Test on Internal Networks
BrowserStack enables you to run your Protractor 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 Protractor tests for Local Testing takes just three steps:
Step 1: Install the BrowserStack Local Testing bindings:
npm install browserstack-local
Step 2: Next, you need to update your Protractor config file, protractor-browserstack/conf/local.conf.js
(in sample repo), and set the browserstack.local
capability to true
:
var browserstack = require('browserstack-local');
exports.config = {
'specs': [ '../specs/local.js' ], // Example spec file in sample repository
'browserstackUser': 'YOUR_USERNAME',
'browserstackKey': 'YOUR_ACCESS_KEY',
'capabilities': {
'build': 'protractor-browserstack',
'name': 'local_test',
'browserName': 'chrome',
'browserstack.local': 'true',
'browserstack.debug': 'true'
},
// Code to start browserstack local before start of test
beforeLaunch: function(){
console.log("Connecting local");
return new Promise(function(resolve, reject){
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config['browserstackKey'] }, function(error) {
if (error) return reject(error);
console.log('Connected. Now testing...');
resolve();
});
});
},
// Code to stop browserstack local after end of test
afterLaunch: function(){
return new Promise(function(resolve, reject){
exports.bs_local.stop(resolve);
});
}
};
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.driver.get('http://bs-local.com:45691/check').then(function() {
expect(browser.driver.getPageSource()).toMatch(/Up and running/i);
});
});
});
Step 3: You can now run your Protractor test using BrowserStack Local with the following command:
./node_modules/.bin/protractor conf/local.conf.js
Next steps
Once you have successfully run your first test on BrowserStack, you might want to explore the following:
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
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!