Skip to content

Commit c23e440

Browse files
[py] Improve how desired_capabilities and options are merged
The code has been moved around over time so have take the gist of the original PR by @earendil and made it work. Original PR in #7348
1 parent 4fc2afe commit c23e440

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

py/selenium/webdriver/chrome/webdriver.py

-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,3 @@ def __init__(self, executable_path="chromedriver", port=DEFAULT_PORT,
6565
port, options,
6666
service_args, desired_capabilities,
6767
service_log_path, service, keep_alive)
68-
69-
def create_options(self) -> Options:
70-
return Options()

py/selenium/webdriver/chromium/webdriver.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ def __init__(self, browser_name, vendor_prefix,
6464

6565
_ignore_proxy = None
6666
if not options:
67-
# desired_capabilities stays as passed in
68-
if not desired_capabilities:
69-
desired_capabilities = self.create_options().to_capabilities()
70-
else:
71-
if not desired_capabilities:
72-
desired_capabilities = options.to_capabilities()
73-
else:
74-
desired_capabilities.update(options.to_capabilities())
75-
if options._ignore_local_proxy:
76-
_ignore_proxy = options._ignore_local_proxy
67+
options = self.create_options()
68+
69+
if desired_capabilities:
70+
for key, value in desired_capabilities.items():
71+
options.set_capability(key, value)
72+
73+
if options._ignore_local_proxy:
74+
_ignore_proxy = options._ignore_local_proxy
7775

7876
self.vendor_prefix = vendor_prefix
7977

@@ -204,5 +202,5 @@ def quit(self) -> NoReturn:
204202
finally:
205203
self.service.stop()
206204

207-
def create_options(self):
208-
pass
205+
def create_options(self) -> Options:
206+
return Options()

0 commit comments

Comments
 (0)