feat(java): add Playwright Java examples for axe Watcher 4.4.0#275
Merged
Conversation
Watcher 4.4.0 adds Playwright Java support, so this adds runnable JUnit 5 example projects mirroring the existing java/selenium layout. Three Maven projects under java/playwright cover the integration's core scenarios: basic (auto analysis via wrapPage), manual-mode (setAutoAnalyze(false) with analyze/start/stop), and context-wrapping (wrapContext so every page from one BrowserContext is instrumented). Each depends on com.microsoft.playwright:playwright 1.60.0 and com.deque.axe_core:watcher 4.4.0, reads API_KEY/PROJECT_ID/SERVER_URL from the environment like the rest of the repo, and drives the-internet.herokuapp.com. A new java-smoke-tests job in the Tests workflow keeps the samples green: it sets up Temurin 17, installs Chrome via the existing install-chrome action, and runs `mvn -B test` against each project. The examples launch headless with an explicit Chromium-based channel (chrome + CHROME_BIN in CI, bundled chromium locally) because axe Watcher's extension cannot load in classic/default headless mode; this mirrors the watcher package's own Playwright e2e setup, including PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD so CI reuses the runner's Chrome rather than downloading a browser. java/playwright/README.md documents prerequisites and run steps, the root README points to it, and a top-level `permissions: contents: read` is added to the workflow. The example projects build with Java 11 (a modern LTS) rather than 8; the axe Watcher integration itself supports Java 8+, which the README notes. Supply-chain hardening of the Maven step (checksum/lock, environment-gated secrets) is intentionally left to match the existing JS smoke-tests job rather than expanded here. Closes #274 ## QA Notes From an example directory (e.g. java/playwright/basic), with API_KEY and PROJECT_ID exported, run `mvn test` and confirm the suite passes and a page state appears in the axe Developer Hub project. Without CHROME_BIN set, first run `mvn exec:java -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install chromium"`. Niche cases to exercise manually: - No CHROME_BIN: the example falls back to channel "chromium" (Playwright's bundled browser) -- verify it still launches. - Missing credentials (e.g. a fork PR without secrets): the run reaches flush() and fails at upload, not at setup. - setHeadless(false): confirm the test runs in a visible window.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds runnable Playwright Java + JUnit 5 example projects for axe Watcher 4.4.0, mirroring the existing Java/Selenium examples, and wires them into CI via a new Java smoke-test job.
Changes:
- Add three Maven/JUnit 5 Playwright Java sample projects (basic auto-analysis, manual mode, context wrapping).
- Add documentation for running the new Playwright Java samples and link to it from the root README.
- Extend the GitHub Actions test workflow with a Java smoke-test matrix.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Links to the new Java/Playwright examples and explains Maven-based execution. |
| java/playwright/README.md | Documents prerequisites and run steps for the Playwright Java sample projects. |
| java/playwright/basic/src/test/java/com/deque/watcher_examples/playwright/BasicTest.java | Basic auto-analysis example using wrapPage() and per-test flush. |
| java/playwright/manual-mode/src/test/java/com/deque/watcher_examples/playwright/ManualModeTest.java | Manual mode example using setAutoAnalyze(false) with explicit analyze/start/stop. |
| java/playwright/context-wrapping/src/test/java/com/deque/watcher_examples/playwright/ContextWrappingTest.java | Context-wrapping example using wrapContext() and multi-page navigation. |
| java/playwright/basic/pom.xml | Maven config for the basic Playwright Java example (Playwright + watcher + JUnit). |
| java/playwright/manual-mode/pom.xml | Maven config for the manual-mode Playwright Java example. |
| java/playwright/context-wrapping/pom.xml | Maven config for the context-wrapping Playwright Java example. |
| .github/workflows/test.yml | Adds workflow permissions and a new java-smoke-tests matrix job running mvn test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ContextWrappingTest sampled `homePage.locator("ul li a").count()`
immediately after navigate(). Playwright's count() does not auto-wait,
so on a slow render it could read the link list before it finished
attaching and assert a count below the threshold. Wait for the first
link with waitFor() before counting; the >= 20 assertion still does
real work since waitFor() only proves one link exists.
Also clarifies the Playwright Java README: the projects target Java 11
source compatibility but are tested on Java 17 in CI (the prior wording
said only "build with Java 11"), and the bundled-Chromium install
command drops its `-e` flag to match the identical command shown in the
example source comments.
These address Copilot and documentation-review feedback on PR #275.
## QA Notes
Run `mvn test` in java/playwright/context-wrapping with API_KEY and
PROJECT_ID set and confirm the suite passes and the home-page link
count assertion still holds.
Niche cases to exercise manually:
- A slow/throttled network: waitFor() should block until the link list
renders rather than asserting on a partial count.
scottmries
previously requested changes
Jun 22, 2026
scottmries
left a comment
Contributor
There was a problem hiding this comment.
I would take this over the other PR with these tests, but can we include its MultiPageTest, too?
Bring over the multi-page test from #273 as a fourth Playwright Java example: one wrapped page reused across the home, login, and forgot-password pages, with assertions grouped by page via @nested and a flush after each test. Adapt the setup to match the other Java/Playwright examples (env-var credentials, CHROME_BIN channel selection, debug logger) and wait for the link list before count() so the assertion is not raced. Wire the example into the java-smoke-tests matrix and the README table. Co-authored-by: Jonathan Garbee <jonathan.garbee@deque.com>
scottmries
approved these changes
Jun 23, 2026
Member
Author
|
Lint is just the JS side. So I'm bypassing this since the lint check failed to run. Going to fix that separately with a new event. And probably add Java linting as well so all that is consistent too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Watcher 4.4.0 adds Playwright Java support, so this adds runnable
JUnit 5 example projects mirroring the existing java/selenium layout.
Three Maven projects under java/playwright cover the integration's core
scenarios: basic (auto analysis via wrapPage), manual-mode
(setAutoAnalyze(false) with analyze/start/stop), and context-wrapping
(wrapContext so every page from one BrowserContext is instrumented).
Each depends on com.microsoft.playwright:playwright 1.60.0 and
com.deque.axe_core:watcher 4.4.0, reads API_KEY/PROJECT_ID/SERVER_URL
from the environment like the rest of the repo, and drives
the-internet.herokuapp.com.
A new java-smoke-tests job in the Tests workflow keeps the samples
green: it sets up Temurin 17, installs Chrome via the existing
install-chrome action, and runs
mvn -B testagainst each project. Theexamples launch headless with an explicit Chromium-based channel (chrome
extension cannot load in classic/default headless mode; this mirrors the
watcher package's own Playwright e2e setup, including
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD so CI reuses the runner's Chrome rather
than downloading a browser. java/playwright/README.md documents
prerequisites and run steps, the root README points to it, and a
top-level
permissions: contents: readis added to the workflow.The example projects build with Java 11 (a modern LTS) rather than 8;
the axe Watcher integration itself supports Java 8+, which the README
notes. Supply-chain hardening of the Maven step (checksum/lock,
environment-gated secrets) is intentionally left to match the existing
JS smoke-tests job rather than expanded here.
QA Notes
From an example directory (e.g. java/playwright/basic), with API_KEY and
PROJECT_ID exported, run
mvn testand confirm the suite passes and apage state appears in the axe Developer Hub project. Without CHROME_BIN
set, first run
mvn exec:java -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install chromium".Niche cases to exercise manually:
(Playwright's bundled browser) -- verify it still launches.
flush() and fails at upload, not at setup.
Closes: #274