Skip to content

Commit c0f38bf

Browse files
fix: Update the constructor for compatibility with python client 4.10 (#879)
1 parent 2f45ef9 commit c0f38bf

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ typing-extensions = "~=4.6"
1919
types-python-dateutil = "~=2.8"
2020

2121
[packages]
22-
selenium = "~=4.9"
22+
selenium = "~=4.10"

appium/webdriver/webdriver.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def add_command(self):
9090
9191
2. Creates a session with the extension.
9292
# Appium capabilities
93-
desired_caps = { ... }
94-
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps,
93+
options = AppiumOptions()
94+
driver = webdriver.Remote('http://localhost:4723/wd/hub', options=options,
9595
extensions=[YourCustomCommand])
9696
9797
3. Calls the custom command
@@ -207,8 +207,11 @@ class WebDriver(
207207
def __init__(
208208
self,
209209
command_executor: Union[str, AppiumConnection] = 'http://127.0.0.1:4444/wd/hub',
210+
# TODO: Remove the deprecated arg
210211
desired_capabilities: Optional[Dict] = None,
212+
# TODO: Remove the deprecated arg
211213
browser_profile: Union[str, None] = None,
214+
# TODO: Remove the deprecated arg
212215
proxy: Union[str, None] = None,
213216
keep_alive: bool = True,
214217
direct_connection: bool = True,
@@ -232,12 +235,28 @@ def __init__(
232235
if isinstance(command_executor, str):
233236
command_executor = AppiumConnection(command_executor, keep_alive=keep_alive)
234237

238+
if browser_profile is not None:
239+
warnings.warn('browser_profile argument is deprecated and has no effect', DeprecationWarning)
240+
241+
if proxy is not None:
242+
warnings.warn('proxy argument is deprecated and has no effect', DeprecationWarning)
243+
244+
if desired_capabilities is not None:
245+
warnings.warn(
246+
'desired_capabilities argument is deprecated and will be removed in future versions. '
247+
'Use options instead.',
248+
DeprecationWarning,
249+
)
250+
# TODO: Remove the fallback after desired_capabilities removal
251+
dst_options = (
252+
AppiumOptions().load_capabilities(desired_capabilities)
253+
if desired_capabilities is not None and options is None
254+
else options
255+
)
256+
235257
super().__init__(
236258
command_executor=command_executor,
237-
desired_capabilities=desired_capabilities,
238-
browser_profile=browser_profile,
239-
proxy=proxy,
240-
options=options,
259+
options=dst_options,
241260
)
242261

243262
if hasattr(self, 'command_executor'):

0 commit comments

Comments
 (0)