Guest User

Untitled

a guest
Jan 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var webdriver = require('selenium-webdriver'),
  2. By = webdriver.By,
  3. until = webdriver.until,
  4. logging = webdriver.logging;
  5. const fs = require('fs');
  6. const path = require('path');
  7.  
  8.  
  9. // Take a screenshot.
  10. // state contains the Selenium driver instance and the config with the default path.
  11. // name is the filename (relative)
  12. function takeScreenshot(state, name) {
  13. return state
  14. .driver.takeScreenshot()
  15. .then(base64PngImage => {
  16. return state.driver.getCurrentUrl()
  17. .then(u => {
  18. let fname = path.join(state.config.screenshotPath, name);
  19. console.info("Writing screenshot: " + fname);
  20. fs.writeFileSync(fname, base64PngImage, 'base64');
  21. });
  22. })
  23. .then(_ => state);
  24. }
Add Comment
Please, Sign In to add comment