How to run headless REMOTE chrome using robot framework

Dan W picture Dan W · Oct 18, 2017 · Viewed 25.5k times · Source

I'm trying to run chrome headless with my robot framework tests suites. I managed to do it independtly with python using selenium as follows:

options = webdriver.ChromeOptions()
options.add_argument('--headless')
my_driver = webdriver.Remote(command_executer=my_remote_address, desired_capabilities=options.to_capabilities)

The following code is what I did in robot but didn't work:

${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
${options.add_argument}=  Set Variable  add_argument=--headless
Create WebDriver  Chrome  chrome_options=${options}

Open Browser   http://www.google.com   chrome

Answer

Joao Coelho picture Joao Coelho · Jul 12, 2018

In newer versions of SeleniumLibrary (3.1.0) and Selenium (3.8.0) you can simply set the browser to headlesschrome instead of chrome.

There's also headlessfirefox available.

Ex.

Open Browser      http://www.yoursite.com    headlesschrome

http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Open%20Browser