admin管理员组文章数量:1304067
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:
.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?
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:
.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?
Share Improve this question asked Feb 10 at 12:22 MikachuMikachu 1453 silver badges16 bronze badges3 Answers
Reset to default 1If 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
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..
Edge or Chrome are based off Chromium and their capabilities are command line arguments.
You will need to pass them with double hyphen -- as seen below
本文标签: selenium webdriverStarting automated tests with Edge DriverStack Overflow
版权声明:本文标题:selenium webdriver - Starting automated tests with Edge Driver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741717107a2394178.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论