Repository navigation
Conversation
`WebDriver.__init__` checked `client_config.direct_connection` on the `client_config` argument as returned by `_get_remote_connection_and_client_config`. That caused two problems: - When a custom `AppiumConnection` is passed as `command_executor`, the helper returns `client_config=None`, so `direct_connection=True` on the connection's own `AppiumClientConfig` was silently ignored. - When a Selenium `ClientConfig` is passed as `client_config`, the check raised `AttributeError: 'ClientConfig' object has no attribute 'direct_connection'`. This happened after the server had created the session, so the session was left running. Read the client config from the command executor instead, which is the config the driver actually uses, and switch to the direct connect endpoint only when it is an `AppiumClientConfig` with `direct_connection` enabled. Its `keep_alive` is still used for the new connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WebDriver.__init__decides whether to use direct connect withif client_config and client_config.direct_connection:. Thatclient_configis the one returned by_get_remote_connection_and_client_config, which causes two problems.1. A custom connection's
direct_connectionis ignored. When a customAppiumConnectionis passed ascommand_executor, the helper returnsclient_config=None, because the connection already has its own config. Direct connect is then skipped, even though that config enables it:2. A Selenium
ClientConfigraisesAttributeError.The error is raised after the server has created the session, so that session is left running on the server.
Fix
getattr(self.command_executor, 'client_config', None)). This is the config the driver actually uses, whether it came fromclient_configor from a custom connection.AppiumClientConfigwithdirect_connectionenabled. Itskeep_aliveis used for the new connection, as before.Behaviour change: a custom
AppiumConnectionwhoseAppiumClientConfighasdirect_connection=Truenow switches to the direct connect endpoint when the server returns thedirectConnect*capabilities. Before, this setting was ignored. For the new endpoint,_update_command_executorcreates a plainAppiumConnectionwith a copy of the config, as it already does today, so a subclass ofAppiumConnectionis not kept after the switch.Tests
test_create_session_register_uridirect_with_custom_connection: a customAppiumConnectionwithdirect_connection=Trueandkeep_alive=False. The driver now talks to the direct connect endpoint and keepskeep_alive=False. Without the fix, the driver stays onhttp://127.0.0.1:4723.test_create_session_with_selenium_client_config: a SeleniumClientConfigcreates the driver without error and stays on the original endpoint. Without the fix, it raises theAttributeErrorabove.AppiumClientConfigthroughclient_config, pass unchanged.ruff check,ruff format --check,mypy appiumand the full unit test suite pass.🤖 Generated with Claude Code