最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

selenium webdriver - Starting automated tests with Edge Driver - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a comment  | 

3 Answers 3

Reset to default 1

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

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

发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>