Skip to content

Instantly share code, notes, and snippets.

@hollychen503
Forked from nottyo/chrome-headless.robot
Created July 4, 2018 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hollychen503/ab3a34e9724c09f62497c499dadf731c to your computer and use it in GitHub Desktop.
Save hollychen503/ab3a34e9724c09f62497c499dadf731c to your computer and use it in GitHub Desktop.
Selenium2Library with Chrome Headless Mode
*** Settings ***
Library Selenium2Library
*** Variables ***
${url} https://medium.com/@nottyo/
@{chrome_arguments} --disable-infobars --headless --disable-gpu
${page_text} Test Automation Engineer. Let’s make awesome tests
${timeout} 10s
*** Test Cases ***
TC_EXP_00001
[Documentation] Sample Test For Chrome Headless
[Tags] chrome headless
${chrome_options}= Set Chrome Options
Create Webdriver Chrome chrome_options=${chrome_options}
Go To ${url}
Wait Until Page Contains ${page_text} ${timeout}
Capture Page Screenshot
[Teardown] Close Browser
*** Keywords ***
Set Chrome Options
[Documentation] Set Chrome options for headless mode
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
: FOR ${option} IN @{chrome_arguments}
\ Call Method ${options} add_argument ${option}
[Return] ${options}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment