summaryrefslogtreecommitdiff
path: root/tests/end2end/fixtures/quteprocess.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-02-10 19:28:33 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-02-10 20:00:23 +0100
commitddaa6262f6f3fff1919b777b23d0cd0964c9cad0 (patch)
tree1ffca6c6379942b92188b42d77c8bea46b41052c /tests/end2end/fixtures/quteprocess.py
parent478e4de7bd1f26bebdcdc166d5369b2b5142c3e2 (diff)
downloadqutebrowser-ddaa6262f6f3fff1919b777b23d0cd0964c9cad0.tar.gz
qutebrowser-ddaa6262f6f3fff1919b777b23d0cd0964c9cad0.zip
tests: Add first screenshot test for dark mode
See #2146
Diffstat (limited to 'tests/end2end/fixtures/quteprocess.py')
-rw-r--r--tests/end2end/fixtures/quteprocess.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index f5592ac9c..12c5adcf2 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -34,6 +34,7 @@ import json
import yaml
import pytest
from PyQt5.QtCore import pyqtSignal, QUrl
+from PyQt5.QtGui import QImage
from qutebrowser.misc import ipc
from qutebrowser.utils import log, utils, javascript
@@ -887,6 +888,17 @@ class QuteProc(testprocess.Process):
with open(path, 'r', encoding='utf-8') as f:
return f.read()
+ def get_screenshot(self):
+ """Get a screenshot of the current page."""
+ tmp_path = self.request.getfixturevalue('tmp_path')
+ path = tmp_path / 'screenshot.png'
+ self.send_cmd(f':screenshot --force {path}')
+ self.wait_for(message=f'Screenshot saved to {path}')
+
+ img = QImage(str(path))
+ assert not img.isNull()
+ return img
+
def press_keys(self, keys):
"""Press the given keys using :fake-key."""
self.send_cmd(':fake-key -g "{}"'.format(keys))