karma-browserstack-launcher icon indicating copy to clipboard operation
karma-browserstack-launcher copied to clipboard

screenshot

Open ComLock opened this issue 9 years ago • 1 comments

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?

ComLock avatar Dec 21 '15 15:12 ComLock

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.

randallb avatar Jul 04 '16 11:07 randallb