Skip to content

Instantly share code, notes, and snippets.

@Tset-Noitamotua
Last active May 31, 2021 11:06
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Tset-Noitamotua/ab94b2e1b7ce3642f21429a3f4d89bb7 to your computer and use it in GitHub Desktop.
Save Tset-Noitamotua/ab94b2e1b7ce3642f21429a3f4d89bb7 to your computer and use it in GitHub Desktop.
Robot Framework Selenium2Library - "Create Webdriver" Keyword Examples
# Author: Greg Meece (glmeece) on robotframework.slack.com
# start Google Chrome browser with "ChromeOptions"
# Assuming both `${URL}` and `${BROWSER}` are defined as Global or Suite variables
# depends on "Open Browser to Page" below
Open Chrome Browser to Page
[Documentation] Opens _Google Chrome_ to a given web page.
... For more information on what capabilities that _Google Chrome_
... supports, see [https://sites.google.com/a/chromium.org/chromedriver/capabilities%7Cthis Capabilities & ChromeOptions page].
[Arguments] ${URL}
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${chrome_options} add_argument test-type
Call Method ${chrome_options} add_argument --disable-extensions
Run Keyword If os.sep == '/' Create Webdriver Chrome my_alias chrome_options=${chrome_options} executable_path=/usr/lib/chromium-browser/chromedriver
... ELSE Create Webdriver Chrome my_alias chrome_options=${chrome_options}
# Maximize Browser Window # doesn't work under XVFB
Set Window Size 1200 1000
Go To ${URL}
Open Browser to Page
[Documentation] Opens one of:
... - Google Chrome
... - Mozilla Firefox
... - Microsoft Internet Explorer
... to a given web page.
[Arguments] ${URL}
Run Keyword If '${BROWSER}' == 'Chrome' Open Chrome Browser to Page ${URL}
... ELSE IF '${BROWSER}' == 'Firefox' Open Firefox Browser to Page ${URL}
... ELSE IF '${BROWSER}' == 'IE' Open Internet Explorer to Page ${URL}
Set Selenium Speed ${DELAY}
# Author: Hélio Guilherme (helioguilhlerme66) on robotframework.slack.com
# start Google Chrome browser with specified user profile
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${options.add_argument}= Set Variable --user-data-dir=C:\\Users\\<username>\\AppData\\Local\\Google\\Chrome\\User Data\\Default
Create WebDriver Chrome chrome_options=${options}
@Tset-Noitamotua
Copy link
Author

Tset-Noitamotua commented Oct 19, 2016

Collection of examples for Create Webdriver Keyword from Robot Framework's Selenium2Library:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment