Protractor: Proposal: Bring Back sauceProxy configuration

Created on 25 Jul 2017  Â·  5Comments  Â·  Source: angular/protractor

Bug report

  • Node Version: 6.9.1
  • Protractor Version: 5.1.2
  • Angular Version: ^4.0.0
  • Browser(s): All
  • Operating System and Version Windows 7
  • Your protractor configuration file
const conf = require('./e2e/config/conf.e2e.json');
const { SpecReporter } = require('jasmine-spec-reporter');
const jasmineReporters = require('jasmine-reporters');

const prerun = { "background": true, "executable": "sauce-storage:auth_sauce.exe" };
const shartTestFiles = false;
const maxInstances = 1;

console.log("proxy is " + process.env.HTTP_PROXY + '--------------------------------------');

exports.config = {
  SELENIUM_PROMISE_MANAGER: 0,
  sauceBuild: process.env.JENKINS_BUILD_NUMBER || 'localTestBuildNumber__00',
  sauceUser: process.env.SAUCE_USERNAME || 'test',
  sauceKey: process.env.SAUCE_ACCESS_KEY || 'test',
  sauceSeleniumUseHttp: true,
  sauceSeleniumAddress: 'localhost:4445/wd/hub',
  webDriverProxy: process.env.HTTP_PROXY,
  multiCapabilities: [

    // {
    //   build,
    //   buildName,
    //   "name": "Windows 7 IE 11",
    //   "username": conf.sauceUser,
    //   "accessKey": conf.sauceKey,
    //   "tunnel-identifier": "shepherd-jenkins",
    //   "platform": "Windows 7",
    //   "browserName": "internet explorer",
    //   "version": "11",
    //   "avoid-proxy": true,
    //   "unexpectedAlertBehaviour": "ignore",
    //   maxInstances,
    //  shartTestFiles,
    //   prerun
    // },
    {
      count: 1,
      "name": "Windows 7 chrome 57",
      "tunnel-identifier": "shepherd-jenkins",
      "platform": "Windows 7",
      "browserName": "chrome",
      chromeOptions: {
        prefs: {
          'credentials_enable_service': false,
          'profile': {
            'password_manager_enabled': false
          }
        },
        args: [
          '--disable-cache',
          '--disable-application-cache',
          '--disable-offline-load-stale-cache',
          '--disk-cache-size=0',
          '--v8-cache-options=off'
        ]
      },
      "version": "57",
      shartTestFiles,
      prerun
    },
  ],
  allScriptsTimeout: 11000,
  seleniumArgs: ['--ignore_ssl'],
  specs: [
    './e2e/**/*.e2e-spec.ts',
  ],

  directConnect: true,
  baseUrl: 'my.url.com',
  framework: 'jasmine2',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function () {
    }
  },

  onPrepare() {
    let capabilities
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });

    jasmine.getEnv().addReporter(new SpecReporter({
      spec: { displayStacktrace: true }
    }));

    return browser.getProcessedConfig().then((c) => {
      capabilities = c.capabilities;
      // used to change the namespace for the data.
      process.env.CURRENT_BROWSER = c.capabilities.browserName.replace(new RegExp(' ', 'g'), '-');
      jasmine.getEnv().addReporter(
        new jasmineReporters.JUnitXmlReporter({
          filePrefix: c.capabilities.browserName,
          consolidateAll: true,
          modifySuiteName: function (generatedSuiteName, suite) {
            // this will produce distinct suite names for each capability,
            // e.g. 'firefox.login tests' and 'chrome.login tests'
            return c.capabilities.browserName + '.' + generatedSuiteName;
          }
        }));

      return browser.driver.get(c.baseUrl).then(function () {
        browser.sleep(2000);
      });
    });
  },

  onComplete() {
    return browser.getProcessedConfig().then(function (c) {
      return browser.getSession().then(function (session) {
        // required to be here so saucelabs picks up reports to put in jenkins
        console.log('SauceOnDemandSessionID=' + session.getId() + ' job-name=' + c.capabilities.name);
      });
    });
  }
};

  • A relevant example test
    Setup Saucelabs in a jenkins build using node version 6.2.1 (i had 6.9.1 on my local)

  • Output from running the test
    Basically what it boils down to is I need my proxy to make the SauceLabs call to update my tests however I'm running my tests in Jenkins. When I run my tests, I get this problem

03:10:21 <div id="content">
03:10:21 <p>The following error was encountered while trying to retrieve the URL: <a href="http://myusername@localhost:4445/wd/hub/session">http://myusername@localhost:4445/wd/hub/session</a></p>
03:10:21 
03:10:21 <blockquote id="error">
03:10:21 <p><b>Access Denied.</b></p>
03:10:21 </blockquote>

Now I'm not sure if it was because the Jenkins job was running on NODE 6.2.1 or not but I do know it was usingthe webdriver proxy for my connection to the Sauce Selenium Relay but oddly was not including the saucekey. Whenever i got access denied it always only showed myusername only. I'm able using seleniumAddress and setting username / accesskey in each of my capabilities without setting webdriverproxy to run the tests.

Feature Request

