Skip to content

Commit

Permalink
fix: self.command_executor instance in _update_command_executor (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa authored Dec 14, 2023
1 parent 876233e commit 17639ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,11 @@ def _update_command_executor(self, keep_alive: bool) -> None:
executor = f'{protocol}://{hostname}:{port}{path}'

logger.debug('Updated request endpoint to %s', executor)
# Override command executor
self.command_executor = RemoteConnection(executor, keep_alive=keep_alive)
# Override command executor.
if isinstance(self.command_executor, AppiumConnection): # type: ignore
self.command_executor = AppiumConnection(executor, keep_alive=keep_alive)
else:
self.command_executor = RemoteConnection(executor, keep_alive=keep_alive)
self._add_commands()

# https://github.com/SeleniumHQ/selenium/blob/06fdf2966df6bca47c0ae45e8201cd30db9b9a49/py/selenium/webdriver/remote/webdriver.py#L277
Expand Down
2 changes: 2 additions & 0 deletions test/unit/webdriver/webdriver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def test_create_session_register_uridirect(self):

assert 'http://localhost2:4800/special/path/wd/hub' == driver.command_executor._url
assert ['NATIVE_APP', 'CHROMIUM'] == driver.contexts
assert isinstance(driver.command_executor, AppiumConnection)

@httpretty.activate
def test_create_session_register_uridirect_no_direct_connect_path(self):
Expand Down Expand Up @@ -173,6 +174,7 @@ def test_create_session_register_uridirect_no_direct_connect_path(self):

assert SERVER_URL_BASE == driver.command_executor._url
assert ['NATIVE_APP', 'CHROMIUM'] == driver.contexts
assert isinstance(driver.command_executor, AppiumConnection)

@httpretty.activate
def test_get_events(self):
Expand Down

0 comments on commit 17639ea

Please sign in to comment.