Last active
January 3, 2020 20:28
-
-
Save up1/0d299f6aebfd3bdcf7e863bcc98c0be7 to your computer and use it in GitHub Desktop.
Robotframework + Google Chrome headless
This file contains hidden or 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
ChromeOptions chromeOptions = new ChromeOptions(); | |
chromeOptions.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"); | |
chromeOptions.addArguments("--headless"); | |
WebDriver Driver = new ChromeDriver(chromeOptions); |
This file contains hidden or 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 Collections | |
Library Selenium2Library | |
*** Test Cases *** | |
Hello chrome headless | |
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver | |
${options.set_binary}= Set Variable set_binary=/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary | |
${options.add_argument}= Set Variable add_argument=--headless | |
Create WebDriver Chrome chrome_options=${options} | |
Open Browser http://www.google.com chrome | |
Wait Until Page Contains ffgdfgdfgdfgdfg | |
Close Browser |
I found that the robot example won't work for me. I would replace the add_argument
part with the following:
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome_options} add_argument headless
For robotframework I found better solution - https://github.com/drobota/robotframework-xvfb
Exactly Below code worked for me, for headless chrome
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Test title
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${options} add_argument --headless
#my_create_webdriver Chrome ${options}
create webdriver Chrome chrome_options=${options}
Maximize Browser Window
go to https://google.com
Maximize Browser Window
capture page screenshot
close browser
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the update headless chrome beta version 60 does not seem to work with websites which have self signed SSL Certificates.
Please update if Chrome Canary version works with url having SSL error.