Skip to content

Commit c2cc14f

Browse files
committed
Fix e2e screenshot: skip snap stub, find real chromium binary
The base image has /usr/bin/chromium-browser as a snap wrapper stub that prints "requires the chromium snap". Now search for the actual chromium binary at /usr/lib/chromium/chromium first, skipping any snap stubs. Add diagnostic output if no working binary is found.
1 parent 68321d2 commit c2cc14f

1 file changed

Lines changed: 30 additions & 22 deletions

File tree

testing/hooks/screenshot.sh

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,36 @@ HTTP_PORT="${QEMU_HTTP_PORT:-8080}"
3434
echo " Checking forwarded port accessibility..."
3535
curl -s -o /dev/null -w " Port $HTTP_PORT -> HTTP %{http_code}\n" "http://localhost:${HTTP_PORT}" || echo " Port $HTTP_PORT not reachable"
3636

37-
for BROWSER in chromium chromium-browser; do
38-
BROWSER_PATH=$(command -v "$BROWSER" 2>/dev/null || true)
39-
if [ -n "$BROWSER_PATH" ]; then
40-
echo " Taking headless screenshot with $BROWSER_PATH ..."
41-
"$BROWSER_PATH" \
42-
--headless=new \
43-
--no-sandbox \
44-
--disable-gpu \
45-
--disable-software-rasterizer \
46-
--disable-dev-shm-usage \
47-
--virtual-time-budget=15000 \
48-
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
49-
--window-size=1280,720 \
50-
"http://localhost:${HTTP_PORT}" 2>&1 | tail -5 || true
51-
if [ -f "$ARTIFACTS_DIR/screenshot.png" ]; then
52-
echo " Screenshot saved to $ARTIFACTS_DIR/screenshot.png"
53-
ls -la "$ARTIFACTS_DIR/screenshot.png"
54-
exit 0
55-
else
56-
echo " Screenshot file was NOT created by $BROWSER"
57-
fi
37+
# Find real chromium binary (skip snap stubs that print "requires the chromium snap")
38+
BROWSER_PATH=""
39+
for candidate in /usr/lib/chromium/chromium /usr/bin/chromium /snap/bin/chromium; do
40+
if [ -x "$candidate" ] && ! "$candidate" --version 2>&1 | grep -q "snap"; then
41+
BROWSER_PATH="$candidate"
42+
break
5843
fi
5944
done
6045

61-
echo " No screenshot produced (headless browser may have failed)"
46+
if [ -n "$BROWSER_PATH" ]; then
47+
echo " Taking headless screenshot with $BROWSER_PATH ..."
48+
"$BROWSER_PATH" \
49+
--headless=new \
50+
--no-sandbox \
51+
--disable-gpu \
52+
--disable-software-rasterizer \
53+
--disable-dev-shm-usage \
54+
--virtual-time-budget=15000 \
55+
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
56+
--window-size=1280,720 \
57+
"http://localhost:${HTTP_PORT}" 2>&1 | tail -10 || true
58+
if [ -f "$ARTIFACTS_DIR/screenshot.png" ]; then
59+
echo " Screenshot saved to $ARTIFACTS_DIR/screenshot.png"
60+
ls -la "$ARTIFACTS_DIR/screenshot.png"
61+
else
62+
echo " Screenshot file was NOT created"
63+
fi
64+
else
65+
echo " No working chromium binary found. Checking available:"
66+
ls -la /usr/bin/chromium* /usr/lib/chromium/chromium 2>&1 || true
67+
echo " dpkg -l chromium:"
68+
dpkg -l chromium 2>&1 | tail -3 || true
69+
fi

0 commit comments

Comments
 (0)