Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var webdriver = require('selenium-webdriver'),
- By = webdriver.By,
- until = webdriver.until,
- logging = webdriver.logging;
- const fs = require('fs');
- const path = require('path');
- // Take a screenshot.
- // state contains the Selenium driver instance and the config with the default path.
- // name is the filename (relative)
- function takeScreenshot(state, name) {
- return state
- .driver.takeScreenshot()
- .then(base64PngImage => {
- return state.driver.getCurrentUrl()
- .then(u => {
- let fname = path.join(state.config.screenshotPath, name);
- console.info("Writing screenshot: " + fname);
- fs.writeFileSync(fname, base64PngImage, 'base64');
- });
- })
- .then(_ => state);
- }
Add Comment
Please, Sign In to add comment