Everything was going smoothly with my tests until I encountered an issue when the browser.getCapabilities();
method was called in the OnComplete
function, resulting in an error.
//The HTMLReport is triggered once all tests are completed
onComplete: function () {
var browserName, browserVersion;
browser.getCapabilities();
capsPromise.then(function (caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
platform = caps.get('platform');
var HTMLReport = require('protractor-html-reporter-2');
testConfig = {
reportTitle: 'Protractor Test Execution Report',
outputPath: './reports',
outputFilename: 'ProtractorTestReport',
screenshotPath: '..//screenshots',
testBrowser: browserName,
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true,
testPlatform: platform
};
new HTMLReport().from('xmlresults.xml', testConfig);
});
Here is the error from the console:
E/launcher - Error: TypeError: Cannot read property 'getCapabilities' of undefined
at onComplete (/Users/Testbook/Documents/protractorproj/conf/conf.js:63:13)
at /usr/local/lib/node_modules/protractor/built/frameworks/jasmine.js:115:27
at module.exports.jasmineDone (/usr/local/lib/node_modules/protractor/node_modules/jasmine/lib/reporters/completion_reporter.js:15:5)
at dispatch (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4366:28)
at ReportDispatcher.jasmineDone (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4337:11)
at QueueRunner.onComplete (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:994:18)
at Immediate._onImmediate (/usr/local/lib/node_modules/protractor/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4231:12)
at processImmediate (internal/timers.js:461:21)