Created
June 7, 2016 14:12
-
-
Save OrganicPanda/5ed09da7c519543badf73fbbc786eddb to your computer and use it in GitHub Desktop.
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
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