karma-browserstack-launcher
karma-browserstack-launcher copied to clipboard
screenshot
This might be a really stupid question, but how to I access the driver/webdriver to make screenshot like suggested here: https://www.browserstack.com/automate/node#enhancements-screenshots
var fs = require('fs');
webdriver.WebDriver.prototype.saveScreenshot = function(filename) {
return driver.takeScreenshot().then(function(data) {
fs.writeFile(filename, data.replace(/^data:image\/png;base64,/,''), 'base64', function(err) {
if(err) throw err;
});
})
};
driver.saveScreenshot('snapshot1.png');
Bonus question: Is it also possible to take screenshots of a css selector, not the whole page?
I think Karma is the wrong tool for the job. Something like SeRunner seems more promising.
https://github.com/Hyddan/se-runner
Karma is for unit testing, which inherently wouldn't have screenshots.