无法使用量角器运行Angular 2的端到端测试



我使用的是Angular 2和Angular 2的Seed包。我正在尝试运行端到端测试。我遵循了种子页面上列出的步骤。

我的量角器配置如下:

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启动web驱动程序。我可以看到selenium服务器启动并运行消息:

[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

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

node_modulesselenium-webdriverhttpindex.js:365
      onError(new Error(message));
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:62400
    at ClientRequest.<anonymous> (C:Users..node_modulesselenium-webdriverhttpindex.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_modulesselenium-webdriverlibwebdriver.js:62:22)
    at Function.createSession (C:Users..node_modulesselenium-webdriverlibwebdriver.js:295:12)

有什么建议可以给我指路吗?

这个错误今天早上才开始。我怀疑是昨晚安装的windows更新造成的。在禁用windows防火墙后,我停止收到ECONNREFUSED.

我得到了另一个错误,不得不更新chromedriver到2.24得到量角器运行

我最近也有这个问题,并通过更新量角器和webdriver来修复它,该版本似乎很旧

这个问题是由于angular 2版本(beta版本或RC版本)。如果你正在做的代码在测试版,并将尝试运行代码在RC版本,我们需要改变配置和版本相应。请更新您的标识符和selenium webdriver版本。

最新更新