1

我正在使用 Angular 2 和Angular 2 Seed包。我正在尝试运行我的 E2E 测试。我已按照种子页面上列出的步骤进行操作。

我的量角器配置如下所示:

const config = {
  baseUrl: 'http://localhost:6563/',
  specs: [
    './dist/dev/**/*.e2e-spec.js'
  ],
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
  },
  directConnect: true,
  capabilities: {
    browserName: 'chrome'
  },
  onPrepare: function() {
    const SpecReporter = require('jasmine-spec-reporter');
    jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: true }));

    browser.ignoreSynchronization = false;
  },
  useAllAngular2AppRoots: true
};

if (process.env.TRAVIS) {
  config.capabilities = {
    browserName: 'firefox'
  };
}

exports.config = config;

npm run webdriver-start我在一个终端上使用网络驱动程序。我可以看到 selenium server is up and running 消息:

[16:01:58] I/start - seleniumProcess.pid: 20888
16:01:59.133 INFO - Launching a standalone Selenium Server
16:01:59.262 INFO - Java: Oracle Corporation 25.111-b14
16:01:59.262 INFO - OS: Windows 10 10.0 x86
16:01:59.283 INFO - v2.53.1, with Core v2.53.1. Built from revision a36b8b1
16:01:59.345 INFO - Driver class not found: com.opera.core.systems.OperaDriver
16:01:59.345 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
16:01:59.353 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN10
16:01:59.354 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
16:01:59.354 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
16:01:59.532 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
16:01:59.532 INFO - Selenium Server is up and running

我可以http://127.0.0.1:4444/wd/hub从 chrome 访问并创建一个会话,但是当我在另一个终端上运行 E2E 测试时,我收到以下错误:

node_modules\selenium-webdriver\http\index.js:365
      onError(new Error(message));

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:62400
    at ClientRequest.<anonymous> (C:\Users\..\node_modules\selenium-webdriver\http\index.js:365:15)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:269:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1269:8)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
From: Task: WebDriver.createSession()
    at acquireSession (C:\Users\..\node_modules\selenium-webdriver\lib\webdriver.js:62:22)
    at Function.createSession (C:\Users\..\node_modules\selenium-webdriver\lib\webdriver.js:295:12)

任何可以将我推向正确方向的指针?

4

3 回答 3

1

这个错误今天早上才对我开始。我怀疑这是由于昨晚安装了 Windows 更新。禁用 Windows 防火墙后,我不再获得 ECONNREFUSED。

然后我又遇到了一个错误,不得不将 chromedriver 更新到 2.24 才能让量角器运行。

于 2016-10-27T16:10:40.080 回答
0

此问题是由于 Angular 2 版本(测试版或 RC 版)造成的。如果您正在编写测试版代码并尝试在 RC 版本中运行代码,我们需要相应地更改配置和版本。请更新您的量角器和 selenium-webdriver 版本。它会正常运行。

于 2017-04-16T05:53:17.790 回答
0

我最近也遇到了这个问题,并通过更新量角器和 webdriver 来解决这个问题,这个版本似乎很旧。

于 2016-10-28T18:35:52.163 回答