Test on Internal Networks

BrowserStack enables you to run your WebdriverIO automated tests on your internal development environments, on localhost, and from behind a corporate firewall. This feature is called “Local Testing”.

Local Testing establishes a secure connection between your machine and the BrowserStack cloud. Once you set up Local Testing, all URLs work out of the box, including HTTPS URLs and those behind a proxy or firewall.

Configuring your WebdriverIO tests for Local Testing takes just three steps:

Step 1: Install the BrowserStack Local Testing bindings:

# Install using npm

npm install browserstack-local

Step 2: Next, you need to update your WebdriverIO config file, local.conf.js, and set the browserstack.local capability to true:

var browserstack = require('browserstack-local');

exports.config = {
  user: 'YOUR_USERNAME',
  key: 'YOUR_ACCESS_KEY',

  capabilities: [{
    browserName: 'chrome',
    name: 'Bstack-[WebdriverIO] Local Test',
    'browserstack.local': true
  }],

  // Code to start browserstack local before start of test
  onPrepare: function (config, capabilities) {
    console.log("Connecting local");
    return new Promise(function(resolve, reject){
      exports.bs_local = new browserstack.Local();
      exports.bs_local.start({'key': exports.config.key }, function(error) {
        if (error) return reject(error);
        console.log('Connected. Now testing...');

        resolve();
      });
    });
  },

  // Code to stop browserstack local after end of test
  onComplete: function (capabilties, specs) {
    exports.bs_local.stop(function() {});
  }
}

You can use the following sample test case, which is in our GitHub repo. This test case navigates to the local server which you can use to verify if your Local test connection has been setup correctly:

describe('BrowserStack Local Testing', function() {
  it('can check tunnel working', function () {
    browser
      .url('http://bs-local.com:45691/check')

    assert(browser.getSource().match(/Up and running/i));
  });
});

Step 3: You can now run your WebdriverIO test using BrowserStack Local with the following command:

./node_modules/.bin/wdio conf/local.conf.js

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert