Hi I'm trying to get the protractor test results in a file by giving the following command in command prompt.
protractor conf.js > location\result.txt
where I could see the complete output of the protractor test.
Can I get just the number of Specs executed and failures in a txt file after running the protractor tests in a customized way?
I need my report in this customized way as I need to run a shell script if all the protractor tests are passed.
We have two ways to fulfill your requirement. but it will give final results in .json format. If you really needed only .txt format you convert .json to .text
Ways To Do:
Declare parameter 'resultJsonOutputFile:' value in conf.js file as follows-
resultJsonOutputFile:'./testResults.json', //output file path to store the final results in .json format
OR
Pass the output file path from command line while running the protractor:
Command:
protractor --resultJsonOutputFile='../outputFilePath.json' protractor.conf.js
If you need any suggestions/help, please ping here, i'm happy to help you.
Jasmine is the framework that does the spec reporting, not Protractor. You can either use one of the popular ones they already have:
(1) https://www.npmjs.com/package/jasmine-spec-reporter
(2)https://github.com/larrymyers/jasmine-reporters (look at the JUnit XML section)
Or you can make your own (which is what it sounds like you want): http://jasmine.github.io/2.1/custom_reporter.html
Change your conf.js
file something like this.
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
baseDirectory: './protractor-result', // a location to store screen shots.
docTitle: 'Protractor Demo Reporter',
docName: 'protractor-demo-tests-report.html'
});
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['invoice.js'],
capabilities: {
browserName: 'chrome',
},
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
},
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
}
}
Then execute it using following comander.
npm install protractor-html-screenshot-reporter
Feel free to ask any questions if you are not clear. :)