Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OrganicPanda/5ed09da7c519543badf73fbbc786eddb to your computer and use it in GitHub Desktop.
Save OrganicPanda/5ed09da7c519543badf73fbbc786eddb to your computer and use it in GitHub Desktop.
const screenshot = (text = '') => {
const upload = filename => {
const util = require('util');
const exec = require('child_process').exec;
const command = 'curl -sbv ' +
'-H \'Content-Type: multipart/form-data\' ' +
'-H \'Accept: application/json\' ' +
'-F "file=@./' + filename + '" ' +
'-F "upload_preset=kzrkwuhx" ' +
'-F "public_id=' + filename + '" ' +
'https://api.cloudinary.com/v1_1/organicpanda/image/upload'
const child = exec(command, function(error, stdout, stderr) {});
};
// within a test:
return browser.takeScreenshot().then(function(png) {
let datetime = new Date().valueOf()
, filename = `screenshot${text ? '-' + text + '-' : ''}${datetime}.png`
, stream = fs.createWriteStream(filename);
stream.write(new Buffer(png, 'base64'));
stream.end();
return filename;
}).then(upload);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment