Protractor 在 Chrome 上运行良好,但我无法启动 Firefox 或 Internet Explorer。
- Windows 7的
- 节点 v6.9.1
片段来自package.json
:
"scripts": {
....
"webdriver-manager-update": "webdriver-manager update --ie",
"protractor": "protractor protractor.conf.js",
...
},
...
"devDependencies": {
...
"protractor": "5.1.1",
...
}
protractor.conf.js
:
exports.config = {
capabilities: {
browserName: "firefox" // or "internet explorer"
},
specs: ["target/e2e/**/*.e2e-spec.js"]
};
运行后,npm run webdriver-manager-update
包含<project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\
文件chromedriver_2.28.exe
和.geckodriver-v0.15.0.exe
IEDriverServer3.3.0.exe
运行时npm run protractor
,出现错误:
[12:29:45] I/launcher - Running 1 instances of WebDriver
[12:29:45] I/local - Starting selenium standalone server...
[12:29:46] I/local - Selenium standalone server started at http://192.168.213.25:62661/wd/hub
[12:29:46] E/launcher - The path to the driver executable must be set by the webdriver.gecko.driver system property
(对于IE来说,它是指webdriver.ie.driver
系统属性)
经过大量谷歌搜索,我尝试了以下修复:
a) 添加<project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\
到系统环境变量Path
。这似乎没有什么区别。
b) 将以下行添加到protractor.conf.js
:
seleniumArgs: ["-Dwebdriver.gecko.driver=<project-home>\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.15.0.exe"],
现在npm run protractor
产生:
[12:40:35] I/launcher - Running 1 instances of WebDriver
[12:40:35] I/local - Starting selenium standalone server...
[12:40:35] E/launcher - Error: Error: Server terminated early with status 1
at Error (native)
at earlyTermination.catch.e (<project-home>\node_modules\selenium-webdriver\remote\index.js:252:52)
at process._tickCallback (internal/process/next_tick.js:103:7)
[12:40:35] E/launcher - Process exited with error code 100
(与 IE 类似的行为)
我的搜索结果表明我不是唯一遇到此问题的人,但不幸的是,我没有找到解决方案。