Skip to content

feat(java): add Playwright Java examples for axe Watcher 4.4.0#275

Merged
Garbee merged 4 commits into
mainfrom
garbee/playwright-examples
Jun 24, 2026
Merged

feat(java): add Playwright Java examples for axe Watcher 4.4.0#275
Garbee merged 4 commits into
mainfrom
garbee/playwright-examples

Conversation

@Garbee

@Garbee Garbee commented Jun 22, 2026

Copy link
Copy Markdown
Member

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.

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.

Closes: #274

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.
@Garbee Garbee self-assigned this Jun 22, 2026
@Garbee Garbee requested a review from Copilot June 22, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/test.yml
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@Garbee Garbee marked this pull request as ready for review June 22, 2026 18:27
@Garbee Garbee requested a review from a team as a code owner June 22, 2026 18:27

@scottmries scottmries left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Garbee Garbee requested a review from scottmries June 23, 2026 19:54
@Garbee Garbee enabled auto-merge (squash) June 23, 2026 19:54
@Garbee Garbee disabled auto-merge June 24, 2026 11:24
@Garbee

Garbee commented Jun 24, 2026

Copy link
Copy Markdown
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.

@Garbee Garbee merged commit 99f520a into main Jun 24, 2026
3 checks passed
@Garbee Garbee deleted the garbee/playwright-examples branch June 24, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Playwright Java Samples

4 participants