Created
May 12, 2017 09:31
-
-
Save nottyo/e48e6c352d74e7eef677e1d7c5c2188e to your computer and use it in GitHub Desktop.
Selenium2Library with Chrome Headless Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** 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
Nice! I think your approach to having all the Chrome Options in a list makes a lot of sense. I have my line-by-line, which makes it easier to toggle arguments, but I may adopt your approach instead. Here's my take I've used for awhile.