soygul / electron-chromedriver

Starter kit for testing Electron apps using ChromeDriver with Python bindings
MIT License
4 stars 1 forks source link

Taking screenshots don't work with Electron #4

Closed soygul closed 8 years ago

soygul commented 8 years ago

http://selenium-python.readthedocs.org/faq.html#how-to-take-screenshot-of-the-current-window

Issue discussed here: https://bugs.chromium.org/p/chromedriver/issues/detail?id=816

Looks like the solution is to make the Electron browser to navigate or refresh page at least once.

soygul commented 8 years ago

Alternative is to use this python script: https://github.com/ponty/pyscreenshot

soygul commented 8 years ago

Or call platform specific screenshot utility. On OS X:

from subprocess import call
call(["screencapture", "screenshot.jpg”])
soygul commented 8 years ago

This works from inside the electron-app:

// app.js
const screenshot = require('electron-screenshot');
function takeScreenshot(path) {
  screenshot({'filename': path});
}
# test.py
self.driver.execute_script("takeScreenshot(\'" + filepath + "\');")
soygul commented 8 years ago

Closing this as won't fix as it is an upstream vendor issue. Should be solved at Electron level if possible.