Skip to content

Commit

Permalink
Screenshot whole body, not just canvas
Browse files Browse the repository at this point in the history
Separate screenshots for turbovnc and tigervnc
  • Loading branch information
manics committed Sep 14, 2024
1 parent e82cb60 commit f5a1fb0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
export CONTAINER_ID=$container_id
export JUPYTER_HOST=http://localhost:8888
export JUPYTER_TOKEN=secret
export VNCSERVER=${{ matrix.vncserver }}
python -mpytest -vs
Expand Down
Binary file added tests/reference/desktop-turbovnc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/reference/desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CONTAINER_ID = getenv("CONTAINER_ID", "test")
JUPYTER_HOST = getenv("JUPYTER_HOST", "http://localhost:8888")
JUPYTER_TOKEN = getenv("JUPYTER_TOKEN", "secret")
VNCSERVER = getenv("VNCSERVER")


def compare_screenshot(test_image, threshold=2):
Expand All @@ -21,6 +22,8 @@ def compare_screenshot(test_image, threshold=2):
# e.g. for 24 bit images (8 bit RGB pixels) threshold=1 means a maximum
# difference of 1 bit per pixel per channel
reference = Image.open(HERE / "reference" / "desktop.png")
if VNCSERVER == "turbovnc":
reference = Image.open(HERE / "reference" / "desktop-turbovnc.png")
test = Image.open(test_image)

# Absolute difference
Expand Down Expand Up @@ -53,7 +56,7 @@ def test_desktop(browser):
page1.wait_for_timeout(5000)
# Use a non temporary folder so we can check it manually if necessary
screenshot = Path("screenshots") / "desktop.png"
page1.locator("canvas").screenshot(path=screenshot)
page1.locator("body").screenshot(path=screenshot)

# Open clipboard, enter random text, close clipboard
clipboard_text = str(uuid4())
Expand Down

0 comments on commit f5a1fb0

Please sign in to comment.