我有像这样的package.json文件
{
"name": "E2E",
"version": "1.0.0",
"description": "AngularJS E2E testing",
"main": "conf.js",
"scripts": {
"postinstall": "node_modules/protractor/bin/webdriver-manager update",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"devDependencies": {
"protractor": "^2.2.0"
}
}
在安装量角器后运行命令npm install
时抛出错误
node_modules/protractor/bin/webdriver-manager update
'node_modules' is not recognized as an internal or external command, operable program or batch file
答案 0 :(得分:9)
好的找到了修复,我需要像这样
运行它作为节点命令"postinstall": "node node_modules/protractor/bin/webdriver-manager update",
答案 1 :(得分:1)
尝试使用点后跟斜杠前缀可执行文件的路径:
./node_modules/protractor/bin/webdriver-manager update
答案 2 :(得分:0)
如果webdriver是全局安装的,那么我猜不需要提供文件路径。如果它安装在某个文件夹中,那么您可能应该提供该文件夹的完整路径。可能这会对你有所帮助 -
"postinstall": "webdriver-manager update",
This post might of help。希望这会有所帮助。
答案 3 :(得分:0)
问题是您需要在调用它之前安装该命令的文件夹。假设您使用的是Windows,可以通过运行一个简单的批处理文件来解决这个问题:
@echo off
call npm install -g protractor
call npm install
cd C:/Users/%USERNAME%/AppData/Roaming/npm/node_modules/protractor/selenium/
call webdriver-manage update
您应该可以从任何地方运行批处理文件。事实上,整个量角器测试过程可以使用批处理文件自动完成。你只需要在你的package.json中添加Grunt,load-grunt-tasks,grunt-protractor-runner,jasime和protractor-jasmine2-html-reporter:
{
"name": "yourproject",
"version": "0.0.1",
"dependencies": { },
"devDependencies": {
"grunt": "~0.4.1",
"load-grunt-tasks": "~1.0.0",
"grunt-protractor-runner": "~2.1.0",
"jasmine": "~2.3",
"protractor-jasmine2-html-reporter": "~0.0.5"
},
"engines": {
"node": ">=0.12.0"
}
}
配置Protractor并编写一些测试后,您可以使用一个简单的批处理文件调用整个过程:
@echo off
cd %CD%
@echo running tests
call grunt
@echo Opening test results in browser
start "" %CD%\tests\reports\index.html