Skip to content

fix(options): store default automationName with the appium: prefix - #10

Draft
MattL1989 wants to merge 1 commit into
masterfrom
fix/default-automation-name-prefix
Draft

MattL1989 wants to merge 1 commit into
masterfrom
fix/default-automation-name-prefix

Conversation

@MattL1989

Copy link
Copy Markdown
Owner

Problem

Driver options such as UiAutomator2Options store their default automationName under the bare key, because AppiumOptions.__init__ assigns default_capabilities straight to _caps. The automation_name setter goes through set_capability, which writes appium:automationName. So the two never meet:

options = UiAutomator2Options()
options.automation_name = 'Espresso'
options.automation_name      # 'UIAutomator2', expected 'Espresso'
options.to_capabilities()
# {'automationName': 'UIAutomator2', 'platformName': 'Android', 'appium:automationName': 'Espresso'}

options.automation_name = None
options.automation_name      # still 'UIAutomator2'

Clearing automation_name removes only the prefixed key, so the default is still sent to the server. The same happens for every options class with a default: Espresso, XCUITest, Safari, Mac2, Windows, Gecko and FlutterIntegration.

Fix

Load the defaults through load_capabilities, so they get the same W3C names as every other capability. platformName is a W3C capability and stays unprefixed.

Behaviour change: to_capabilities() now returns appium:automationName instead of automationName, for example {'appium:automationName': 'UIAutomator2', 'platformName': 'Android'}. Code that reads to_capabilities()['automationName'] directly needs updating; get_capability('automationName') and the automation_name property work as before. The to_w3c() request body is unchanged, except that setting automation_name = None now really removes it.

Tests

  • Added unit tests that check every options class stores its defaults as appium:automationName (and platformName unprefixed), that to_w3c() still sends the same body, that setting automation_name replaces the default, and that setting it to None removes it. Without the fix they fail with, for example, assert 'UIAutomator2' == 'Espresso'.
  • Compared the to_w3c() output before and after the fix for every options class, with default, overridden and loaded automation names. It only differs when automation_name is set to None.
  • No existing test asserted the bare key in to_capabilities().
  • ruff check, ruff format --check, mypy appium and the full unit test suite pass.

🤖 Generated with Claude Code

AppiumOptions.__init__ assigned default_capabilities straight to _caps,
so driver defaults such as automationName were stored under the bare
key, while the automation_name setter (via set_capability) writes
appium:automationName. As a result:

- UiAutomator2Options() then automation_name = 'Espresso' left both
  keys in to_capabilities(), and the getter still returned the default
  'UIAutomator2' because get_capability checks the bare key first.
- automation_name = None removed only the prefixed key, so the default
  was still sent to the server.

Load the defaults through load_capabilities so they get the same W3C
names as every other capability. platformName is a W3C capability and
stays unprefixed. to_capabilities() now returns appium:automationName
instead of automationName; the to_w3c() request body is unchanged,
except that clearing automation_name now really removes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant