Skip to content

Commit

Permalink
Allow for trailing semicolon within selenium options
Browse files Browse the repository at this point in the history
Within the selenium options argument of the `Open Browser` keword, if there were
trailing semicolons then the keyword would fail. With this change we allow trailing
semicolons. In addition the library warns about emtpy options.

Fixes robotframework#1877
  • Loading branch information
emanlove committed Jan 14, 2024
1 parent ffbc863 commit 66aabbd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def create(self, browser, options):
selenium_options = selenium_options()
for option in options:
for key in option:
if key == '' and option[key]==[]:
logger.warn('Empty selenium option found and ignored. Suggested you review options passed to `Open Browser` keyword')
continue
attr = getattr(selenium_options, key)
if callable(attr):
attr(*option[key])
Expand Down Expand Up @@ -566,9 +569,12 @@ def _split(self, options):
split_options = []
start_position = 0
tokens = generate_tokens(StringIO(options).readline)
for toknum, tokval, tokpos, _, _ in tokens:
if toknum == token.OP and tokval == ";":
for toktype, tokval, tokpos, _, _ in tokens:
if toktype == token.OP and tokval == ";":
split_options.append(options[start_position : tokpos[1]].strip())
start_position = tokpos[1] + 1
split_options.append(options[start_position:])
# Handles trailing semicolon
# !! Note: If multiline options allowed this splitter might fail !!
if toktype == token.NEWLINE and start_position != tokpos[1]:
split_options.append(options[start_position : tokpos[1]].strip())
return split_options

0 comments on commit 66aabbd

Please sign in to comment.