我尝试用无头火狐运行Selenium代码。在Eclipse中我输入了这段代码:
String Xport = System.getProperty(
"lmportal.xvfb.id", ":10");
final File firefoxPath = new File(System.getProperty(
"lmportal.deploy.firefox.path", "/usr/bin/firefox/"));
FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath);
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
// Start Firefox driver
WebDriver driver = new FirefoxDriver(firefoxBinary, null);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
但到达时:
WebDriver driver = new FirefoxDriver(firefoxBinary, null);
没有前进..
我尝试使用phantomjs但非常慢......
答案 0 :(得分:0)
是肯定的。你可以通过Xvbf用无头火狐运行selenium。你可能有以下步骤:
在您的代码中,它可能就像
FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty(“DISPLAY”,1);