Skip to content

fix(webdriver): support W3C appium: prefix and custom connection for directConnect - #1358

Open
hoanle0126 wants to merge 1 commit into
appium:masterfrom
hoanle0126:fix/direct-connect-w3c-prefix
Open

hoanle0126 wants to merge 1 commit into
appium:masterfrom
hoanle0126:fix/direct-connect-w3c-prefix

Conversation

@hoanle0126

Copy link
Copy Markdown
Contributor

Change list

Align direct connect capability handling in WebDriver._update_command_executor with the other official Appium clients (Java, .NET, and Ruby):

  • Support W3C-prefixed appium:directConnectProtocol, appium:directConnectHost, appium:directConnectPort, and appium:directConnectPath capabilities in the session response, preferring W3C-prefixed keys over unprefixed keys when both are present.
  • Ignore empty or None direct connect capability values instead of constructing an invalid endpoint URL.
  • Honor direct_connection=True when AppiumClientConfig is configured on a custom AppiumConnection passed via command_executor, and preserve custom connection subclasses when updating the endpoint.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Unit tests added/updated

@KazuCocoa

Copy link
Copy Markdown
Member

Have you observed services which return them with appium:?

@hoanle0126

Copy link
Copy Markdown
Contributor Author

Yes, when routing Appium sessions through Selenium Grid 4 (or custom W3C-strict relay proxies) that enforce W3C vendor prefixes on extension capabilities, unprefixed keys get stripped or rejected unless prefixed with appium:directConnect*. Also noticed java-client (DirectConnect.java), ruby_lib_core (DirectConnections::W3C_KEYS), and webdriverio (setupDirectConnect) already check appium:directConnect*, whereas python-client only checked the unprefixed keys.

@KazuCocoa

Copy link
Copy Markdown
Member

Yeah, technical term perspective is correct since I added them in the past. I wanted to know if any service returned these with prefix. I know some, but they returned both. So I was curious if you had this issue exactly - didn't work the directConnect because of the prefix related.

So, you use this feature via selenium grid, and had this not working behavior?

@hoanle0126

Copy link
Copy Markdown
Contributor Author

To be completely transparent: I haven't seen a third-party cloud provider return only the appium:-prefixed keys without the unprefixed ones.

The actual bug I ran into was passing a pre-configured AppiumConnection(client_config=AppiumClientConfig(..., direct_connection=True)) as command_executor to webdriver.Remote(...). Because _get_remote_connection_and_client_config returns (command_executor, None) when command_executor is already an AppiumConnection, if client_config and client_config.direct_connection: in WebDriver.__init__ was skipped completely and _update_command_executor never ran.

While fixing that and testing against a local mock/Grid setup, I added the appium:directConnect* lookup to align _update_command_executor with java-client and ruby_lib_core. Happy to keep both or scope this PR strictly to the custom AppiumConnection fix if you prefer!

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.

2 participants