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

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


* 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:

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

raises ValueError

Unknown browser type

raises Related keywords

raises —————-

raises Back, CloseAllBrowsers, CloseBrowser, GetTitle,

raises GetUrl, GoTo, RefreshPage, ReturnBrowser,

raises SwitchWindow, VerifyTitle, VerifyUrl