Selenium 3.0.1 and Firefox 50.0 in headless mode launches browser on visible screen

565 views Asked by At

I have successfully used non gecko version of Firefox driver in headless mode but it has stopped working since I started using Selenium 3.0. What I do -

  • Start xvfb
  • Set webdriver.gecko.driver to path to gecko driver
  • Set Firefox binary display

System.setProperty("webdriver.gecko.driver", "path to geckodriver");                    
String Xport = System.getProperty("lmportal.xvfb.id", ":1"); final 
FirefoxBinary firefoxBinary = new FirefoxBinary(); 
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport); 
WebDriver driver = new FirefoxDriver(firefoxBinary, null); 
driver.get("https://www.google.com/"); 

But this launches the browser on visible screen and not on headless mode. What else do I need to to do to launch Firefox on xvfb?

1

There are 1 answers

1
Marius D. On

Check if the xPort display value is set to :10 instead of :1

If it's not, just try setting it to :10 and recheck:

 firefoxBinary.setEnvironmentProperty("DISPLAY", ":10");