Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor: ng e2e: How to solve the "Error: connect ETIMEDOUT" error?

I developed the Tour of Heroes Angular tutorial application. After that I wrote tests for the components. The application and the component tests are doing fine. Now I wanted to develop E2E tests with Protractor and I can't get them running.

Every time I run ng e2e on the command line, I get the following output:

$ ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-26T14:51:12.962Z
Hash: ef70100f8d31703b6b85
Time: 8035ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:13556) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
events.js:182
  throw er; // Unhandled 'error' event
  ^

Error: connect ETIMEDOUT 216.58.205.112:443
    at Object._errnoException (util.js:1026:11)
    at _exceptionWithHostPort (util.js:1049:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)

Some hopefully useful information regarding my setup:

  • The project was created with the Anguliar CLI
  • Protractor was installed globally and local
  • The following files are in the node_modules/webdriver-manager/selenium directory: chromedriver_2.32.exe, chromedriver_2.32.zip, chrome-response.xml, gecko-response.json, selenium-server-standalone-3.5.3.jar, standalone-response.xml
  • I run webdriver-manager update with a proxy property
  • It makes no difference if I run the command with a running Selenium Grid or with the directConnect: true configuration
  • As browser is set Chrome (Firefox has the same problem)
  • OS: Windows 10, Browser: Chrome 51.0.2704.106 m (64-bit)

protractor.conf.js file:

// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  /*seleniumAddress: 'http://localhost:4444/wd/hub',*/
  directConnect: true,
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

package.json file:

{
  "name": "angular-tour-of-heroes",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.2",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-in-memory-web-api": "^0.4.6",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-firefox-launcher": "^1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

It's the first time that I try to develop E2E tests with Angular and Protractor.

Thank you for your support!

Update

I didn't know that webdriver-manager update will be executed if I run ng e2e. So I tried ng e2e --no-webdriver-update and with this command the error above is not coming anymore. I think the error appears because no proxy is set and the webdriver-manager is not able to run the update.

However, now I am getting a new error. Here is the full output again:

$ ng e2e --no-webdriver-update
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-27T06:50:31.482Z
Hash: ef70100f8d31703b6b85
Time: 8513ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:12764) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[08:50:31] I/launcher - Running 1 instances of WebDriver
[08:50:31] I/direct - Using ChromeDriver directly...
[08:50:31] E/direct - Error code: 135
[08:50:31] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[08:50:31] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
    at Direct.getNewDriver (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\driverProviders\direct.js:63:31)
    at Runner.createBrowser (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:195:43)
    at q.then.then (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\built\runner.js:339:29)
    at _fulfilled (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:796:13)
    at D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:137:13)
    at flush (D:\gitrepos\angular-tour-of-heroes\node_modules\protractor\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
[08:50:31] E/launcher - Process exited with error code 135
like image 650
Twaldigas Avatar asked Sep 26 '17 15:09

Twaldigas


2 Answers

OK, I was able to solve the problem. Here is what I did.

ng e2e runs the webdriver-manager update command. In my case this caused the ETIMEDOUT problem, because in my environment without a proxy it cannot download the files. Instead I have to use ng e2e --no-webdriver-update.

Now I had the Could not find update-config.json error.

Using the --proxy argument to update webdriver-manager seems to not download everything and/or correct. I had to set the environment variables HTTP_PROXY and HTTPS_PROXY and run the command webdriver-manager update --ignore_ssl.

Now protractor is working.

like image 96
Twaldigas Avatar answered Oct 02 '22 02:10

Twaldigas


If you are in webstorm or Intellij editor. You can either setup the HTTPS_PROXY variable or in the webstorm terminal

SET https_proxy=http://yourcompanydomain.com:portnumber
SET http_proxy=http://yourcompanydomain.com:portnumber 

Then run the following command in Terminal

ng e2e

it should definitely work

like image 35
Ragavan Rajan Avatar answered Oct 02 '22 02:10

Ragavan Rajan