Skip to content

Commit 27cb0ca

Browse files
committed
initial implementation
1 parent ea61c2e commit 27cb0ca

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

appium/webdriver/webdriver.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
WebDriverException,
2323
)
2424
from selenium.webdriver.common.by import By
25-
from selenium.webdriver.remote.client_config import ClientConfig
2625
from selenium.webdriver.remote.command import Command as RemoteCommand
2726
from selenium.webdriver.remote.remote_connection import RemoteConnection
2827
from typing_extensions import Self
@@ -32,6 +31,7 @@
3231
from appium.webdriver.common.appiumby import AppiumBy
3332

3433
from .appium_connection import AppiumConnection
34+
from .client_config import AppiumClientConfg
3535
from .errorhandler import MobileErrorHandler
3636
from .extensions.action_helpers import ActionHelpers
3737
from .extensions.android.activities import Activities
@@ -205,24 +205,16 @@ class WebDriver(
205205
def __init__( # noqa: PLR0913
206206
self,
207207
command_executor: Union[str, AppiumConnection] = 'http://127.0.0.1:4444/wd/hub',
208-
keep_alive: bool = True,
209-
direct_connection: bool = True,
210208
extensions: Optional[List['WebDriver']] = None,
211-
strict_ssl: bool = True,
212209
options: Union[AppiumOptions, List[AppiumOptions], None] = None,
213-
client_config: Optional[ClientConfig] = None,
210+
client_config: Optional[AppiumClientConfg] = None,
214211
):
212+
if client_config is None:
213+
# TODO: when command_executor is not string
214+
client_config = client_config or AppiumClientConfg(remote_server_addr=command_executor)
215+
215216
if isinstance(command_executor, str):
216-
client_config = client_config or ClientConfig(
217-
remote_server_addr=command_executor, keep_alive=keep_alive, ignore_certificates=not strict_ssl
218-
)
219-
client_config.remote_server_addr = command_executor
220217
command_executor = AppiumConnection(remote_server_addr=command_executor, client_config=client_config)
221-
elif isinstance(command_executor, AppiumConnection) and strict_ssl is False:
222-
logger.warning(
223-
"Please set 'ignore_certificates' in the given 'appium.webdriver.appium_connection.AppiumConnection' or "
224-
"'selenium.webdriver.remote.client_config.ClientConfig' instead. Ignoring."
225-
)
226218

227219
super().__init__(
228220
command_executor=command_executor,
@@ -237,8 +229,8 @@ def __init__( # noqa: PLR0913
237229

238230
self.error_handler = MobileErrorHandler()
239231

240-
if direct_connection:
241-
self._update_command_executor(keep_alive=keep_alive)
232+
if client_config.direct_connection:
233+
self._update_command_executor(keep_alive=client_config.keep_alive)
242234

243235
# add new method to the `find_by_*` pantheon
244236
By.IOS_PREDICATE = AppiumBy.IOS_PREDICATE

test/unit/webdriver/webdriver_test.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from appium import webdriver
2222
from appium.options.android import UiAutomator2Options
2323
from appium.webdriver.appium_connection import AppiumConnection
24+
from appium.webdriver.client_config import AppiumClientConfg
2425
from appium.webdriver.webdriver import ExtensionBase, WebDriver
2526
from test.helpers.constants import SERVER_URL_BASE
2627
from test.unit.helper.test_helper import (
@@ -124,10 +125,11 @@ def test_create_session_register_uridirect(self):
124125
'app': 'path/to/app',
125126
'automationName': 'UIAutomator2',
126127
}
128+
client_config = AppiumClientConfg(remote_server_addr=SERVER_URL_BASE, direct_connection=True)
127129
driver = webdriver.Remote(
128130
SERVER_URL_BASE,
129131
options=UiAutomator2Options().load_capabilities(desired_caps),
130-
direct_connection=True,
132+
client_config=client_config,
131133
)
132134

133135
assert 'http://localhost2:4800/special/path/wd/hub' == driver.command_executor._client_config.remote_server_addr
@@ -164,10 +166,9 @@ def test_create_session_register_uridirect_no_direct_connect_path(self):
164166
'app': 'path/to/app',
165167
'automationName': 'UIAutomator2',
166168
}
169+
client_config = AppiumClientConfg(remote_server_addr=SERVER_URL_BASE, direct_connection=True)
167170
driver = webdriver.Remote(
168-
SERVER_URL_BASE,
169-
options=UiAutomator2Options().load_capabilities(desired_caps),
170-
direct_connection=True,
171+
SERVER_URL_BASE, options=UiAutomator2Options().load_capabilities(desired_caps), client_config=client_config
171172
)
172173

173174
assert SERVER_URL_BASE == driver.command_executor._client_config.remote_server_addr
@@ -382,19 +383,17 @@ def test_extention_command_check(self):
382383

383384

384385
class SubWebDriver(WebDriver):
385-
def __init__(self, command_executor, direct_connection=False, options=None):
386+
def __init__(self, command_executor, options=None):
386387
super().__init__(
387388
command_executor=command_executor,
388-
direct_connection=direct_connection,
389389
options=options,
390390
)
391391

392392

393393
class SubSubWebDriver(SubWebDriver):
394-
def __init__(self, command_executor, direct_connection=False, options=None):
394+
def __init__(self, command_executor, options=None):
395395
super().__init__(
396396
command_executor=command_executor,
397-
direct_connection=direct_connection,
398397
options=options,
399398
)
400399

0 commit comments

Comments
 (0)