Skip to content

Commit 66aabbd

Browse files
committed
Allow for trailing semicolon within selenium options
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 #1877
1 parent ffbc863 commit 66aabbd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/SeleniumLibrary/keywords/webdrivertools/webdrivertools.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ def create(self, browser, options):
503503
selenium_options = selenium_options()
504504
for option in options:
505505
for key in option:
506+
if key == '' and option[key]==[]:
507+
logger.warn('Empty selenium option found and ignored. Suggested you review options passed to `Open Browser` keyword')
508+
continue
506509
attr = getattr(selenium_options, key)
507510
if callable(attr):
508511
attr(*option[key])
@@ -566,9 +569,12 @@ def _split(self, options):
566569
split_options = []
567570
start_position = 0
568571
tokens = generate_tokens(StringIO(options).readline)
569-
for toknum, tokval, tokpos, _, _ in tokens:
570-
if toknum == token.OP and tokval == ";":
572+
for toktype, tokval, tokpos, _, _ in tokens:
573+
if toktype == token.OP and tokval == ";":
571574
split_options.append(options[start_position : tokpos[1]].strip())
572575
start_position = tokpos[1] + 1
573-
split_options.append(options[start_position:])
576+
# Handles trailing semicolon
577+
# !! Note: If multiline options allowed this splitter might fail !!
578+
if toktype == token.NEWLINE and start_position != tokpos[1]:
579+
split_options.append(options[start_position : tokpos[1]].strip())
574580
return split_options

0 commit comments

Comments
 (0)