angularjsseleniumprotractorsaucelabs

Having issue with running Angular Protractor test behind corporate firewall on Sauce lab?


I am not able to run protractor test on Sauce Lab. I am behind corporate firewall and I have active Tunnel to Sauce Lab using Sauce Connect. Below is my protractor conf.js

var HttpsProxyAgent = require("https-proxy-agent");
var agent = new HttpsProxyAgent('http://userName:password@proxy.example.com:8099');

// An example configuration file.
exports.config = {
  agent: agent,
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  directConnect: false,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome',
    'proxy': {
      'proxyType': 'manual',
      'httpProxy': 'http://userName:password@proxy.example.com:8099'
    }
  },

  // Framework to use. Jasmine is recommended.
  framework: 'jasmine',

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: ['tests/specs/*-spec.js'],

  // Options to be passed to Jasmine.
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
  }
};

I am getting following Error when I run node_modules/protractor/bin/protractor conf.js

Error: ETIMEDOUT connect ETIMEDOUT 151.444.33.22:80
    at ClientRequest.<anonymous> (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:174:16)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:259:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
    at doNTCallback2 (node.js:439:9)
    at process._tickCallback (node.js:353:17)
From: Task: WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
    at Function.webdriver.WebDriver.createSession (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
    at [object Object].Builder.build (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
    at [object Object].DriverProvider.getNewDriver (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/driverProviders/driverProvider.js:42:27)
    at [object Object].Runner.createBrowser (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:190:37)
    at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:280:21
    at _fulfilled (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:796:13)
    at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:556:49
[launcher] Process exited with error code 1

Solution

  • The keyword to pass proxy into Sauce Labs via Protractor is sauceAgent. Try the following to see if you have better luck.

    var HttpsProxyAgent = require("https-proxy-agent");
    var agent = new HttpsProxyAgent('http://userName:password@proxy.example.com:8099');
    
    // An example configuration file.
    exports.config = {
      sauceAgent: agent,
      sauceUser: process.env.SAUCE_USERNAME,
      sauceKey: process.env.SAUCE_ACCESS_KEY,