我可以让量角器使用node_modules中安装的IEDriverServer.exe webdriver-update吗?

时间:2016-02-29 20:44:55

标签: angularjs node.js internet-explorer selenium-webdriver protractor

我正在为我的角度Web应用程序项目编写验收测试。他们通过量角器运行,并且在chrome上工作得很好。但是当我尝试在Internet Explorer 11上运行它们时,我得到了一个失败,抱怨说"驱动程序可执行文件的路径必须由webdriver.ie.driver系统设置"设置。但是,我将我的项目配置为将IE驱动程序下载到与chromedriver可执行文件相同的位置。

虽然我确定可以将IE驱动程序移动到存储在我的PATH env变量中的文件夹,但项目中的每个开发人员都必须执行相同操作或更新其PATH以指向驱动程序。

我的问题是 - 是否有一个简单的配置我想让这个IE驱动程序可用于量角器,就像Chrome驱动程序一样?

我的package.json:

{
//...
"scripts": {
    "webdriver-update": "webdriver-manager update --ie",
    "preacceptance-tests": "npm run webdriver:update -- --standalone",
    "acceptance-tests": "protractor",
    //...
}

我的protractor.conf.js:

exports.config = {
    baseUrl: 'http://localhost:3000/',
    specs: [
        'src/**/**test.ts',
        'src/**/*test.ts'
    ],
    capabilities: {
        'browserName': 'internet explorer' //If I put chrome here, the tests pass
    },
    onPrepare: function() {
        browser.ignoreSynchronization = true;
    },
    seleniumServerJar: "node_modules/protractor/selenium/selenium-server-standalone-2.51.0.jar",
    useAllAngular2AppRoots: true
};

我运行" npm运行验收测试",并将chromedriver.exe和IEDriverServer.exe下载到我的node_modules / protractor / selenium文件夹。量角器似乎意识到了chromedriver,但为什么它不能看到IEDriverServer呢?

除了手动将PATH指向此文件夹外,我似乎无法在任何地方找到答案。如果量角器能够找到chromedriver似乎我不应该......

1 个答案:

答案 0 :(得分:1)

据我所知,通过检查Selenium来源,只有一种解决方法。

如果当前工作目录中存在名为IEDriverServer.exe的可执行文件(已明确检查,并且您可以使用process.cwd()进行查询),则将选择该实例并PATH检查绕过(错误消息有点误导)。

您可以按照Selenium来源herehere中的逻辑进行操作。