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

风格不统一 提交于 2019-12-07 17:10:37

问题


will appreciate any help!

  • I'm running on windows
  • I installed protractor Version 5.3.0 globally
  • Before updating webdriver I ran: webdriver-manager clean
  • And updated version as follows:

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

  • node version 9.2.1
  • npm version 5.7.1
  • started dev server before starting e2e..

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)

回答1:


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.



来源:https://stackoverflow.com/questions/49233422/cant-run-angular-2-e2e-using-protractor-behind-a-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!