Skip to content

Commit

Permalink
Starting to bring service class down into driver creation for various…
Browse files Browse the repository at this point in the history
… browsers

The is just an in ititial commit with some changes which bring the service class down to
the point where we create/instantiate the webdrivers for the for the various browsers.
Still need some work to actually use what the user provides and to test this code.
  • Loading branch information
emanlove committed Feb 18, 2024
1 parent 6f9954b commit da2004f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/SeleniumLibrary/keywords/browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def open_browser(
options: Any = None,
service_log_path: Optional[str] = None,
executable_path: Optional[str] = None,
service: Any = None,
) -> str:
"""Opens a new browser instance to the optional ``url``.
Expand Down Expand Up @@ -279,6 +280,10 @@ def open_browser(
return index
if desired_capabilities:
self.warn("desired_capabilities has been deprecated and removed. Please use options to configure browsers as per documentation.")
if service_log_path:
self.warn("service_log_path is being deprecated. Please use service to configure log_output or equivalent service attribute.")
if executable_path:
self.warn("exexcutable_path is being deprecated. Please use service to configure the driver's executable_path as per documentation.")
return self._make_new_browser(
url,
browser,
Expand All @@ -289,6 +294,7 @@ def open_browser(
options,
service_log_path,
executable_path,
service,
)

def _make_new_browser(
Expand All @@ -302,6 +308,7 @@ def _make_new_browser(
options=None,
service_log_path=None,
executable_path=None,
service=None,
):
if remote_url:
self.info(
Expand All @@ -318,6 +325,7 @@ def _make_new_browser(
options,
service_log_path,
executable_path,
service,
)
driver = self._wrap_event_firing_webdriver(driver)
index = self.ctx.register_driver(driver, alias)
Expand Down Expand Up @@ -763,6 +771,7 @@ def _make_driver(
options=None,
service_log_path=None,
executable_path=None,
service=None,
):
driver = self._webdriver_creator.create_driver(
browser=browser,
Expand All @@ -772,6 +781,7 @@ def _make_driver(
options=options,
service_log_path=service_log_path,
executable_path=executable_path,
service=service,
)
driver.set_script_timeout(self.ctx.timeout)
driver.implicitly_wait(self.ctx.implicit_wait)
Expand Down
5 changes: 5 additions & 0 deletions src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def create_driver(
options=None,
service_log_path=None,
executable_path=None,
service=None,
):
browser = self._normalise_browser_name(browser)
creation_method = self._get_creator_method(browser)
Expand All @@ -89,13 +90,15 @@ def create_driver(
options=options,
service_log_path=service_log_path,
executable_path=executable_path,
service=service,
)
return creation_method(
desired_capabilities,
remote_url,
options=options,
service_log_path=service_log_path,
executable_path=executable_path,
service=service,
)

def _get_creator_method(self, browser):
Expand Down Expand Up @@ -148,6 +151,7 @@ def create_chrome(
options=None,
service_log_path=None,
executable_path="chromedriver",
service=None,
):
if remote_url:
if not options:
Expand All @@ -169,6 +173,7 @@ def create_headless_chrome(
options=None,
service_log_path=None,
executable_path="chromedriver",
service=None,
):
if not options:
options = webdriver.ChromeOptions()
Expand Down

0 comments on commit da2004f

Please sign in to comment.