My versions are selenium-java-3.14.0 and geckodriver-v0.23.0-win64. I am using the following code.
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\\\\Try out files\\\\geckodriver.exe");
driver = new FirefoxDriver();
String baseURL = "http://www.google.com";
driver.get(baseURL);
When I run it, I get the following error message.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: '*******', ip: '*****`enter code here`', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new0ドル(W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction2ドル(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession0ドル(ProtocolHandshake.java:122)
at java.util.stream.ReferencePipeline3ドル1ドル.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
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:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
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 basicweb.FirefoxDriverDemo.main(FirefoxDriverDemo.java:17)
undetected Selenium
194k44 gold badges304 silver badges386 bronze badges
asked Oct 31, 2018 at 9:49
-
Try updating FF browser.Guy– Guy2018年10月31日 09:52:39 +00:00Commented Oct 31, 2018 at 9:52
2 Answers 2
Use firefox version 56 or 61 and gecko driver version 0.21. and add firefox options use profile.
FirefoxOptions fo = new FirefoxOptions();
fo.setBinary("C:\\Users\\ChawlaSh\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("default");
fo.setProfile(myprofile);
driver = new FirefoxDriver(fo);
I hope this will surely help.
Matthieu Brucher
22.1k7 gold badges43 silver badges66 bronze badges
answered Oct 31, 2018 at 10:02
-
Any reason to ask OP for downgrading GeckoDriver?undetected Selenium– undetected Selenium2018年10月31日 11:24:37 +00:00Commented Oct 31, 2018 at 11:24
-
I faced same issue month ago and if you check Mozilla release's page on GitHub they have mentioned which gecko driver is compatible with which version of selenium and Firefox for me it worked perfectly.shubham chawla– shubham chawla2018年10月31日 11:34:23 +00:00Commented Oct 31, 2018 at 11:34
This error message...
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
...implies that your program wasn't able to create a new Firefox Browser session..
Analysis
There are a couple of issues as follows:
file.separator
: Character that separates components of a file path. This is/
on UNIX and\
on Windows. You need to escape them too.- Your JDK version is 1.8.0_151 which is pretty ancient.
Solution
- Use
file.separator
as\
escaping with another\
. - Upgrade JDK to recent levels JDK 8u191.
- Ensure the GeckoDriver-Firefox Mapping
You effective code block will be:
WebDriver driver; System.setProperty("webdriver.gecko.driver", "D:\\Try out files\\geckodriver.exe"); driver = new FirefoxDriver(); String baseURL = "http://www.google.com"; driver.get(baseURL);
answered Oct 31, 2018 at 11:45
Explore related questions
See similar questions with these tags.