Skip to content

Commit b933ea3

Browse files
committed
Options need to be initialized for remote browsers
For several of the remote browsers we need to initialize the options if none are provided. In addition I removed the deprecated and removed from selenium desired_capabilities. This fixes #1855.
1 parent f3caca2 commit b933ea3

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,9 @@ def create_chrome(
140140
executable_path="chromedriver",
141141
):
142142
if remote_url:
143-
defaul_caps = webdriver.DesiredCapabilities.CHROME.copy()
144-
desired_capabilities = self._remote_capabilities_resolver(
145-
desired_capabilities, defaul_caps
146-
)
147-
return self._remote(desired_capabilities, remote_url, options=options)
143+
if not options:
144+
options = webdriver.ChromeOptions()
145+
return self._remote(remote_url, options=options)
148146
if not executable_path:
149147
executable_path = self._get_executable_path(webdriver.chrome.service.Service)
150148
service = ChromeService(executable_path=executable_path, log_path=service_log_path)
@@ -196,11 +194,7 @@ def create_firefox(
196194
# as to attach the profile to it. If there a scenario in which we don't want to do this???
197195

198196
if remote_url:
199-
default_caps = webdriver.DesiredCapabilities.FIREFOX.copy()
200-
desired_capabilities = self._remote_capabilities_resolver(
201-
desired_capabilities, default_caps
202-
)
203-
return self._remote(desired_capabilities, remote_url, profile, options)
197+
return self._remote(remote_url, options)
204198
service_log_path = (
205199
service_log_path if service_log_path else self._geckodriver_log
206200
)
@@ -209,9 +203,7 @@ def create_firefox(
209203
service = FirefoxService(executable_path=executable_path, log_path=service_log_path)
210204
return webdriver.Firefox(
211205
options=options,
212-
#firefox_profile=profile, # need to move
213206
service=service,
214-
#**desired_capabilities,
215207
)
216208

217209
def _get_ff_profile(self, ff_profile_dir):
@@ -271,11 +263,9 @@ def create_ie(
271263
executable_path="IEDriverServer.exe",
272264
):
273265
if remote_url:
274-
defaul_caps = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()
275-
desired_capabilities = self._remote_capabilities_resolver(
276-
desired_capabilities, defaul_caps
277-
)
278-
return self._remote(desired_capabilities, remote_url, options=options)
266+
if not options:
267+
options = webdriver.IeOptions()
268+
return self._remote(remote_url, options=options)
279269
if not executable_path:
280270
executable_path = self._get_executable_path(webdriver.ie.service.Service)
281271
service = IeService(executable_path=executable_path, log_path=service_log_path)
@@ -298,11 +288,9 @@ def create_edge(
298288
executable_path="msedgedriver",
299289
):
300290
if remote_url:
301-
defaul_caps = webdriver.DesiredCapabilities.EDGE.copy()
302-
desired_capabilities = self._remote_capabilities_resolver(
303-
desired_capabilities, defaul_caps
304-
)
305-
return self._remote(desired_capabilities, remote_url, options=options)
291+
if not options:
292+
options = webdriver.EdgeOptions()
293+
return self._remote(remote_url, options=options)
306294
if not executable_path:
307295
executable_path = self._get_executable_path(webdriver.edge.service.Service)
308296
service = EdgeService(executable_path=executable_path, log_path=service_log_path)
@@ -321,25 +309,21 @@ def create_safari(
321309
executable_path="/usr/bin/safaridriver",
322310
):
323311
if remote_url:
324-
defaul_caps = webdriver.DesiredCapabilities.SAFARI.copy()
325-
desired_capabilities = self._remote_capabilities_resolver(
326-
desired_capabilities, defaul_caps
327-
)
328-
return self._remote(desired_capabilities, remote_url, options=options)
312+
if not options:
313+
options = webdriver.SafariOptions()
314+
return self._remote(remote_url, options=options)
329315
if not executable_path:
330316
executable_path = self._get_executable_path(webdriver.Safari)
331317
service = SafariService(executable_path=executable_path, log_path=service_log_path)
332318
return webdriver.Safari(options=options, service=service)
333319

334-
def _remote(self, desired_capabilities, remote_url, profile_dir=None, options=None):
320+
def _remote(self, remote_url, options):
335321
remote_url = str(remote_url)
336322
file_detector = self._get_sl_file_detector()
337323
return webdriver.Remote(
338324
command_executor=remote_url,
339-
# browser_profile=profile_dir,
340325
options=options,
341326
file_detector=file_detector,
342-
# **desired_capabilities,
343327
)
344328

345329
def _get_sl_file_detector(self):

0 commit comments

Comments
 (0)