Pradeep
Pradeep

Reputation: 3276

Not able to run Angular 2 E2E tests using protractor

I am using Angular 2 and Angular 2 Seed package. I am trying to run my E2E tests. I have followed the steps which are listed on Seed page.

My protractor config looks like this:

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;

I start web driver using npm run webdriver-start on one terminal. I can see selenium server is up and running message:

[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

I can reach http://127.0.0.1:4444/wd/hub from chrome and create a session but when I run E2E test on another terminal, I get following error:

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)

Any pointers which can push me in right direction?

Upvotes: 1

Views: 719

Answers (3)

Gajanan Kulkarni
Gajanan Kulkarni

Reputation: 693

This problem is due to angular 2 version (beta version or RC version). If you are doing code in beta and will try to run code in RC version, we need to change configuration and version accordingly. Please update your protrator and selenium-webdriver version. It will run properly.

Upvotes: 0

Irene Novogurskaya
Irene Novogurskaya

Reputation: 24

I've also got the issue recently and fixed it by updating protractor and webdriver which version appeared to be very old.

Upvotes: 0

brocborc
brocborc

Reputation: 11

This error just started for me this morning. I suspected it was due to windows updates that were installed last night. After disabling the windows firewall i stopped getting ECONNREFUSED.

I then got another error and had to update chromedriver to 2.24 to get protractor to run.

Upvotes: 1

Related Questions