Skip to content

Commit 41d809a

Browse files
committed
[py] allow Remote webdriver when only given Options class
also, use Options.to_capabilties as base caps
1 parent d7155fe commit 41d809a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,18 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
130130
then default LocalFileDetector() will be used.
131131
- options - instance of a driver options.Options class
132132
"""
133-
if desired_capabilities is None:
134-
raise WebDriverException("Desired Capabilities can't be None")
135-
if not isinstance(desired_capabilities, dict):
136-
raise WebDriverException("Desired Capabilities must be a dictionary")
133+
capabilities = {}
134+
if options is not None:
135+
capabilities = options.to_capabilities()
136+
if desired_capabilities is not None:
137+
if not isinstance(desired_capabilities, dict):
138+
raise WebDriverException("Desired Capabilities must be a dictionary")
139+
else:
140+
capabilities.update(desired_capabilities)
137141
if proxy is not None:
138142
warnings.warn("Please use FirefoxOptions to set proxy",
139143
DeprecationWarning)
140-
proxy.add_to_capabilities(desired_capabilities)
141-
if options is not None:
142-
desired_capabilities.update(options.to_capabilities())
144+
proxy.add_to_capabilities(capabilities)
143145
self.command_executor = command_executor
144146
if type(self.command_executor) is bytes or isinstance(self.command_executor, str):
145147
self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive)
@@ -151,7 +153,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
151153
if browser_profile is not None:
152154
warnings.warn("Please use FirefoxOptions to set browser profile",
153155
DeprecationWarning)
154-
self.start_session(desired_capabilities, browser_profile)
156+
self.start_session(capabilities, browser_profile)
155157
self._switch_to = SwitchTo(self)
156158
self._mobile = Mobile(self)
157159
self.file_detector = file_detector or LocalFileDetector()

0 commit comments

Comments
 (0)