一尘不染

无法运行量角器-ECONNREFUSED连接ECONNREFUSED

angularjs

我正在尝试学习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)

我究竟做错了什么?


阅读 192

收藏
2020-07-04

共1个答案

一尘不染

我用–standalone标志解决了这个问题:

webdriver-manager start --standalone

2020-07-04