Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created November 26, 2013 12:59
Show Gist options
  • Save thekarel/7657903 to your computer and use it in GitHub Desktop.
Save thekarel/7657903 to your computer and use it in GitHub Desktop.
function writeScreenshot(data, name) {
name = name || 'ss.png';
var screenshotPath = 'C:\\selenium_local_map\\';
fs.writeFileSync(screenshotPath + name, data, 'base64');
};
driver.takeScreenshot().then(function(data) {
writeScreenshot(data, 'out1.png');
});
@john1625b
Copy link

john1625b commented Aug 17, 2016

Thanks for making this

Another way to do it, from the docs
var screenshot = browser.saveScreenshot(); // returns base64 string buffer
fs.writeFileSync('./myShort.png', screenshot)

@vivacenontroppo
Copy link

It's not working anymore:

Failed: ENOENT: no such file or directory, open './screenshots/out1.png'

And from the comment:
browser.saveScreenshot() - that's a method from webdriver.io, not present in Selenium webdriver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment