Browser needs to be opened with
keyword for QWeb/Selenium to be able to control it. OpenBrowser takes url and browser name as arguments. Optionally browser options and preferences can be given as well.OpenBrowser
*** Settings ***
Library QWeb
*** Test Cases ***
Open Browser demo
OpenBrowser https://www.google.com chrome
OpenBrowser file://resources/window.html firefox
OpenBrowser https://www.google.com chrome chrome_path=/path/to/chromium/chrome.exe
Open Browser about:blank chrome --lang\=it prefs=download.prompt_for_download: False, plugins.always_open_pdf_externally: True
|
QWeb and SeleniumLibrary have their own browser registries, so you can’t use QWeb keywords and SeleniumLibrary keywords to control same browser session. |
GoTo url
Navigates to given url with already opened browser window
*** Settings ***
Library QWeb
*** Test Cases ***
GoTo demo
Open Browser about:blank chrome
GoTo http://google.com
GoTo file://resources/window.html
You can open, interact and close browser tabs using OpenWindow, SwitchWindow and CloseWindow respectively. If you have not specifically opened a new tab with OpenWindow, you need to use SwitchWindow to switch focus to correct window.
*** Settings ***
Library QWeb
*** Test Cases ***
Tabs demo
Open Browser about:blank chrome
OpenWindow
# No need to use SwitchWindow as you specifically opened a new window
GoTo https://www.google.com
# simulate an action/javascript opening a new window
ExecuteJavascript window.open()
# focus is still on window 2
GoTo https://qentinelqi.github.io/shop/
# switches focus to latest opened tab
SwitchWindow NEW
GoTo https://qentinelqi.github.io/shop/
CloseWindow
Browser can be closed with CloseBrowser (current active instance) or CloseAllBrowsers (all instances opened by QWeb)
-
Open Chrome and navigate to https://www.google.com
-
Open new tab/window. Navigate to https://qentinelqi.github.io/shop/
-
Change browser window size to
-
Set focus to first window (Google) and navigate to https://qentinelqi.github.io/shop/
-
Close all browser windows
Exercise example solution can be found the repo. Please try to implement your own solution first before looking at the provided solution.
Run this solution from repo root by:
robot ./01/01_solution.robot