0

I have Selenium v3.12.0, Mozilla Firefox v48 I am unable to open mozilla firefox from eclipse while running a testcase in selenium. The code I have written is:

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class MyFirstTestCase {

    public static void main(String[] args) {

        System.setProperty("webdriver.gecko.driver", "C:\\Users\\MI SERVICE\\Downloads\\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();

        driver.get("http://learn-automation.com");

        driver.quit();

    }

}

The exception I am getting is:

1528719496592   geckodriver INFO    geckodriver 0.20.1
1528719496605   geckodriver INFO    Listening on 127.0.0.1:18883
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-3P379LK', ip: '192.168.0.103', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.1'
Driver info: driver.version: FirefoxDriver

remote stacktrace: 
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    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 org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
    at firefoxScripts.MyFirstTestCase.main(MyFirstTestCase.java:12)

Where is the mismatch? Please help.

  • @DebanjanB I have gone through the solution and applied in my code but still its giving the same exception. May be the version mentioned in the older one is not matching with my version of mozilla firefox and selenium. The version of mozilla firefox in my system in 48 and selenium version is 3.12.0. – Gaurav Singh Jun 11 '18 at 13:01
  • The clue is as you are on `3.12.0`, _GeckoDriver v0.20.1_ and `Firefox < v48.x`, you have to pass the capability `dc.setCapability("marionatte", false);`. – undetected Selenium Jun 11 '18 at 13:10
  • Now I have changed the code to: import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; public class MyFirstTestCase { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\Users\\MI SERVICE\\Downloads\\geckodriver.exe"); FirefoxOptions capa = new FirefoxOptions(); capa.setCapability("marionette", false); WebDriver driver = new FirefoxDriver(); driver.navigate().to("https://gmail.com"); driver.quit(); } } but the same exception – Gaurav Singh Jun 11 '18 at 13:33
  • You did it pretty correct `FirefoxOptions capa = new FirefoxOptions(); capa.setCapability("marionette", false);`. Now you just need to pass `capa` within `WebDriver driver = new FirefoxDriver(capa);` – undetected Selenium Jun 11 '18 at 13:39
  • It worked. Thanks a lot. – Gaurav Singh Jun 12 '18 at 06:17
  • Upvote any answer which was useful to you – undetected Selenium Jun 12 '18 at 06:23
  • It successfully opened Firefox but its not redirecting to the link given. I have seen the same problem faced by others but solved after updating the geckodriver. For me its the latest one v 0.20.1. But still facing the same. The exception details: 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' – Gaurav Singh Jun 12 '18 at 06:46

0 Answers0