Search code examples
javaseleniumfirefoxselenium-webdrivergeckodriver

Firefox is not launched using Geckodriver and Selenium - It works with Chrome


I've started using the Geckodriver today with no success.

The same scripts work using chrome (chrome launches correctly) but the Firefox browser is not being launched and TestNG fails the scripts before launching the browser.

The code is as simple as this:

       case "IE":
            System.setProperty("webdriver.ie.driver", ECC.IE_DRIVER_PATH);
            localWebDriver = new InternetExplorerDriver();
            break;
       case "FIREFOX":
            System.setProperty("webdriver.gecko.driver", ECC.FIREFOX_DRIVER_PATH);
            localWebDriver = new FirefoxDriver();
            break;
        case "CHROME":
            System.setProperty("webdriver.chrome.driver", ECC.CHROME_DRIVER_PATH);
            localWebDriver = new ChromeDriver();
            break;
        }

When performing the localWebDriver = new FirefoxDriver();, it does not launches the browser, and it automatically goes to the invoker.class to the following code:

 catch(InvocationTargetException ite) {
   testResult.setThrowable(ite.getCause());
   setTestStatus(testResult, ITestResult.FAILURE);
 }

The console only shows this:

1491601901866 geckodriver INFO Listening on 127.0.0.1:27826

I'm using:

  • FF version 48
  • Geckodriver 15.0
  • Selenium 3.3.1

I've also tried with the most updated version of FF without success.

This does not happens with chrome.

Can you please help me?

Thanks in advance!!


Solution

  • I wanted to thank you for your responses. My problem was that I had a maven dependency which was causing problems I believe with the versions of what I was using. The dependency was:

    <!--        <dependency> -->
    <!--            <groupId>org.seleniumhq.selenium</groupId> -->
    <!--            <artifactId>selenium-remote-driver</artifactId> -->
    <!--            <version>2.51.0</version> -->
    <!--        </dependency> -->
    

    By commenting these 2, the problem was solved.