Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Protractor with BrowserStack behind a proxy

I want to build a Testsuite for an Angular App. The testsuite should use the framework "Protractor". When I start the testsuite local with protractor local.config.js, then the test are running successful. When I start the testsuite with BrowserStack without proxy, also everything are okay.

Now my question:

What settings do I have to do if I want to perform the test by local browser stack behind a proxy?

Main BrowserStack configuration:

var
  proxy = 'http://proxy.example.com:8888';

exports.config = {
  capabilities: {
    project: 'BrowserStack (beyond Proxy)',
    proxy: {
      proxyType: 'manual',
      httpProxy: proxy,
      sslProxy: proxy,
      },
    loggingPrefs: {
      driver: "FINE",
      server: "OFF",
      browser: "FINE"
    },

    'browserstack.user': 'USER_KEY',
    'browserstack.key': 'ACCESS_KEY', // show on BrowserStack

    // Needed for testing localhost
    'browserstack.local' : 'true',

    // Settings for the browser you want to test
    // (check docs for difference between `browser` and `browserName`
    'browserName' : 'chrome',
    'version' : '43.0',
    'os' : 'OS X',
    'os_version' : 'Yosemite',
    'resolution' : '1024x768'
  },
  seleniumAddress: 'http://hub.browserstack.com/wd/hub',
  specs: [
    'test/e2e/**/*.spec.js'
  ]
};

I call the script "BrowserStackLocal" with this parameters:

./BrowserStackLocal -v -proxyHost PROXY_DOMAIN -proxyPort PROXY_PORT $ACCESS_KEY localhost,$PORT,0

Stepts:

  1. start the application on my local computer node app.js
  2. start the script "BrowserStackLocal"
  3. start the protractor with the browserstack configuration from above.
like image 952
Mulder3 Avatar asked May 07 '26 14:05

Mulder3


2 Answers

When you are behind a proxy server, you need to do two things:

  1. If you are testing your local server, you need to setup the Local Testing connection by passing the proxy details, which I assume you are doing.

  2. You have to make sure the Selenium requests made via Protractor also reach BrowserStack. The easiest option would be to use global-tunnel npm package. If your proxy is behind an Authentication, you can try using the tunnel npm module.

like image 88
Umang Sardesai Avatar answered May 10 '26 02:05

Umang Sardesai


You no longer need to use global-tunnel. There is now a new configuration option webDriverProxy:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  webDriverProxy: 'http://127.0.0.1:8888',
  capabilities: {
    browserName: 'chrome'
  },
  specs: ['*.spec.js'],
};
like image 30
gregjhogan Avatar answered May 10 '26 02:05

gregjhogan