Skip to content

Commit 2c1575b

Browse files
committed
Updated browser creator arguments for Chrome, Firefox, Edge and IE
Selenium 4.10.0 removed the deprecated arguments to the various borwser creation classes. This starts to move to the newer version. There are a few things still to do - Fix the unit tests as I know these are failing. This is in progress. - Add in the firefox_profile argument for Firefox - Safari has not only a similar issue, the creation code is a bit behind in that options are now allowed as of v4.1.3/v4.1.4 - [.. add I recall something else but can't remember at the moment..]
1 parent 3560c5f commit 2c1575b

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
from selenium import webdriver
2828
from selenium.webdriver import FirefoxProfile
2929

30+
from selenium.webdriver.chrome.service import Service as ChromeService
31+
from selenium.webdriver.edge.service import Service as EdgeService
32+
from selenium.webdriver.firefox.service import Service as FirefoxService
33+
from selenium.webdriver.ie.service import Service as IeService
34+
3035
from SeleniumLibrary.keywords.webdrivertools.sl_file_detector import (
3136
SelLibLocalFileDetector,
3237
)
@@ -144,12 +149,11 @@ def create_chrome(
144149
)
145150
return self._remote(desired_capabilities, remote_url, options=options)
146151
if not executable_path:
147-
executable_path = self._get_executable_path(webdriver.Chrome)
152+
executable_path = self._get_executable_path(webdriver.chrome.service.Service)
153+
service = ChromeService(executable_path=executable_path, log_path=service_log_path)
148154
return webdriver.Chrome(
149155
options=options,
150-
service_log_path=service_log_path,
151-
executable_path=executable_path,
152-
**desired_capabilities,
156+
service=service,
153157
)
154158

155159
def create_headless_chrome(
@@ -195,13 +199,13 @@ def create_firefox(
195199
service_log_path if service_log_path else self._geckodriver_log
196200
)
197201
if not executable_path:
198-
executable_path = self._get_executable_path(webdriver.Firefox)
202+
executable_path = self._get_executable_path(webdriver.firefox.service.Service)
203+
service = FirefoxService(executable_path=executable_path, log_path=service_log_path)
199204
return webdriver.Firefox(
200205
options=options,
201-
firefox_profile=profile,
202-
service_log_path=service_log_path,
203-
executable_path=executable_path,
204-
**desired_capabilities,
206+
#firefox_profile=profile, # need to move
207+
service=service,
208+
#**desired_capabilities,
205209
)
206210

207211
def _get_ff_profile(self, ff_profile_dir):
@@ -267,12 +271,12 @@ def create_ie(
267271
)
268272
return self._remote(desired_capabilities, remote_url, options=options)
269273
if not executable_path:
270-
executable_path = self._get_executable_path(webdriver.Ie)
274+
executable_path = self._get_executable_path(webdriver.ie.service.Service)
275+
service = IeService(executable_path=executable_path, log_path=service_log_path)
271276
return webdriver.Ie(
272277
options=options,
273-
service_log_path=service_log_path,
274-
executable_path=executable_path,
275-
**desired_capabilities,
278+
service=service,
279+
#**desired_capabilities,
276280
)
277281

278282
def _has_options(self, web_driver):
@@ -294,20 +298,12 @@ def create_edge(
294298
)
295299
return self._remote(desired_capabilities, remote_url)
296300
if not executable_path:
297-
executable_path = self._get_executable_path(webdriver.Edge)
298-
if self._has_options(webdriver.Edge):
299-
# options is supported from Selenium 4.0 onwards
300-
# If can be removed when minimum Selenium version is 4.0 or greater
301-
return webdriver.Edge(
302-
options=options,
303-
service_log_path=service_log_path,
304-
executable_path=executable_path,
305-
**desired_capabilities,
306-
)
301+
executable_path = self._get_executable_path(webdriver.edge.service.Service)
302+
service = EdgeService(executable_path=executable_path, log_path=service_log_path)
307303
return webdriver.Edge(
308-
service_log_path=service_log_path,
309-
executable_path=executable_path,
310-
**desired_capabilities,
304+
options=options,
305+
service=service,
306+
#**desired_capabilities,
311307
)
312308

313309
def create_safari(

0 commit comments

Comments
 (0)