java 等待 45 秒让 Firefox 启动超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47504392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Timed out waiting 45 seconds for Firefox to start
提问by Dhinakaran
I am using ubuntu 16.04
我正在使用 ubuntu 16.04
Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:31.527Z'
System info: host: 'supranimbus-Inspiron-3250', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.10.0-40-generic', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:131)
at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:116)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
at facedoxmain.FaceDox.InvokeBrowser(FaceDox.java:17)
at facedoxmain.FaceDox.main(FaceDox.java:57)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:20033/hub/status] to be available after 45005 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:129)
回答by bjones01001101
I faced this issue and finally found the answer. I had been referencing the Marionette driver which is no longer correct for FF version 53 and up on Selenium 3.5 or higher. The GeckoDriver documentationdisplays how the system property should be referenced.
我遇到了这个问题,终于找到了答案。我一直在引用 Marionette 驱动程序,它不再适用于 FF 53 版及更高版本的 Selenium 3.5 或更高版本。该GeckoDriver文档显示系统属性应该如何引用。
I changed my code from:
我改变了我的代码:
System.setProperty("webdriver.firefox.marionette", System.getProperty("user.dir") + "path");
to:
到:
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "path");
and now my local Firefox works perfectly.
现在我本地的 Firefox 运行良好。
Hope this helps others.
希望这对其他人有帮助。
回答by Rose8525
I haved this error for 2 days in WIndows, the solution for me was in Set.Plataform put Plataform.ANY or Plataform.Windows because Plataform.WIN10 not worked, marionette wasn't necessary and I added and neether works, only works this. I hope this helps someone else:
我在 WINdows 中遇到了这个错误 2 天,我的解决方案是在 Set.Plataform 中放置 Plataform.ANY 或 Plataform.Windows,因为 Plataform.WIN10 不起作用,木偶不是必需的,我添加了 neether 工作,仅适用于此。我希望这对其他人有帮助:
public class Main {
public static RemoteWebDriver driver;
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.gecko.driver", "D:/Lib/geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities().firefox();
desiredCapabilities.setPlatform(Platform.ANY);
desiredCapabilities.setBrowserName("firefox");
driver = new RemoteWebDriver(new URL("http://172.20.19.182:5557/wd/hub"), desiredCapabilities);
driver.navigate().to("http://www.google.com");
driver.findElementByName("q").sendKeys("execute automation");
driver.findElementByName("q").sendKeys(Keys.ENTER);
driver.close();
// write your code here
}
}
回答by rijin john
use implicit wait before get method, it will wait for the page to load eg:
在 get 方法之前使用隐式等待,它将等待页面加载,例如:
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);