Mikachu
Mikachu

Reputation: 145

Starting automated tests with Edge Driver

I already got the tests running with chrome, but now we need to test also with MS Edge. I have downloaded the correct Edge WebDriver (version-vise) and got it up and running with the selenium standalone server.

Now, I set up the driver but something is not right. I used the same logic as with the chrome driver:

EdgeOptions eOptions = new EdgeOptions();
eOptions.setCapability("javascriptEnabled", true);
eOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
eOptions.setCapability("takesScreenshot", true);
eOptions.setCapability("browserName", DriverClass.getBrowser());
eOptions.setCapability("e34:l_testName", testSetName);
eOptions.setCapability("e34:video", true);
eOptions.setCapability("build", "Build-" + buildnr);
eOptions.setCapability("acceptSslCerts", true);

After the cababilities are set, I load them into the driver:

String preferredDriver = getBrowser();
    MutableCapabilities options;
    switch (preferredDriver.toLowerCase()) {
        case "chrome":
            options = new ChromeOptions();
            options.setCapability(ChromeOptions.CAPABILITY, options);
            setDriverOptions(options, testSetName, buildnr);
            break;
        case "edge":
            options = new EdgeOptions();
            options.setCapability("ms:edgeOptions", options);
            setDriverOptions(options, testSetName, buildnr);
            break;
    }

    try {
        driver = new RemoteWebDriver(new URL(seleniumBoxUrl  + "/wd/hub"), eOptions);
        //LOG.debug(driver.toString());
    } catch (MalformedURLException ex) {
        //LOG.error(ex.getMessage());
        System.exit(0);
    }

The program fails at the RemoteWebDriver initialization. The error I get looks something like this:

org.openqa.selenium.SessionNotCreatedException: Unable to create session from {
"desiredCapabilities": {
 "e34:l_testName": "Some Test 1",
 "acceptSslCerts": true,
 "build": "Build-1739188765063",
 "browserName": "edge",
 "takesScreenshot": true,
 "unhandledPromptBehavior": "ignore",
 "javascriptEnabled": true,
 "e34:video": true,
 "unexpectedAlertBehaviour": "ignore"
},
 "capabilities": {
 "firstMatch": [
  {
    "browserName": "edge",
    "e34:l_testName": "Some Test 1",
    "e34:video": true,
    "unhandledPromptBehavior": "ignore"
  }
]
}
}

Any ideas what it could be?

Upvotes: 0

Views: 58

Answers (2)

Sajith dilshan
Sajith dilshan

Reputation: 171

If you are still running into issues, try using the default EdgeOptions without adding any extra capabilities. like below:

EdgeOptions eOptions = new EdgeOptions();
driver = new RemoteWebDriver(new URL(seleniumBoxUrl  + "/wd/hub"), eOptions);

This way ensures that no conflicting or unsupported configurations are being sent to the WebDriver, which can sometimes cause problem

Upvotes: 1

Abhishek Maurya
Abhishek Maurya

Reputation: 1

You should try to match your Webdriver and edge version, because in my case whenever I get this type of issue, I solve it by matching the version, most of the time as edge driver and webdriver always shows to update the driver..

Upvotes: 0

Related Questions