Companion examples and benchmarks for the Screenshot Scout article How to Take Website Screenshots in Java (Benchmarked).
The project has two parts:
- copy-pasteable examples for Playwright, Selenium, Jvppeteer, and Screenshot Scout;
- reproducible benchmark runners for performance and reliability screenshots.
Install JDK 17 or newer and Maven. Dependencies are pinned in pom.xml for reproducible examples and benchmark runs.
Install Playwright Chromium:
mvn compile exec:java "-Dexec.mainClass=com.microsoft.playwright.CLI" "-Dexec.args=install chromium"Selenium benchmark runs use Selenium Manager to force-download Chrome for Testing major version 149 instead of using the machine's installed Chrome. Jvppeteer benchmark runs use Jvppeteer's managed Chrome for Testing version.
Screenshot Scout examples and benchmarks require an access key.
On Windows PowerShell:
$env:SCREENSHOT_SCOUT_ACCESS_KEY = "your_access_key"On macOS/Linux:
export SCREENSHOT_SCOUT_ACCESS_KEY=your_access_keyEach example is standalone and designed to appear verbatim in the article.
mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.examples.playwright.Screenshot"
mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.examples.playwright.FullPageScreenshot"
mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.examples.playwright.ElementScreenshot"mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.benchmarks.BenchmarkRun"The combined benchmark command creates one timestamped run folder and runs both performance measurements and reliability screenshot capture into it.
Performance measurements use cold starts: launch, capture, close. The runner records wall time, peak local RAM, and local CPU-seconds by sampling the worker process tree with OSHI.
By default, performance runs benchmark normal viewport screenshots. Optional --performance-kind full_page and --performance-kind selector modes are available for exploratory measurements; selector mode uses selector from manifests/performance.toml.
Screenshot Scout rendering happens on Screenshot Scout infrastructure, so local CPU/RAM numbers represent only client-side request handling. Wall time still measures how long the screenshot request takes from start to finish.
The reliability runner captures each configured page once per tool and saves screenshots under runs/<timestamp>/screenshots/reliability/. It does not grade pass/fail.
Reliability runs also write runs/<timestamp>/results/reliability_raw.csv for manual grading. After filling the result column, run:
mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.benchmarks.reliability.Summarize" "-Dexec.args=runs/<timestamp>/results/reliability_raw.csv"The benchmark can also run in Docker:
docker build -t java-screenshot-benchmarks .
docker run --rm -it --shm-size=2g -e SCREENSHOT_SCOUT_ACCESS_KEY="$SCREENSHOT_SCOUT_ACCESS_KEY" -v "$PWD/runs:/app/runs" java-screenshot-benchmarks
mvn compile exec:java "-Dexec.mainClass=com.screenshotscout.benchmarks.BenchmarkRun"Local browser-library ad and cookie-banner cleanup benchmarks use uBlock Origin Lite. The benchmark downloads a pinned official uBOL release into .cache/ on first use and loads it as an unpacked extension. The extension is not committed to this repository.
Each run writes:
runs/<timestamp>/
screenshots/
reliability/
results/
performance_raw.csv
performance_summary.csv
run_metadata.json
reliability_raw.csv
reliability_summary.csv # after manual grading and summarization