Skip to content

Instantly share code, notes, and snippets.

@tompurl
Forked from nottyo/chrome-headless.robot
Created February 14, 2019 18:37
Show Gist options
  • Save tompurl/903346c73b8ada17d988e1f2fb99f7f3 to your computer and use it in GitHub Desktop.
Save tompurl/903346c73b8ada17d988e1f2fb99f7f3 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} Traitanit
${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