Skip to content

Commit 17639ea

Browse files
authored
fix: self.command_executor instance in _update_command_executor (appium#940)
1 parent 876233e commit 17639ea

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

appium/webdriver/webdriver.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,11 @@ def _update_command_executor(self, keep_alive: bool) -> None:
295295
executor = f'{protocol}://{hostname}:{port}{path}'
296296

297297
logger.debug('Updated request endpoint to %s', executor)
298-
# Override command executor
299-
self.command_executor = RemoteConnection(executor, keep_alive=keep_alive)
298+
# Override command executor.
299+
if isinstance(self.command_executor, AppiumConnection): # type: ignore
300+
self.command_executor = AppiumConnection(executor, keep_alive=keep_alive)
301+
else:
302+
self.command_executor = RemoteConnection(executor, keep_alive=keep_alive)
300303
self._add_commands()
301304

302305
# https://github.com/SeleniumHQ/selenium/blob/06fdf2966df6bca47c0ae45e8201cd30db9b9a49/py/selenium/webdriver/remote/webdriver.py#L277

test/unit/webdriver/webdriver_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def test_create_session_register_uridirect(self):
134134

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

138139
@httpretty.activate
139140
def test_create_session_register_uridirect_no_direct_connect_path(self):
@@ -173,6 +174,7 @@ def test_create_session_register_uridirect_no_direct_connect_path(self):
173174

174175
assert SERVER_URL_BASE == driver.command_executor._url
175176
assert ['NATIVE_APP', 'CHROMIUM'] == driver.contexts
177+
assert isinstance(driver.command_executor, AppiumConnection)
176178

177179
@httpretty.activate
178180
def test_get_events(self):

0 commit comments

Comments
 (0)