【发布时间】:2014-05-13 14:59:49
【问题描述】:
我正在 Windows 上构建一个 AngularJS 应用程序。我想用 Jasmine 创建端到端测试。据我了解,我需要量角器来运行这些类型的测试。出于这个原因,我在 package.json 中添加了以下内容:
"devDependencies": {
...
"grunt-protractor-runner": "0.2.4",
"selenium-webdriver":"2.41.0",
...
}
在我的 gruntfile.js 中,我已经这样配置 Protractor:
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.
}
};
现在,当我从命令行运行 grunt 时,我收到一条错误消息:
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 中看到它期望一个 selenium 独立服务器正在运行。但是,我认为这就是 Grunt 任务运行器的目的:启动 selenium 服务器。我在 node_modules\grunt-protractor-runner\node_modules\protractor\bin 中看到 webdriver-manager,但是,如果我切换到该目录并从命令行运行 webdriver-manager update,我会收到一条错误消息:
'webdriver-manager' is not recognized as an internal or external command,
operable program or batch file.
如何让 selenium 部分运行,以便我可以使用量角器运行端到端测试?
谢谢!
【问题讨论】:
标签: angularjs selenium selenium-webdriver protractor