Skip to content

Commit

Permalink
Updated work on adding service class
Browse files Browse the repository at this point in the history
Some minor changes which I want to store away. Starting to see the final
version of this code. Also started to add a test case copied from the
options test. All this is a work in progress.
  • Loading branch information
emanlove committed Apr 30, 2024
1 parent 5ca677d commit 680ce1d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
53 changes: 53 additions & 0 deletions atest/acceptance/multiple_browsers_service.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
*** Settings ***
Suite Teardown Close All Browsers
# Library ../resources/testlibs/get_selenium_options.py
Resource resource.robot
# Force Tags Known Issue Firefox Known Issue Safari Known Issue Internet Explorer
Documentation Creating test which would work on all browser is not possible.
... These tests are for Chrome only.
*** Test Cases ***
Chrome Browser With Chrome Service As String
[Documentation]
... LOG 1:14 DEBUG GLOB: *"goog:chromeOptions"*
# ... LOG 1:14 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... service=executable_path=/usr/local/bin; port=9999

Chrome Browser With Chrome Service As String With service_args As List
[Documentation]
... LOG 1:14 DEBUG GLOB: *"goog:chromeOptions"*
... LOG 1:14 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
... LOG 1:14 DEBUG GLOB: *"--headless=new"*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... service=service_args=['--append-log', '--readable-timestamp'], log_output=log_path)

Chrome Browser With Selenium Options With Complex Object
[Tags] NoGrid
[Documentation]
... LOG 1:14 DEBUG GLOB: *"goog:chromeOptions"*
... LOG 1:14 DEBUG GLOB: *"mobileEmulation": {"deviceName": "Galaxy S5"*
... LOG 1:14 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... options=add_argument ( "--disable-dev-shm-usage" ) ; add_experimental_option( "mobileEmulation" , { 'deviceName' : 'Galaxy S5'})

Chrome Browser With Selenium Options Object
[Documentation]
... LOG 2:14 DEBUG GLOB: *"goog:chromeOptions"*
... LOG 2:14 DEBUG GLOB: *args": ["--disable-dev-shm-usage"?*
${options} = Get Chrome Options
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=${options}

Chrome Browser With Selenium Options Invalid Method
Run Keyword And Expect Error AttributeError: 'Options' object has no attribute 'not_here_method'
... Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=not_here_method("arg1")


Chrome Browser With Selenium Options Argument With Semicolon
[Documentation]
... LOG 1:14 DEBUG GLOB: *"goog:chromeOptions"*
... LOG 1:14 DEBUG GLOB: *["has;semicolon"*
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("has;semicolon")
11 changes: 11 additions & 0 deletions src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ def _split(self, service):
split_service.append(service[start_position:])
return split_service

def _dualsplit(self, service_or_attr, splittok):
split_string = []
start_position = 0
tokens = generate_tokens(StringIO(service_or_attr).readline)
for toknum, tokval, tokpos, _, _ in tokens:
if toknum == token.OP and tokval == splittok:
split_string.append(service_or_attr[start_position : tokpos[1]].strip())
start_position = tokpos[1] + 1
split_string.append(service_or_attr[start_position:])
return split_string

class SeleniumOptions:
def create(self, browser, options):
if not options:
Expand Down

0 comments on commit 680ce1d

Please sign in to comment.