我在Windows上構建了一個AngularJS應用程序。我想用Jasmine創建端到端的測試。根據我的理解,我需要量角器來運行這些測試。出於這個原因,我已經添加了以下到我的package.json:讓我的AngularJS應用使用量角器來使用硒
"devDependencies": {
...
"grunt-protractor-runner": "0.2.4",
"selenium-webdriver":"2.41.0",
...
}
在我gruntfile.js,我已經配置量角器這樣:
grunt.initConfig({
protractor: {
options: {
configFile: "node_modules/protractor/referenceConf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
args: {
// Arguments passed to the command
}
},
tests: {
options: {
configFile: "tests/config/e2e.conf.js",
args: {} // Target-specific arguments
}
},
}
});
我然後運行protractor:tests
目標。 e2e.conf.js的內容如下所示:
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to the location of the spec file. They may
// include glob patterns.
specs: ['../../tests/e2e/user-tests.e2e.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
現在,當我運行在命令行的呼嚕聲,我得到一個錯誤,指出:
Using the selenium server at http://localhost:4444/wd/hub
C:\Projects\MyProject\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1702
throw error;
^
Error: ECONNREFUSED connect ECONNREFUSED
...
我不瞭解我爲什麼會收到此錯誤。我在Protractor Getting Started Guide中看到它期望一個硒獨立服務器正在運行。不過,我認爲這是Grunt任務運行者的目的:啓動硒服務器。我看到的webdriver經辦node_modules \咕嚕,量角器亞軍\ node_modules \量角器\ BIN,但是,如果我更改到該目錄,並在命令行中運行webdriver-manager update
,我得到一個錯誤,指出:
'webdriver-manager' is not recognized as an internal or external command,
operable program or batch file.
如何獲得硒片,以便我可以使用量角器進行端到端測試?
謝謝!