I'm developing an AngularJS app and want to do end-2-end testing with Protractor. I would like to benefit from the suite of test browsers available at Browserstack and run the tests on Browserstack Automate instead of a local Selenium server.
How do I set up a system to run these tests?
Protractor from version 3.0.0 onwards has added inbuilt support for BrowserStack.
You simply need to add the following two parameters in your conf.js
to launch the test on BrowserStack:
browserstackUser: '<username>'
browserstackKey: '<automate-key>'
Your username and automate key can be found here, after you have logged in to your account.
Hence, lets say you wish to run your test on Chrome 50 / OS X Yosemite, your conf.js
should look something like this:
exports.config = {
specs: ['spec.js'],
browserstackUser: '<username>',
browserstackKey: '<automate-key>',
capabilities: {
browserName: 'Chrome',
browser_version: '50.0',
os: 'OS X',
os_version: 'Yosemite'
},
};
If you wish to run tests in parallel on different browser and OS combinations, you can use the multiCapabilities
as given below:
exports.config = {
specs: ['spec.js'],
browserstackUser: '<username>',
browserstackKey: '<automate-key>',
multiCapabilities: [
{
browserName: 'Safari',
browser_version: '8.0',
os: 'OS X',
os_version: 'Yosemite'
},
{
browserName: 'Firefox',
browser_version: '30.0',
os: 'Windows',
os_version: '7'
},
{
browserName: 'iPhone',
platform: 'MAC',
device: 'iPhone 5S'
}
]
};
Some helpful links:
Code Generator - Helps you configure the capabilities to test on different various browser and OS combinations especially mobile devices.
Sample Github project for Protractor-BrowserStack - This should help you get started.