From ccafba78205c7a47c19e4645ccf8e767e40ead73 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 5 Jul 2024 21:52:15 +0100 Subject: [PATCH] Upload screenshot as artifact --- .github/workflows/test.yaml | 8 ++++++++ tests/test_browser.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c8163f4d..cd566067 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -84,6 +84,7 @@ jobs: export CONTAINER_ID=$container_id export JUPYTER_HOST=http://localhost:8888 export JUPYTER_TOKEN=secret + export SCREENSHOT_NAME=${{ matrix.vncserver }}-desktop.png python -mpytest -vs @@ -101,3 +102,10 @@ jobs: echo "One or more tests failed!" exit 1 fi + + - name: Upload screenshot + uses: actions/upload-artifact@v4 + if: always() + with: + path: screenshots/* + if-no-files-found: error diff --git a/tests/test_browser.py b/tests/test_browser.py index 292b59ad..11d5918d 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -12,6 +12,7 @@ CONTAINER_ID = getenv("CONTAINER_ID", "test") JUPYTER_HOST = getenv("JUPYTER_HOST", "http://localhost:8888") JUPYTER_TOKEN = getenv("JUPYTER_TOKEN", "secret") +SCREENSHOT_NAME = getenv("SCREENSHOT_NAME", "desktop.png") def compare_screenshot(test_image, threshold=1): @@ -51,8 +52,8 @@ def test_desktop(browser): # Screenshot the desktop element only # May take a few seconds to load page1.wait_for_timeout(5000) - # Use a nontemp folder so we can check it manually if necessary - screenshot = "screenshots/desktop.png" + # Use a non temporary folder so we can check it manually if necessary + screenshot = Path("screenshots") / SCREENSHOT_NAME page1.locator("canvas").screenshot(path=screenshot) # Open clipboard, enter random text, close clipboard