Reputation: 624
I've the following config.js
file:
var testName = 'Testing';
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
baseDirectory: './protractor-result', // a location to store screen shots.
docTitle: 'Report Test Summary',
docName: 'protractor-tests-report.html'
});
exports.config = {
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
multiCapabilities: [
{
name: testName,
browserName: 'Chrome',
browser_version: '39.0',
os: 'OS X',
os_version: 'Yosemite',
resolution: '1920x1080',
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.debug': 'true',
'browserstack.selenium_version': '2.45.0'
}
,
{
name: testName,
browserName: 'IE',
browser_version: '11.0',
os: 'Windows',
os_version: '8.1',
resolution: '2048x1536',
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.debug': 'true',
'browserstack.selenium_version': '2.45.0',
'browserstack.ie.driver': '2.44',
//ignoreProtectedModeSettings: true
}
],
// Spec patterns are relative to the current working directly when
// protractor is called.
suites: {
waitlist: './././specs/waitlist_page_spec.js',
press: './././specs/press_page_spec.js',
news: './././specs/news_page_spec.js',
landing: './././specs/landing_page_spec.js'
},
// Maximum number of total browser sessions to run. Tests are queued in
// sequence if number of browser sessions is limited by this parameter.
// Use a number less than 1 to denote unlimited. Default is unlimited.
maxSessions: 2,
// protractor will save the test output in json format at this path.
// The path is relative to the location of this config.
resultJsonOutputFile: null,
framework: 'jasmine2',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 100000,
realtimeFailure: true,
showTiming: true,
includeStackTrace: true,
isVerbose: true,
onComplete: null
},
onPrepare: function () {
jasmine.getEnv().addReporter(reporter);
browser.driver.manage().window().maximize();
global.dvr = browser.driver; //variable to call selenium directly
global.isAngularSite = function (flag) {
browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages
};
//browser.manage().timeouts().pageLoadTimeout(90000);
browser.manage().timeouts().implicitlyWait(100000);
}
};
And I would like to find a way to ask on my test that if the capability.browserName is IE do a certain/especial action, so, I would like to do some sort of getConfig(), is that possible? does anyone had implemented something similar?
Thanks all for your time!
Upvotes: 1
Views: 704
Reputation: 4286
The getCapabilities in browser returns a promise with these values:
browser.getCapabilities().then(function (capabilities) {
browser = capabilities.caps_.browserName;
platform = capabilities.caps_.platform;
}).then(function displayEnv() {
console.log('Browser:', browser, 'on platform', platform);
});
Upvotes: 1