I'm trying to set up an automatic web test environment using Ranorex and Selenium Web Driver. As the test will be integrated in Jenkings and run on a machine without graphical interface. I'm trying to set up an endpoint with headless browsers.
I start the selenium-standalone server and gekoDriver with the script:
java -jar -Dwebdriver.gecko.driver="C:\Utility\BrowserDrivers\geckodriver.exe"
selenium-server-standalone-3.12.0.jar
How do you I manage to set up the Geko and Google Driver in headless mode?
Many thanks in advance.
Not sure about Ranorex
but in Selenium, for Firefox, you just need to set the set_headless
options to a boolean true or false to run the browser in headless mode.
For Python, it's like this
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.set_headless(headless=True)
driver = webdriver.Firefox(firefox_options=options, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get("http://google.com/")
print ("Headless Firefox Initialized")
driver.quit()
Code and documentation and explanation is given in this post. Credits to the user Debanjan for this.