|
12 | 12 | CONTAINER_ID = getenv("CONTAINER_ID", "test") |
13 | 13 | JUPYTER_HOST = getenv("JUPYTER_HOST", "http://localhost:8888") |
14 | 14 | JUPYTER_TOKEN = getenv("JUPYTER_TOKEN", "secret") |
| 15 | +VNCSERVER = getenv("VNCSERVER") |
15 | 16 |
|
16 | 17 |
|
17 | | -def compare_screenshot(test_image, threshold=2): |
| 18 | +def compare_screenshot(test_image): |
18 | 19 | # Compare images by calculating the mean absolute difference |
19 | 20 | # Images must be the same size |
20 | 21 | # threshold: Average difference per pixel, this depends on the image type |
21 | 22 | # e.g. for 24 bit images (8 bit RGB pixels) threshold=1 means a maximum |
22 | 23 | # difference of 1 bit per pixel per channel |
23 | 24 | reference = Image.open(HERE / "reference" / "desktop.png") |
| 25 | + threshold = 2 |
| 26 | + if VNCSERVER == "turbovnc": |
| 27 | + reference = Image.open(HERE / "reference" / "desktop-turbovnc.png") |
| 28 | + # The TurboVNC screenshot varies a lot more than TigerVNC |
| 29 | + threshold = 6 |
24 | 30 | test = Image.open(test_image) |
25 | 31 |
|
26 | 32 | # Absolute difference |
@@ -53,7 +59,7 @@ def test_desktop(browser): |
53 | 59 | page1.wait_for_timeout(5000) |
54 | 60 | # Use a non temporary folder so we can check it manually if necessary |
55 | 61 | screenshot = Path("screenshots") / "desktop.png" |
56 | | - page1.locator("canvas").screenshot(path=screenshot) |
| 62 | + page1.locator("body").screenshot(path=screenshot) |
57 | 63 |
|
58 | 64 | # Open clipboard, enter random text, close clipboard |
59 | 65 | clipboard_text = str(uuid4()) |
|
0 commit comments