Skip to content

Commit 683fb0d

Browse files
committed
Move firefox_profile into moz:firefoxOptions.
Otherwise, the profile might not make it into the W3C capabilities, if moz:firefoxOptions is not set on the requested capabilities.
1 parent cec5677 commit 683fb0d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""The WebDriver implementation."""
1919

2020
import base64
21+
import copy
2122
import warnings
2223
from contextlib import contextmanager
2324

@@ -58,13 +59,25 @@ def _make_w3c_caps(caps):
5859
Filters out capability names that are not in the W3C spec. Spec-compliant
5960
drivers will reject requests containing unknown capability names.
6061
62+
Moves the Firefox profile, if present, from the old location to the new Firefox
63+
options object.
64+
6165
:Args:
6266
- caps - A dictionary of capabilities requested by the caller.
6367
"""
68+
profile = caps.get('firefox_profile')
6469
always_match = {}
6570
for k, v in caps.iteritems():
6671
if k in _W3C_CAPABILITY_NAMES or ':' in k:
6772
always_match[k] = v
73+
if profile:
74+
moz_opts = always_match.get('moz:firefoxOptions', {})
75+
# If it's already present, assume the caller did that intentionally.
76+
if 'profile' not in moz_opts:
77+
# Don't mutate the original capabilities.
78+
new_opts = copy.deepcopy(moz_opts)
79+
new_opts['profile'] = profile
80+
always_match['moz:firefoxOptions'] = new_opts
6881
return {"firstMatch": [{}], "alwaysMatch": always_match}
6982

7083

0 commit comments

Comments
 (0)