Search code examples
javaseleniumfirefoxselenium-webdrivergeckodriver

Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start after geckodriver upgradation


I have written the below code in java to just open the firefox and redirect to gmail.com link, but seems its getting timed out before redirection. I have checked for the solution in stackoverflow and found the same problem faced by some one else. He/she has upgraded the geckodriver which was backdated and after that it successfully redirected to the link for him/her. After seeing that I have checked the versions of geckodriver, firefox and selenium and seems everything is updated. The version of the geckodriver is v0.20.1, firefox version is 60.0.2 and selenium is 3.12.0. The code I have written is:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\MI SERVICE\\Downloads\\geckodriver.exe");
FirefoxOptions capa = new FirefoxOptions();
capa.setCapability("marionette", false);
WebDriver driver = new FirefoxDriver(capa);
driver.navigate().to("https://www.gmail.com");
driver.quit();

The exception caused:

Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-3P379LK', ip: '192.168.0.105', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.1'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:132)
    at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:117)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at firefoxScripts.MyFirstTestCase.main(MyFirstTestCase.java:17)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:36845/hub/status] to be available after 45002 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:130)
    ... 7 more
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:148)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 8 more

Solution

  • As you are working with Selenium v3.12.0, GeckoDriver is v0.20.1 and Firefox v60.0.2 you have to mandatorily use marionette which is the default configuration. As you have forcefully set marionette to false so you see the error as:

    org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
    

    Solution:

    There are 2 ways to address your issue as follows:

    • Either use the default configuration (marionette set as true) as follows:

      System.setProperty("webdriver.gecko.driver", "C:\Users\MI SERVICE\Downloads\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      driver.navigate().to("https://www.gmail.com");
      driver.quit();
      
    • Or you can explicitly set marionette to true as follows:

      System.setProperty("webdriver.gecko.driver", "C:\Users\MI SERVICE\Downloads\geckodriver.exe");
      FirefoxOptions capa = new FirefoxOptions();
      capa.setCapability("marionette", true);
      WebDriver driver = new FirefoxDriver(capa);
      driver.navigate().to("https://www.gmail.com");
      driver.quit();