【问题标题】:Failure to run protractor from Node.js command prompt无法从 Node.js 命令提示符运行量角器
【发布时间】:2017-03-25 13:36:43
【问题描述】:

希望一切都好。我是第一次通过 Node.js 设置量角器。这是 AngularJS 网站上“运行 E2E 测试”下教程的一部分: https://docs.angularjs.org/tutorial

但是,在通过提供的命令“npm run protractor”执行量角器时,我在 Node.js 命令提示符中收到以下错误:

E/launcher - Process exited with error code 199

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "protractor"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat@0.0.0 protractor: `protractor e2e-tests/protractor.conf.js`
npm ERR! Exit status 199
npm ERR!
npm ERR! Failed at the angular-phonecat@0.0.0 protractor script 'protractor e2e-tests/protractor.conf.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     protractor e2e-tests/protractor.conf.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-phonecat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.

这是 package.json 文件的内容:

{
  "name": "angular-phonecat",
  "private": true,
  "version": "0.0.0",
  "description": "A tutorial application for AngularJS",
  "repository": "https://github.com/angular/angular-phonecat",
  "license": "MIT",
  "devDependencies": {
    "bower": "^1.7.7",
    "http-server": "^0.9.0",
    "jasmine-core": "^2.4.1",
    "karma": "^0.13.22",
    "karma-chrome-launcher": "^0.2.3",
    "karma-firefox-launcher": "^0.1.7",
    "karma-jasmine": "^0.3.8",
    "protractor": "^4.0.9"
  },
  "scripts": {
    "postinstall": "bower install",
    "prestart": "npm install",
    "start": "http-server ./app -a localhost -p 8000 -c-1",
    "pretest": "npm install",
    "test": "karma start karma.conf.js",
    "test-single-run": "karma start karma.conf.js --single-run",
    "preupdate-webdriver": "npm install",
    "update-webdriver": "webdriver-manager update",
    "preprotractor": "npm run update-webdriver",
    "protractor": "protractor e2e-tests/protractor.conf.js",
    "update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+'    //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
  }
}

我不知道是否有其他人尝试过同样的教程并遇到同样的问题?任何帮助将不胜感激,谢谢。

【问题讨论】:

  • 你启动 selenium 服务器了吗?
  • 你需要从你的package.json所在的文件夹运行命令npm run protractor。你也可以发布package.json 文件的内容
  • 我不确定我是否启动了 selenium 服务器 Danny,你能告诉我如何检查吗?当然是 Sudharsen,我已将 package.json 文件的内容添加到问题中。

标签: javascript angularjs node.js protractor


【解决方案1】:

所以 Protractor 可以通过多种方式启动,最常见的是 directConnectseleniumAddress。由于e2e-tests/protractor.config.js 文件中未设置任何值,因此假定值为directConnect。要让directConnect 使用 chrome 浏览器,您需要获取最新的 chromedriver。只需安装 chromedriver:

./node_modules/.bin/webdriver-manager update --standalone=false --gecko=false

或者按照github angular-seed page 中的建议,另外还会下载 selenium 独立 jar 文件和 gecko 驱动程序(用于 firefox):

npm update-webdriver

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多