Project | Web & API

Playwright for Java Framework

Annotation-based page factory, a browser per thread and a context per test, API tests with their own data clean-up, and a trace, video and screenshot kept for every failed UI test.

57 UI, API and network tests, run in CI on Chromium, Firefox and WebKit (one job per browser engine).

On this page
  1. Problem and purpose
  2. Architecture
  3. Technology and tools
  4. Engineering decisions and approach
  5. Test scope and execution approach
  6. Results with dated evidence
  7. Evidence explorer
  8. Local setup and execution
  9. Workflow and reports
  10. Known limitations

Problem and purpose

Shows Playwright in a Java/TestNG stack, the combination many Java teams move to from Selenium: UI tests on Pattern Shop (my own demo shop, started from its Docker image in CI), API tests on Restful Booker through Playwright's own request context, and network control in the browser.

Architecture

tests (ui, api, network, interview, framework)
      │
pages (PageFactory: @TestId, @Role, @Placeholder ...)     api (ApiClient, BookingApi, records)
      │                                                     │
BrowserManager: Playwright + browser per thread,     Playwright APIRequestContext
context per test, trace + video
      │
Chromium / Firefox / WebKit

Technology and tools

AreaTools
LanguageJava 17
Browser and API automationPlaywright for Java 1.63 (Chromium, Firefox, WebKit; APIRequestContext)
Test runnerTestNG 7.12 (groups, data providers, parallel classes)
JSONJackson (Java records)
ReportCustom TestNG IReporter: one HTML file with screenshots, videos and traces
CIGitHub Actions: one job per browser engine

Engineering decisions and approach

  • One Playwright and browser per thread, a fresh BrowserContext per test: isolated, fast, safe for parallel classes
  • An annotation-based page factory gives Selenium-style declarative locators; Playwright locators are lazy already
  • No waits in tests: Playwright auto-waits, and pages only wait for one element unique to the page
  • API tests create their own bookings and delete them afterwards, so the shared demo API is left as it was
  • Login failures throw the shop's own message at once instead of timing out

Test scope and execution approach

Project-specific checks and execution details documented in the repository:

  • UI: login (including 5 data-driven rejections), sorting, cart, full checkout with total = item total + tax
  • API: auth, create, read, update, patch and delete bookings, 403 and 404 cases
  • Network: images blocked, no failing requests while shopping, mocked responses
  • Every UI test records a trace and a video; both are kept, with a full-page screenshot, only when the test fails

Results with dated evidence

Historical repository or workflow evidence

Tests run #47 on main (57 tests on each browser)

57 UI, API and network tests, run in CI on Chromium, Firefox and WebKit (one job per browser engine).

Evidence checked: | Open dated evidence

Evidence explorer

Static screenshots are labelled as images; dated workflow links identify the execution evidence and its check date.

Test report screenshot. The custom HTML report (this run includes the deliberate demo failures). Static image; capture date is not recorded in the portfolio data.
Playwright for Java HTML report

Test report screenshot. The custom HTML report (this run includes the deliberate demo failures). Static image; capture date is not recorded in the portfolio data.

Static material from the public repository. The linked verification record was checked 2026-11-19; that date is not a screenshot capture date.

Dated workflow record

Evidence checked 2026-11-19. Open Tests run #47 on main (57 tests on each browser)

Local setup and execution

mvn exec:java -Dexec.args="install"   # once: download Chromium, Firefox and WebKit
mvn clean test                        # all tests, headless Chromium
mvn clean test -Dbrowser=firefox      # chromium, firefox or webkit
mvn clean test -Dgroups=api           # one group

Workflow and reports

View workflow definition.

Known limitations

  • The API tests depend on a public demo API (Restful Booker); the UI tests run against Pattern Shop in CI
  • The report screenshots come from local runs; CI keeps each browser's report as an artifact
  • Evidence describes the public portfolio repository and its linked CI runs, not customer production impact.

Back to Projects