Last active
October 14, 2016 22:40
-
-
Save emilong/404a8a4a63c1d81a9b20005110979103 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 colors = require('colors/safe'); | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| function captureLogs(filename) { | |
| const output = path.join(BROWSER_LOGS_DIR, filename); | |
| console.log(colors.red.bold('📜 capturing logs to'), output); | |
| return browser.manage().logs().get('browser').then(browserLog => { | |
| fs.writeFileSync(output, JSON.stringify(browserLog)); | |
| }); | |
| } | |
| function writeScreenshot(data, filename) { | |
| const output = path.join(SCREENSHOT_DIR, filename); | |
| console.log(colors.red.bold('📷 screenshotting to'), output); | |
| const stream = fs.createWriteStream(output); | |
| stream.write(Buffer.from(data, 'base64')); | |
| stream.end(); | |
| } | |
| function takeScreenshot(screenshotName) { | |
| return browser.takeScreenshot() | |
| .then(png => writeScreenshot(png, screenshotName)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment