Last active
April 13, 2017 13:56
-
-
Save masonmark/2332c1238a2fa70b5e4fcfffdcd76ca3 to your computer and use it in GitHub Desktop.
example of a function to take a screenshot from within a Protractor 5 ( / Selenium 3) test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function takeScreenShot(optionalFileNameFragment) { | |
return browser.takeScreenshot().then(function (pngData) { | |
var fragment = '' + (optionalFileNameFragment || "screenshot"); | |
var now = new Date(); | |
var fullName = fragment + "-" + now.toISOString() + ".png"; | |
var fullPath = (process.env.CIRCLE_ARTIFACTS || "/tmp") + "/" + fullName; | |
var stream = fs.createWriteStream(fullPath); | |
stream.write(new Buffer(pngData, 'base64')); | |
stream.end(); | |
console.log("wrote screenshot: " + fullPath) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment