Skip to content

Commit

Permalink
Completed initial construct of service class
Browse files Browse the repository at this point in the history
Although I have completed the intial implementation of the service class and
it's usage, I have discovered unlike the selenium options most if not all of the attributes
must be set on the instantiate of the class. So need to rework the parsing (should check
signature instead of attributes) and then construct the class with these parameters.
  • Loading branch information
emanlove committed Feb 19, 2024
1 parent da2004f commit 5ca677d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion atest/acceptance/browser_service.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Documentation These tests check the service argument of Open Browser.
*** Test Cases ***
Browser With Selenium Service As String
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... service=port=1234; executable_path = '/path/to/driver/executable'
... service=port=1234; executable_path='/path/to/driver/executable'
8 changes: 5 additions & 3 deletions src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class WebDriverCreator:
def __init__(self, log_dir):
self.log_dir = log_dir
self.selenium_options = SeleniumOptions()
#self.selenium_service = SeleniumService()
self.selenium_service = SeleniumService()

def create_driver(
self,
Expand All @@ -76,6 +76,7 @@ def create_driver(
desired_capabilities = self._parse_capabilities(desired_capabilities, browser)
service_log_path = self._get_log_path(service_log_path)
options = self.selenium_options.create(self.browser_names.get(browser), options)
service = self.selenium_service.create(self.browser_names.get(browser), service)
if service_log_path:
logger.info(f"Browser driver log file created to: {service_log_path}")
self._create_directory(service_log_path)
Expand Down Expand Up @@ -160,7 +161,8 @@ def create_chrome(
if not executable_path:
executable_path = self._get_executable_path(webdriver.chrome.service.Service)
log_method = self._get_log_method(ChromeService, service_log_path)
service = ChromeService(executable_path=executable_path, **log_method)
if not service:
service = ChromeService(executable_path=executable_path, **log_method)
return webdriver.Chrome(
options=options,
service=service,
Expand Down Expand Up @@ -573,7 +575,7 @@ def _split(self, service):
if toknum == token.OP and tokval == ";":
split_service.append(service[start_position : tokpos[1]].strip())
start_position = tokpos[1] + 1
split_service.append(options[start_position:])
split_service.append(service[start_position:])
return split_service

class SeleniumOptions:
Expand Down

0 comments on commit 5ca677d

Please sign in to comment.