angularproxyprotractorangular-e2e

Can't run Angular > 2 e2e using protractor behind a proxy


will appreciate any help!

webdriver-manager update --ie32 --proxy http://my-proxy:8080 --ignore_ssl

my protractor.conf file is as follows:

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

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

Tried to ran tests first by: ng e2e second by:

ng e2e --config ./protractor.conf.js --specs ./e2e\app.e2e-spec.ts

And still getting this proxy error:

events.js:136
      throw er; // Unhandled 'error' event
      ^

    Error: getaddrinfo ENOTFOUND chromedriver.storage.googleapis.com chromedriver.storage.googleapis.com:443
        at errnoException (dns.js:55:10)
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:26)

Solution

  • ng e2e will execute webdriver-manager start/update in background, and webdriver-manager start will access "chromedriver.storage.googleapis.com" to query latest webdriver binary, your error comes from here.

    Because ng e2e can't accept proxy from cli or pre-configured file, the only way you can set proxy for webdriver-manager start/update triggered by ng e2e is by Environment Variable.

    Add below 3 Environment Variables:

    HTTP_PROXY = http://my-proxy:port
    HTTPS_PROXY = http://my-proxy:port
    NO_PROXY = localhost,127.0.0.1, .yourcompany.com
    

    Try ng e2e in new cmd window (don't try in old cmd window)

    FYI, once you add the 3 Environment Variables, you no need to pass --proxy in cli when execute webdriver-manager start/update.