OpenBrowser

Web Automation

Open new browser to given url.

Uses the Selenium2Library open_browser method if the browser is not Chrome.

For Chrome, recognizes if we are inside docker container and sets chrome capabilities accordingly.

Browser options can also be given in the robot command, for example: robot -v browser_options:”–kiosk, –disable-gpu” testytest.robot

Examples
OpenBrowser    http://google.com     chrome
#Use Chromium instead of Chrome:
OpenBrowser    http://google.com     chrome    chrome_path=/path/to/chromium/chrome.exe
OpenBrowser    http://google.com     chrome    executable_path=/path/to/my/chromedriver.exe
OpenBrowser    file://resources/window.html    firefox
OpenBrowser    http://google.com     chrome    --allow-running-insecure-content, --xyz
OpenBrowser    http://google.com     chrome    prefs="opt1":"True", "opt2":"False"
OpenBrowser    http://google.com     firefox   -headless, -private, -xyz
OpenBrowser    http://google.com     firefox   prefs="option1":"value1", "option2":"value2"
OpenBrowser    http://google.com     firefox   -profile /path/to/profile
OpenBrowser    http://google.com     firefox   -private    prefs="option1":"value1"
#Supply preferences from a dictionary
${prefs_d}=    Create Dictionary     option1    value1    option2    value2
OpenBrowser    http://google.com     firefox    prefs=${prefs_d}

To re-use existing Chrome browser session, you need to set variable BROWSER_REUSE_SESSION to True. Next you need to run the first test suite normally including OpenBrowser AND excluding CloseBrowser (e.g. in Tear Down section). The first run will result to arguments file in defined output directory. The file name is by default browser_session.arg.

For the next runs, which re-use the existing browser session, you need to specify the argument file in robot command-line using –argumentfile parameter. Additionally, test suites (or debugger) has to run OpenBrowser normally. QWeb will automatically override normal parameters and use argument file’s values instead, thus re-using the existing browser.

In the first test suite open Chrome browser normally without closing it at the tear down:

Set Global Variable   ${BROWSER_REUSE_ENABLED}   True
OpenBrowser           http://google.com    chrome

By running above, an argument file browser_session.arg is created to the output directory or current working directory. To re-use the existing browser session, use following command line examples:

robot --argumentfile <path>/browser_session.arg ... example.robot
rfdebug --argumentfile <path>/browser_session.arg

Parameters

* url ( str) – URL of the website that will be opened.

* browser_alias ( str) – Browser name. For example chrome, firefox or ie.

* options – Arguments for initialization of WebDriver objects(chrome). Some available opts: https://peter.sh/experiments/chromium-command-line-switches/

* kwargs – prefs=args: Experimental options for chrome browser.

raises ValueError

Unkonown browser type