Reputation: 63
I have Windows 10 - 64, Firefox 61.0.2, Java installed. I'm executing my tests with selenium-grid and selenium-server-standalone-3.11.0.jar, and geckodriver 21.0, but when I run it, the test shows the following error:
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {acceptInsecureCerts: true, browserName: firefox, platform: WINDOWS, version: 61.0.2}
My code:
private void createBrowserInstance() throws MalformedURLException {
switch (environmentHandler.getTestBrowser().toLowerCase()) {
case "firefox":
FirefoxOptions firefox = new FirefoxOptions();
firefox.setCapability("marionette", false);
browCapab = DesiredCapabilities.firefox();
browCapab.setBrowserName("firefox");
browCapab.setPlatform(Platform.WINDOWS);
browCapab.setVersion("61.0.2");
Upvotes: 1
Views: 2644
Reputation: 193058
This error message...
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {acceptInsecureCerts: true, browserName: firefox, platform: WINDOWS, version: 61.0.2}
...implies that the GeckoDriver was unable to forward the new session.
Your main issue is the incompatibility in the configuration you are using as follows:
selenium-server-standalone-3.11.0.jar
geckodriver 21.0
So you have to use the capability marionette mandatorily. To achieve that either:
marionette
is set to True.You can also specify the capability marionette as follows:
FirefoxOptions firefox_options = new FirefoxOptions();
firefox_options.setCapability("marionette", true);
firefox is a keyword/reserved word, so do not use this term in your tests.
browserName
: If value is not a string equal to the "browserName" entry in matched capabilities, return success with data null.browserVersion
: Compare value to the "browserVersion" entry in matched capabilities using an implementation-defined comparison algorithm. The comparison is to accept a value that places constraints on the version using the "<", "<=", ">", and ">=" operators. If the two values do not match, return success with data null.platformName
: If value is not a string equal to the "platformName" entry in matched capabilities, return success with data null.Upvotes: 1
Reputation: 14736
Error forwarding the new session cannot find
is the Grid's way of telling you that, it couldn't find a node that matched your requested capability.
The grid uses the following 4 attributes for capability matching [ Match a requested capability from your test case, with the actual capability that a node has to offer ]
You haven't mentioned how you are starting your node. In specific, you haven't mentioned if you are using a node configuration JSON file or not (this configuration file is typically used to tweak the node's supported capabilities amongst other things). But I am assuming that you aren't using one.
When you start a node without any additional customization, then it doesn't know of the version
capability.
So it would perhaps have a node that can support firefox
on windows
. But your test is looking for firefox version 61.0.2
running on windows
. That explains the error.
To fix the problem, you can do one of the following:
Remove the line browCapab.setVersion("61.0.2");
from your test code (or)
Use the version information in the node configuration file, when starting the node.
To learn how to work with a node configuration file, you could refer to my blog post here
Upvotes: 3