Skip to content

Commit 4ce3dfd

Browse files
committed
Add chromium fallback browser for e2e screenshot capture
Install chromium in the Docker container alongside google-chrome-stable. Update screenshot.sh to try google-chrome-stable, chromium, and chromium-browser in order, with screenshot size validation.
1 parent 91c0b83 commit 4ce3dfd

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

testing/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM ptrsr/pi-ci:latest
33
ENV LIBGUESTFS_BACKEND=direct
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
sshpass openssh-client curl socat imagemagick wget gnupg \
6+
sshpass openssh-client curl socat imagemagick wget gnupg chromium \
77
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
88
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
99
&& apt-get update && apt-get install -y --no-install-recommends google-chrome-stable \

testing/hooks/screenshot.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,34 @@ if [ "$WIZARD_READY" -eq 0 ]; then
3030
fi
3131

3232
HTTP_PORT="${QEMU_HTTP_PORT:-8080}"
33-
BROWSER_PATH=$(command -v google-chrome-stable 2>/dev/null || true)
33+
SCREENSHOT_TAKEN=0
34+
35+
for BROWSER in google-chrome-stable chromium chromium-browser; do
36+
BROWSER_PATH=$(command -v "$BROWSER" 2>/dev/null || true)
37+
[ -n "$BROWSER_PATH" ] || continue
3438

35-
if [ -n "$BROWSER_PATH" ]; then
3639
echo " Taking headless screenshot with $BROWSER_PATH ..."
37-
timeout 30 "$BROWSER_PATH" --headless=new --no-sandbox --disable-gpu \
40+
timeout 30 "$BROWSER_PATH" --headless --no-sandbox --disable-gpu \
3841
--disable-dev-shm-usage --virtual-time-budget=15000 \
3942
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
4043
--window-size=1280,720 \
41-
"http://localhost:${HTTP_PORT}" 2>&1 | tail -5 || true
44+
"http://localhost:${HTTP_PORT}" 2>/dev/null || true
45+
4246
if [ -f "$ARTIFACTS_DIR/screenshot.png" ]; then
4347
SIZE=$(stat -c%s "$ARTIFACTS_DIR/screenshot.png" 2>/dev/null || echo "0")
44-
echo " Screenshot saved (${SIZE} bytes)"
48+
if [ "$SIZE" -gt 10000 ]; then
49+
echo " Screenshot saved (${SIZE} bytes) -- wizard page captured"
50+
SCREENSHOT_TAKEN=1
51+
break
52+
else
53+
echo " WARNING: Screenshot is only ${SIZE} bytes (may be blank), trying next browser"
54+
rm -f "$ARTIFACTS_DIR/screenshot.png"
55+
fi
4556
else
46-
echo " Screenshot file was NOT created"
57+
echo " Screenshot file was NOT created by $BROWSER, trying next browser"
4758
fi
48-
else
49-
echo " No google-chrome-stable found in container"
59+
done
60+
61+
if [ "$SCREENSHOT_TAKEN" -eq 0 ]; then
62+
echo " WARNING: No browser produced a valid screenshot"
5063
fi

0 commit comments

Comments
 (0)