Featured project 3 · Java · Web + API
Playwright for Java Framework
UI, API and network test automation with Playwright for Java and TestNG: the Sauce Demo shop and the Restful Booker API, 57 tests run in CI on Chromium, Firefox and WebKit.
Purpose
Shows Playwright in a Java/TestNG stack, the combination many Java teams move to from Selenium: UI tests on Sauce Demo, API tests on Restful Booker through Playwright's own request context, and network control in the browser.
Technology stack
| 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 |
Architecture overview
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 / WebKitKey engineering decisions
- 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
Implemented features
- 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
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 groupSample test results

CI workflow
On every push and pull request: one job each for Chromium, Firefox and WebKit; each installs its browser with the Linux libraries it needs, runs the tests headless and keeps the HTML report plus any failure screenshots, videos and traces as an artifact.
Known limitations and future improvements
Limitations
- UI and API tests depend on public demo sites
- The README report screenshot shows a run that includes the deliberate demo failures (run with -Pdemo)
Next steps
- Publish the HTML report to GitHub Pages
- Visual comparison of key pages
