Closed manosnoam closed 5 months ago
This is due to how we parse the options string. I think that having a trailing semicolon should not throw an error. To me I could see one constructing this string somewhere and for each options adding a trailing semicolon. Thus it would be too much to ask that the last in the set does not contain a trailing semicolin.
I think it is easy enough to ignore those although I see our parsing thinks that introduces another option. I was considering similar cases like,
*** Test Cases ***
Chrome Browser with Selenium Options Ending With A Few Semicolons
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument("--disable-dev-shm-usage") ; ; ;
Chrome Browser with Selenium Options Containing Empty Option
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
... desired_capabilities=${DESIRED_CAPABILITIES} options=add_argument ( "--disable-dev-shm-usage" ) ; ; add_argument ( "--headless=new" )
In these I see the option as being empty for which a warning could be helpful. But we shouldn't warn that you have an empty option for just a trailing semicolon.
Somewhat related, a recent question was asked on setting some download options for which the poster had this, the first test case, solution to their problem,
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Example Of Complex Selenium Options Using Create Dictionary
${Prefs}= Create Dictionary profile.default_content_settings.popups=0, download.default_directory=r"C:\\Users\\me\\test_downloads",download.prompt_for_download:False
Open Browser about:blank Chrome alias=UserCreate
... options=add_argument("--disable-popup-blocking"); add_argument("--ignore-certificate-errors"); add_argument("--disable-gpu"); add_argument("--disable-dev-shm-usage"); add_argument("--no-sandbox");add_argument("--disable-proxy-certificate-handler");add_experimental_option("prefs", ${Prefs})
Example Of Complex Selenium Options Using Options String
Open Browser about:blank Chrome alias=UserCreate
... options=add_argument("--disable-popup-blocking"); add_argument("--ignore-certificate-errors"); add_argument("--disable-gpu"); add_argument("--disable-dev-shm-usage"); add_argument("--no-sandbox");add_argument("--disable-proxy-certificate-handler");add_experimental_option("prefs", { 'profile.default_content_settings.popups' : 0 , 'download.default_directory' : r"C:\\Users\\me\\test_downloads" , 'download.prompt_for_download' : False } )
I was thinking one should be able to put this configuration in as a simple options string. But I see with this attempt the tokenizer fails. It is the tokenizer which parses out the trailing semicolon thinking it is expecting another option as well. Might be able to solve both these at once (although I will focus on the primary problem listed here first). Correction: My error. I had a semicolon as the dictionary key-value pair separator for some reason. As I debug this I see that the Python tokenizer is parsing Python syntax/lexicon and of course the (proper) separator is a comma. So the above code is valid and works!
One other side note is #4948 within robotfram,ework core might help with the visual problem that these options lines can get very long and would allow for multiline usage.
When calling
open browser
withoptions
that ends with;
such as:Then the browser will fail to open with error:
Once I removed the last
;
then the browser was launched with the required options.Found in RF version 6.0