量角器 Js 运行 linux 机器

Protractor Js run to linux machine

我的 angular 项目中有量角器测试,当我想要 运行 它时,我会捕获下一个异常日志:

Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Possibly unhandled RequestError: Error: connect ECONNREFUSED
    at new RequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/errors.js:11:15)
    at Request.RP$callback [as _callback] (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/lib/rp.js:56:32)
    at self.callback (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:198:22)
    at Request.emit (events.js:95:17)
    at Request.onRequestError (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/request-promise/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1548:9)
    at CleartextStream.emit (events.js:95:17)
    at Socket.onerror (tls.js:1456:17)
    at Socket.emit (events.js:117:20)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
Error: connect ECONNREFUSED
    at errnoException (net.js:905:11)
    at Object.afterConnect [as oncomplete] (net.js:896:19)
[launcher] Process exited with error code 1

/home/tk/WorkSpaceNew/dashboard/frontend/gulp/e2e-tests.js:23
        throw err;
              ^
Error: protractor exited with code 1

Process finished with exit code 8

在它之前我看到浏览器 window 和下一个 url: data:,.

UPD protractor.conf.js

'use strict';

var paths = require('./.yo-rc.json')['generator-gulp-angular'].props.paths;

// An example configuration file.
exports.config = {
  // The address of a running selenium server.
  //seleniumAddress: 'http://localhost:4444/wd/hub',
  //seleniumServerJar: deprecated, this should be set on node_modules/protractor/config.json

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: [paths.e2e + '/**/*.js'],

  // Options to be passed to Jasmine-node.
  mochaOpts: {
    timeout: 5000
  },

  framework: 'mocha'
};

UPD2

如果我使用 seleniumAddress: 'http://localhost:4444/wd/hub', 我捕捉到下一个异常:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.

/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED
    at ClientRequest.<anonymous> (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145:16)
    at ClientRequest.emit (events.js:95:17)
    at Socket.socketErrorListener (http.js:1548:9)
    at Socket.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:448:13)
==== async task ====
WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:149:22)
    at Function.webdriver.WebDriver.createSession (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:123:30)
    at Builder.build (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/builder.js:294:22)
    at DriverProvider.getNewDriver (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
    at Runner.createBrowser (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/lib/runner.js:180:37)
    at /home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/lib/runner.js:257:21
    at _fulfilled (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/home/tk/WorkSpaceNew/dashboard/frontend/node_modules/gulp-protractor/node_modules/protractor/node_modules/q/q.js:759:13)
[launcher] Process exited with error code 1

/home/tk/WorkSpaceNew/dashboard/frontend/gulp/e2e-tests.js:23
        throw err;
              ^
Error: protractor exited with code 1

Process finished with exit code 8

请帮助我 运行 在我的电脑上进行此测试。 非常感谢。

如果你想连接到那个 seleniumAddress,你需要从 protractor/bin/webdriver-manager start 启动一个 selenium 服务器。如果没有 selenium 服务器 运行ning,您将无法 运行 那里的测试 (ECONNREFUSED)。

或者您可以在配置文件中注释掉 seleniumAddress,使用 protractor/bin/webdriver-manager update 下载二进制文件,量角器将 运行 使用独立的 seleniumServerJar 进行测试。