angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Protractor proxy configuration property not working correctly #4985

Open RonanCodes opened 6 years ago

RonanCodes commented 6 years ago

Bug report

Your protractor configuration 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 = {
    seleniumServerJar: '../node_modules/selenium-standalone/bin/selenium-standalone',
    blockingProxyUrl: 'http://XXXXX.com:XXXX',
    allScriptsTimeout: 11000,
    // seleniumWebDriver: '',
    specs: [
        './src/**/*.e2e-spec.ts'
    ],
    capabilities: {
        'browserName': 'chrome',
        proxy: {
            proxyType: 'manual',
            httpProxy: 'http://XXXXX.com:XXXX',
            sslProxy: 'http://XXXXX.com:XXXX'
        }
    },
    directConnect: false,
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function() {}
    },
    onPrepare() {
        require('ts-node').register({
            project: require('path').join(__dirname, './tsconfig.e2e.json')
        });
        jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    }
};

Output from running the test

A634360:/c/Users/Ronan/development/protractor-test$ npm run e2e
npm info it worked if it ends with ok
npm info using npm@6.4.1
npm info using node@v8.12.0
npm timing npm Completed in 101ms
npm info ok
npm info it worked if it ends with ok
npm info using npm@6.4.1
npm info using node@v8.12.0
npm info lifecycle protractor-test@0.0.0~pree2e: protractor-test@0.0.0
npm info lifecycle protractor-test@0.0.0~e2e: protractor-test@0.0.0

> protractor-test@0.0.0 e2e C:\Ronan\development\protractor-test
> ng e2e

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-10-24T16:28:31.534Z
Hash: b29343f12156de6022d8
Time: 10064ms
chunk {main} main.js, main.js.map (main) 10.7 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.28 MB [initial] [rendered]
[17:28:32] I/config_source - curl -oC:\Users\A634360\development\cloning\protractor-test\node_modules\protractor\node_modules\webdriver-manager\selenium\chrome-response.xml https://chromedriver.storage.googleapis.com/
i 「wdm」: Compiled successfully.
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 172.217.197.128:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
npm info lifecycle protractor-test@0.0.0~e2e: Failed to exec e2e script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protractor-test@0.0.0 e2e: `ng e2e`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protractor-test@0.0.0 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm timing npm Completed in 38929ms

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ronan\AppData\Roaming\npm-cache\_logs\2018-10-24T16_28_53_621Z-debug.log

Steps to reproduce the bug

Run:

Feature Request

I installed the webdriver-manager npm module and got the same above error when running: webdriver-manager update.

However it works when I run: webdriver-manager update --proxy http://XXXXX.com:XXXX

I read on the webdriver-manager git project page that:

A selenium server and browser driver manager for your end to end tests. This is the same tool as webdriver-manager from the Protractor repository. Here: https://github.com/angular/webdriver-manager

This leads me to believe that all of the various settings we can set via terminal flags on webdriver-manager; should also be allowed to be set via the protractor configuration file: protractor.conf.js.

However, my above protractor config file is not working. Here is where this proxy info is stated: https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#proxy-json-object I found this link within the protractor code in this file: lib\config.ts

I'm created the app with: ng new protractor-app, so it's clean, nothing added.

Summary

The proxy setting works for webdriver-manager standalone but not within protractor.

iranicus commented 4 years ago

Taking a look it appears that the curl fails to get a response which is causing the error indicating you had ran it on a closed network, what I did to avoid this was stop webdriver update from running at all via:

ng e2e --webdriver-update=false

It just requires you to make sure that the right driver files for whatever browser you are testing against is downloaded and put into the node_modules/protractor/node_modules/webdriver-manager/selenium directory. This is pretty straight forward once you bookmark the f2p sites where the drivers for the appropriate web browser is stored. Hope this helps.