0

我已经在无头模式下成功使用了非壁虎版本的 Firefox 驱动程序,但自从我开始使用 Selenium 3.0 后它就停止了工作。我所做的 -

  • 启动 xvfb
  • 设置webdriver.gecko.driver到壁虎驱动程序的路径
  • 设置 Firefox 二进制显示

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/"); 

但这会在可见屏幕上启动浏览器,而不是在无头模式下启动。我还需要做什么才能在 xvfb 上启动 Firefox?

4

1 回答 1

0

检查 xPort 显示值是否设置为 :10 而不是 :1

如果不是,请尝试将其设置为:10并重新检查:

 firefoxBinary.setEnvironmentProperty("DISPLAY", ":10"); 
于 2016-12-28T02:09:30.973 回答