1

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");
David Rogers
  • 2,601
  • 4
  • 39
  • 84
ealvarado
  • 63
  • 1
  • 10
  • Why do you use browCapab.setBrowserName("firefox"); and browCapab.setPlatform(Platform.WINDOWS); if you have browCapab = DesiredCapabilities.firefox();? – unickq Sep 03 '18 at 20:45

2 Answers2

3

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 ]

  • Browser name
  • Platform
  • Version
  • Application name (This AFAIK is not documented, but it does exist. See here )

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

Community
  • 1
  • 1
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • Thank you very much for your reply, I deleted the version now it shows another error,org.openqa.selenium.remote.DesiredCapabilities firefox INFORMACIÓN: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()` 08:35:54.134 [main] ERROR com.verifone.basetest.MainAbstractTest - Maybe the Server is not running on the target. This target is: http://localhost:4444/wd/hub org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities – ealvarado Sep 04 '18 at 11:39
  • start java -jar selenium-server-standalone-3.11.0.jar -role hub start java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.11.0.jar -role node -port 5555 -hub http://localhost:4444/grid/register -browser "browserName=chrome,platform=WINDOWS" start java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.11.0.jar -role node -port 5556 -hub http://localhost:4444/grid/register -browser "browserName=firefox,platform=WINDOWS",maxInstances=3,maxSession=1 – ealvarado Sep 04 '18 at 11:44
1

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:

  • As per your question as you are using:
    • selenium-server-standalone-3.11.0.jar
    • geckodriver 21.0
  • So you have to use the capability marionette mandatorily. To achieve that either:

    • You can leave the capability marionette untouched as by default 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.

  • Rest of your code looks good.
  • As per the WebDriver W3C Editor's Draft:
    • 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.
  • You can find a relevant discussion in org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • browCapab = DesiredCapabilities.firefox(); FirefoxOptions option = new FirefoxOptions(); option.setCapability("marionette", true); browserType = BrowserType.FIREFOX; browCapab.setBrowserName("firefox"); browCapab.setPlatform(Platform.WINDOWS); – ealvarado Sep 04 '18 at 11:45
  • Is shown the error: org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities – ealvarado Sep 04 '18 at 11:46
  • Great !!! So your main issue of **WebDriverException: Error forwarding the new session cannot find : Capabilities** is addressed now. For **org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities** error see [**this**](https://stackoverflow.com/questions/44601126/unable-to-find-a-matching-set-of-capabilities-with-selenium-3-4-3-firefox-54-0/44601664#44601664) and [**this**](https://stackoverflow.com/questions/52002958/selenium-common-exceptions-sessionnotcreatedexception-message-unable-to-find-a/52006033#52006033) discussions. – undetected Selenium Sep 04 '18 at 11:53
  • I not have success, I use java. start java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.11.0.jar -role node -port 5556 -hub http://localhost:4444/grid/register -browser "browserName=firefox,platform=WINDOWS",maxInstances=3,maxSession=1 – ealvarado Sep 04 '18 at 12:24
  • @EdithAlvarado Your setup/codetrials had multiple issues which was not evident in the initial version of your question. However as per my answer your initial error of `WebDriverException: Error forwarding the new session cannot find : Capabilities` is solved now. You have updated the question after receiving effective answer(s) which is against all the best practices on stackoverflow and won't be useful to future readers. If your requirement have changed feel free to raise a new question. Stackoverflow volunteers will be happy to help you. For this time I am reverting the question to original – undetected Selenium Sep 04 '18 at 12:37