I use jasmine reporters (a node) here.
Write the code in the conf file.
onPrepare: function () { jasmine.getEnv().addReporter({ specDone: function (result) { if (result.status === 'failed') { browser.getCapabilities().then(function (caps) { var browserName = caps.get('browserName'); browser.takeScreenshot().then(function (png) { var stream = fs.createWriteStream('screenshots/' + browserName + '-' + result.fullName + '.png'); stream.write(new Buffer(png, 'base64')); stream.end(); }); }); } } }); }
The above code has screenshots when there is a failure, and then it is stored in a folder with screenshot names with the file name: -
browsername-errorItBlockName.png
example: -
it('user signup', function () {
Screenshot Title: chrome-user signup.png
source share