0

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.

Pamana
  • 55
  • 1
  • 1
  • 7

3 Answers3

1

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.

demouser123
  • 4,108
  • 9
  • 50
  • 82
  • Hi. Thanks for your quick answer. I used Selenium in Java before, and I configured it similarly . My problem is that I need to configure this option in ranorex now – Pamana May 15 '18 at 12:51
0

Found the solution. I had to add an endpoint configuration in Ranorex with the capabilities in JSON: For example for Firefox:

{
"browserName": "firefox",
    "moz:firefoxOptions": {  
         "args" : ['-headless']
     }
}

The endpoint will now start the gekoDriver with 'headless' option.

Pamana
  • 55
  • 1
  • 1
  • 7
0

You have to provide the correct JSON capabilities.

For Firefox, the required JSON capabilities are:

{
    "browserName": "firefox",
    "moz:firefoxOptions": { 
        "args" : ['-headless']
    }
}

For Chrome, you have to use these capabilities:

{
    "browserName": "chrome",
    "chromeOptions": { 
        "args" : ["headless"]
    }
}

The other browser don't support headless (yet), as far as I know.