我试图学习AngularJS。作为其中的一部分,我想学习使用端到端测试。目前,我有一个这样的目录结构:
node_modules .bin ... protractor ... node_modules .bin adam-zip glob minijasminenode optimist saucelabs selenium-webdriver protractor config.js src tests test.e2e.js
我的config.js文件看起来像下面:
exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub',capabilities: { 'browserName': 'chrome' },specs: [ '../src/tests/test.e2e.js' ],jasmineNodeOpts: { showColors: true,defaultTimeoutInterval: 30000 } };
test.e2e.js看起来像下面这样:
'use strict'; describe('My Sample',function () { driver = protractor.getInstance(); beforeEach(function () { driver.get('#/'); }); it('My First Test',function () { message = "Hello."; expect(message).toEqual('World.'); }); });
当我尝试使用量角器运行我的端到端测试时,我从命令行运行以下命令:
node_modules\.bin\protractor protractor\config.js
当我运行该命令,我收到以下错误:
C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1542 throw error; ^ Error: ECONNREFUSED connect ECONNREFUSED at ClientRequest.<anonymous> (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:12 7:16) at ClientRequest.EventEmitter.emit (events.js:95:17) at Socket.socketErrorListener (http.js:1528:9) at Socket.EventEmitter.emit (events.js:95:17) at net.js:441:14 at process._tickCallback (node.js:415:13) ==== async task ==== WebDriver.createSession() at Function.webdriver.WebDriver.acquireSession_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv er\lib\webdriver\webdriver.js:130:49) at Function.webdriver.WebDriver.createSession (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver \lib\webdriver\webdriver.js:110:30) at Builder.build (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\builder.js:105:20) at runJasmineTests (C:\Src\MyProject\node_modules\protractor\lib\runner.js:191:45) at C:\Src\MyProject\node_modules\protractor\lib\runner.js:255:5 at C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1178:15 at webdriver.promise.ControlFlow.runInNewFrame_ (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriv er\lib\webdriver\promise.js:1438:20) at notify (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:328:12) at then (C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:377:7)
我究竟做错了什么?
我解决了–standalone标志:
原文链接:https://www.f2er.com/angularjs/145345.htmlwebdriver-manager start –standalone