How can I configure multiple browsers for testing using Protractor?
To configure multiple browsers, you need to specify them in the multiCapabilities
section as shown below:
multiCapabilities: [{
'browserName': 'firefox'
}, {
'browserName': 'chrome'
}]
Is there a straightforward way to test on mobile devices like iOS8 Safari or mobile Chrome?
One approach is to utilize the Appium
framework. You can refer to the following documentation sections for more details:
Alternatively, you can opt for services like Browserstack
or Sauce Labs
as your Selenium server. These platforms offer a wide array of browsers and mobile devices for testing. Here's an example configuration from our internal projects:
'use strict';
var browserstackUser = 'user';
var browserstackKey = 'key';
exports.config = {
multiCapabilities: [
{
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browserName': 'Chrome',
'os': 'Windows',
'os_version': '8',
specs: [
'*.spec.js'
],
exclude: [
'footer.disabledCookies.spec.js',
'footer.disabledFlash.spec.js'
]
},
{
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browserName': 'Internet Explorer',
'browser_version': '9.0',
'os': 'Windows',
'os_version': '7',
'resolution': '1024x768',
specs: [
'*.spec.js'
],
exclude: [
'footer.disabledCookies.spec.js',
'footer.disabledFlash.spec.js'
]
}
],
maxSessions: 2,
// Browserstack's selenium server address
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
framework: 'jasmine',
allScriptsTimeout: 300000,
baseUrl: 'http://localhost:9001',
onPrepare: function () {
require('jasmine-reporters');
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
var browserName = caps.caps_.browserName.toUpperCase();
var browserVersion = caps.caps_.version;
var prePendStr = browserName + "-" + browserVersion + "-";
jasmine.getEnv().addReporter(new
jasmine.JUnitXmlReporter("test-results", true, true, prePendStr));
});
},
jasmineNodeOpts: {
showColors: true,
isVerbose: true,
includeStackTrace: true,
defaultTimeoutInterval: 3600000
}
};