Help using "Create Webdriver" instead of "Open Browser"

1,063 views
Skip to first unread message

Dave V.

unread,
Mar 8, 2016, 4:30:20 PM3/8/16
to robotframework-users
I need to launch Chrome with command line arguments.

From the command line, I do this:
chrome --user-data-dir=C:/TEMP/LPDATA --disable-web-security --app=http://localhost:3000

I'm at a loss for how to do this in RF with Create Webdriver.
The official doc for this keyword says: "See the Selenium API Documentation for information about argument names and appropriate argument values."
but I can't find any info at that link. I also can't find and info on what "WebDriver's __init__" accepts.

Pointers to docs are welcome, as is the right code syntax.

Thanks in advance.

-Dave


Kevin O.

unread,
Mar 9, 2016, 1:54:14 AM3/9/16
to robotframework-users
Finding the information is certainly challenging. ChromeOptions is not being included in the Sphinx documentation you mentioned even though I think requested it. See the source code I guess. See also see https://sites.google.com/a/chromium.org/chromedriver/capabilities and http://peter.sh/experiments/chromium-command-line-switches/

As for what "WebDriver's __init__" accepts, it depends on the browser. Go to the Selenium API Documentation you mentioned and click on the link for the webdriver for the relevant browser. In your case, selenium.webdriver.chrome.webdriver. selenium.webdriver.chrome.webdriver is aliased as selenium.webdriver.Chrome, which you can tell by looking at the __init__ for selenium.webdriver.
I wish it was easier but that's how Selenium is documented and implemented.

I think this will get you going but I have not tested it:

    ${chrome options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome options}    add_argument    user-data-dir\=C:\\TEMP\\LPDATA
    Call Method    ${chrome options}    add_argument    disable-web-security
    Call Method    ${chrome options}    add_argument    app\=http://localhost:3000
    Create Webdriver    Chrome    chrome_options=${chrome options}
    Goto    https://...

I think everyone who works on Selenium2Library would like this to be easy, but I do not see how it could be considering the number of variations in launching Selenium and the documentation of upstream projects.

Kevin

Dave V.

unread,
Mar 9, 2016, 9:41:05 AM3/9/16
to robotframework-users
Thank you Kevin, that got me on the right path.
I think my major issue is grasping how this is documented.
I'm learning though. Baby steps...

-Dave
Reply all
Reply to author
Forward
0 new messages