Skip to content

Commit 9569035

Browse files
committed
add test to check remote_server_addr priority
1 parent 2aabd72 commit 9569035

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ For example, some changes in the Selenium binding could break the Appium client.
7676
# after
7777
from appium.webdriver.client_config import AppiumClientConfig
7878
client_config = AppiumClientConfig(
79+
remote_server_addr=SERVER_URL_BASE,
7980
direct_connection=True,
8081
keep_alive=False,
8182
ignore_certificates=True,
8283
)
8384
driver = webdriver.Remote(
84-
SERVER_URL_BASE,
8585
options=UiAutomator2Options().load_capabilities(desired_caps),
8686
client_config=client_config
8787
)

appium/webdriver/webdriver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ def __init__( # noqa: PLR0913
214214
if isinstance(command_executor, str):
215215
if client_config is None:
216216
client_config = AppiumClientConfig(remote_server_addr=command_executor)
217-
else:
218-
client_config.remote_server_addr = command_executor
219217
# To prevent generating RemoteConnection in selenium
220218
command_executor = AppiumConnection(client_config=client_config)
221219

test/unit/webdriver/webdriver_test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,45 @@ def test_create_session_register_uridirect_no_direct_connect_path(self):
175175
assert ['NATIVE_APP', 'CHROMIUM'] == driver.contexts
176176
assert isinstance(driver.command_executor, AppiumConnection)
177177

178+
@httpretty.activate
179+
def test_create_session_remote_server_addr_treatment_with_appiumclientconfig(self):
180+
# remote server add in AppiumRemoteCong will be prior than the string of 'command_executor'
181+
# as same as Selenium behavior.
182+
httpretty.register_uri(
183+
httpretty.POST,
184+
f'{SERVER_URL_BASE}/session',
185+
body=json.dumps(
186+
{
187+
'sessionId': 'session-id',
188+
'capabilities': {
189+
'deviceName': 'Android Emulator',
190+
},
191+
}
192+
),
193+
)
194+
195+
httpretty.register_uri(
196+
httpretty.GET,
197+
f'{SERVER_URL_BASE}/session/session-id/contexts',
198+
body=json.dumps({'value': ['NATIVE_APP', 'CHROMIUM']}),
199+
)
200+
201+
desired_caps = {
202+
'platformName': 'Android',
203+
'deviceName': 'Android Emulator',
204+
'app': 'path/to/app',
205+
'automationName': 'UIAutomator2',
206+
}
207+
client_config = AppiumClientConfig(remote_server_addr=SERVER_URL_BASE, direct_connection=True)
208+
driver = webdriver.Remote(
209+
'http://localhost:8080/something/path',
210+
options=UiAutomator2Options().load_capabilities(desired_caps),
211+
client_config=client_config,
212+
)
213+
214+
assert SERVER_URL_BASE == driver.command_executor._client_config.remote_server_addr
215+
assert isinstance(driver.command_executor, AppiumConnection)
216+
178217
@httpretty.activate
179218
def test_get_events(self):
180219
driver = ios_w3c_driver()

0 commit comments

Comments
 (0)