My request would be to allow SauceLabs plugin to be configurable separate from the main testing connection like it used to be. Right now there is no way for me to tell Protractor this beucase webDriverProxy is used for the driverProvider config + SauceLabs config.

  • Reasons for adopting new feature
  • Is this a breaking change? (How will this affect existing functionality)
    It would be a breaking revert to what it previously was but it wouldn't be that big. I'd be willing to looking into doing the PR when I have time. I just don't know why sauceProxy was taken out because they are 2 separate usages of the proxy. At the very least have some way that I could maybe slip in my own SauceLabs plugin as we do the sauceAgent.

As a part of a relavant thing it would be also nice if that sauce driverProvider covered console.log(session / job); as you see in my configuration so it would be a more complete integration with saucelabs. (specifically reporting for the jenkins plugin but it doesn't hurt anything anywhere else)

feature request

Most helpful comment

That's exactly it! When I was looking through to code I saw that if
webdriverproxy was set it uses it in the get proxy which messes up my tests
because I'm using sauelabs in Jenkins with selenium relay so it tries to
use the proxy to a driver that is on the Jenkins machine and fails.

On Tue, Aug 1, 2017, 4:37 PM Craig notifications@github.com wrote:

I am having issues with how that is previously phrased. So I'm trying to
get onboard but I don't understand.

You launch your test against saucelabs and need to use the proxy. This is
currently defined as webdriverProxy previously defined as sauceProxy. Is it
because we are initializing sauce with a proxy in the sauce constructor and
then when we get a new driver instance we are trying to proxy again? See sauce
constructor
https://github.com/angular/protractor/blob/ab1afb093107f3a63f6e15f8f315e33576bb414d/lib/driverProviders/sauce.ts#L61
and get new driver
https://github.com/angular/protractor/blob/ab1afb093107f3a63f6e15f8f315e33576bb414d/lib/driverProviders/driverProvider.ts#L54

If that is the case, then I will put a PR to revert this change. We
currently do not have a proxy service to test some of these changes.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/protractor/issues/4405#issuecomment-319504438,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMPLteZDSomb8F1uoxZsD1HXzfYXCcU4ks5sT5qggaJpZM4OjD5d
.

All 5 comments

This is the commit that was made that removed it and to use webdriverProxy https://github.com/angular/protractor/commit/604fdbf064cc2785a2e745747beeaeb45d27f8ed

Here is the original issue why we removed it. https://github.com/angular/protractor/issues/3694

Important to note that webdriverProxy was a variable in the configuration file but I do not believe it was used. I believe we decided to use webdriverProxy over sauceProxy since it was more consistent with the variable names in the sauce node module. If you need to switch between environments, I would suggest using environment variables or something based off of the os node module.

This is not an issue of switching between envs. It is that through
saucelabs I need to use the proxy and through webdriver I don't . There is
no way for me to configure that right now. It is saulabd specific thing as
well so if figured it would be covered through the sl module but it isn't .

This issue has made me and probably others have to hand configure each
capability instead of using the sauce.js config as expected .

Just to reiterate there is no way for me to set webdriverproxy for the
sauce extension in sauce.ts to use but NOT the driver itself.

On Tue, Aug 1, 2017, 12:14 PM Craig notifications@github.com wrote:

Closed #4405 https://github.com/angular/protractor/issues/4405.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/protractor/issues/4405#event-1188065821, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AMPLtSWpAkJOpwrk6yxalgNxaCUJKHtLks5sT1zsgaJpZM4OjD5d
.

I am having issues with how that is previously phrased. So I'm trying to get onboard but I don't understand.

You launch your test against saucelabs and need to use the proxy. This is currently defined as webdriverProxy previously defined as sauceProxy. Is it because we are initializing sauce with a proxy in the sauce constructor and then when we get a new driver instance we are trying to proxy again? See sauce constructor and get new driver

If that is the case, then I will put a PR to revert this change. We currently do not have a proxy service to test some of these changes.

That's exactly it! When I was looking through to code I saw that if
webdriverproxy was set it uses it in the get proxy which messes up my tests
because I'm using sauelabs in Jenkins with selenium relay so it tries to
use the proxy to a driver that is on the Jenkins machine and fails.

On Tue, Aug 1, 2017, 4:37 PM Craig notifications@github.com wrote:

I am having issues with how that is previously phrased. So I'm trying to
get onboard but I don't understand.

You launch your test against saucelabs and need to use the proxy. This is
currently defined as webdriverProxy previously defined as sauceProxy. Is it
because we are initializing sauce with a proxy in the sauce constructor and
then when we get a new driver instance we are trying to proxy again? See sauce
constructor
https://github.com/angular/protractor/blob/ab1afb093107f3a63f6e15f8f315e33576bb414d/lib/driverProviders/sauce.ts#L61
and get new driver
https://github.com/angular/protractor/blob/ab1afb093107f3a63f6e15f8f315e33576bb414d/lib/driverProviders/driverProvider.ts#L54

If that is the case, then I will put a PR to revert this change. We
currently do not have a proxy service to test some of these changes.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/protractor/issues/4405#issuecomment-319504438,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMPLteZDSomb8F1uoxZsD1HXzfYXCcU4ks5sT5qggaJpZM4OjD5d
.

I can do this right now...

Was this page helpful?
0 / 5 - 0 ratings