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).
Evidence checked 19 Nov 2026 | Tests run #47 on main (57 tests on each browser)
On this page
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 / WebKitTechnology and tools
| Area | Tools |
|---|---|
| Language | Java 17 |
| Browser and API automation | Playwright for Java 1.63 (Chromium, Firefox, WebKit; APIRequestContext) |
| Test runner | TestNG 7.12 (groups, data providers, parallel classes) |
| JSON | Jackson (Java records) |
| Report | Custom TestNG IReporter: one HTML file with screenshots, videos and traces |
| CI | GitHub 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.
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 groupWorkflow and reports
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.