SessionNotCreatedException: Unable to find a matching set of capabilities for firefox browser



  • I'm running 2 firefox windows tests, 2 firefox mac tests, 2 chrome windows tests, and 2 chrome mac tests in parallel on both a windows node and a mac node. All tests passes except the 2 firefox mac tests. Sometimes 2 firefox mac tests will pass, but the 2 firefox windows tests would fail. Never will both 2 firefox mac tests and 2 firefox windows tests will pass at the same time. I am using the latest firefox driver, latest firefox browser version, latest selenium webdriver, and latest java 8 jdk.

     testbase file
     if(browser.contains("winfirefox"))
                {
    
                    System.setProperty("webdriver.gecko.driver", ReadProperties.globalProp.getProperty("pcgeckodriver"));
                    FirefoxOptions firefoxOptions = new FirefoxOptions();
                    firefoxOptions.setCapability("platform", "WINDOWS");
                    firefoxOptions.setCapability("browser", "firefox");
                    firefoxOptions.setCapability("newCommandTimeout", 5000);
                    firefoxOptions.setCapability(FirefoxDriver.MARIONETTE, true);
    
                    whichNodeURL=winNodeURL;    
    
                    try
                    {
                        driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), firefoxOptions));
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                    }
    
                }
        else if(browser.contains("macfirefox"))
                {
                    System.setProperty("webdriver.gecko.driver", ReadProperties.globalProp.getProperty("macgeckodriver"));
                    FirefoxOptions macfirefoxOptions = new FirefoxOptions();
                    macfirefoxOptions.setCapability("platform", "MAC");
                    macfirefoxOptions.setCapability("browser", "firefox");
                    macfirefoxOptions.setCapability("newCommandTimeout", 5000);
                    macfirefoxOptions.setCapability(FirefoxDriver.MARIONETTE, true);
    
                    whichNodeURL=macNodeURL;
    
                    try
                    {
                        driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), macfirefoxOptions));
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                    }
    
                }
    
                    String weburl = ReadProperties.globalProp.getProperty("weburl");
                    this.driverThread.get().get(weburl);
                    this.driverThread.get().manage().window().maximize(); 
    
    
        mac node json file
         {
                         "capabilities":
                           [
                    {
                           "browserName": "firefox",
                           "marionette": true,
                           "maxInstances": 2,
                          "browser-version": "66.0.3",
                          "platform": "MAC",
                         "seleniumProtocol": "WebDriver"
                    },
                   {
                         "browserName": "chrome",
                         "maxInstances": 2,
                        "browser-version": "73.0.3683",
                        "platform": "MAC",
                        "seleniumProtocol": "WebDriver"
                   },
                   {
                         "browserName": "safari",
                          "technologyPreview": false,
                          "platform": "MAC",
                          "maxInstances": 1,
                         "seleniumProtocol": "WebDriver"
                        }
                     ],
                  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
                  "maxSession": 2,
                  "port": 5555,
                  "register": true,
                  "registerCycle": 5000,
                  "hub": "http://xxxxxxx:4444",
                 "nodeStatusCheckTimeout": 5000,
                 "nodePolling": 5000,
                 "role": "node",
                 "cleanUpCycle": 5000,
                 "timeout": 5000,
                 "unregisterIfStillDownAfter": 60000,
                "downPollingLimit": 2,
                "debug": false,
                "servlets" : [],
               "withoutServlets": [],
               "custom": {}
                }
    
    TESTNG FILE
    <suite name="XOME Suite" parallel="tests" verbose="1" thread-count="2">
    
    <test name = "Mac Firefox Tests" preserve-order="true" group-by-instances="true">
    <parameter name="browser" value="macfirefox">
        <classes>
            <class name="webTests.FilterMoreResultsByKeyword" />
            <class name="webTests.FilterMoreResultsByYear" />
        </classes>
    </parameter>
    </test>
    
    
    
    <test name = "Win Firefox Tests" preserve-order="true" group-by-instances="true">
    <parameter name="browser" value="winfirefox">
        <classes>
            <class name="webTests.FilterMoreResultsByKeyword" />
            <class name="webTests.FilterMoreResultsByYear" />
        </classes>
    </parameter>
    </test>
    


  • By adding the binary path of Firefox browser and also adding the path of all the browser drivers to the path variable in environment variables in windows this error is no longer seen. On mac add browser driver path with these instructions. Easiest way is to create one folder to store all browser drivers and provide that single path. 1. Open up Terminal 2. Run sudo nano /etc/paths 3. Enter your password 4. Go to the bottom of the file and enter the path you wish to add 5. My PATH looks like: /Users/name/Documents/WebDriver 6. Control-x to quit 7. Y to save 8. Press enter to confirm

    Closing issue. firefoxOptions.setBinary("C:\Program Files\Mozilla Firefox\firefox.exe"); macfirefoxOptions.setBinary("/Applications/Firefox.app/Contents/MacOS/firefox-bin");



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2