sickn33/antigravity-awesome-skills/playwright-java
Claude Code and agent skill by sickn33/antigravity-awesome-skills
- community
Checking that the SKILL.md file is still in the repository.
Scaffold, write, debug, and enhance enterprise-grade Playwright E2E tests in Java using Page Object Model, JUnit 5, Allure reporting, and parallel execution.
Install
npx vskill@latest install sickn33/antigravity-awesome-skills/playwright-javaSKILL.md
Supporting material
The bundled files are configuration, page objects, assertions, fixtures, BaseTest.java and BasePage.java. Copy/adapt them into the target project with their dependencies; src/test/resources/junit-platform.properties below is a project file to create, not a bundled file.
Playwright Java – Advanced Test Automation
Overview
This skill supplies Playwright Java test patterns requiring project-specific compilation and execution. It enforces the Page Object Model (POM), strict locator strategies, per-thread Playwright ownership for parallel execution, and full Allure reporting integration. Targets Java 17+ and Playwright 1.44+.
Supporting reference files are available for deeper topics:
| Topic | File | |
|---|---|---|
| Maven POM, ConfigReader, Docker/CI setup | config.md | |
| Component pattern, dropdowns, uploads, waits | page-objects.md | |
| Full assertion API, soft assertions, visual testing | assertions.md | |
| Fixtures, test data factory, auth state, retry | fixtures.md | |
| Drop-in base class templates | BaseTest.java, BasePage.java |
When to Use This Skill
- Use when scaffolding a new Playwright Java project from scratch
- Use when writing Page Object classes or JUnit 5 test classes
- Use when the user asks about cross-browser testing, parallel execution, or Allure reports
- Use when fixing flaky tests or replacing
Thread.sleep()with proper waits - Use when setting up Playwright in CI/CD pipelines (GitHub Actions, Jenkins, Docker)
- Use when combining API calls and UI assertions in a single test (hybrid testing)
- Use when the user mentions "POM pattern", "BrowserContext", "Playwright fixtures", or "traces"
How It Works
Step 1: Decide the Approach
Use this matrix to pick the right pattern before writing any code:
| User Request | Approach | |
|---|---|---|
| New project from scratch | Full scaffold — see config.md | |
| Single feature test | POM page class + JUnit5 test class | |
| API + UI hybrid | APIRequestContext alongside Page | |
| Cross-browser | @MethodSource parameterized over browser names | |
| Flaky test fix | Replace sleep with waitFor / waitForResponse | |
| CI integration | playwright install --with-deps in pipeline | |
| Parallel execution | junit-platform.properties + ThreadLocal | |
| Rich reporting | Allure + Playwright trace + video recording |
Step 2: Scaffold the Project Structure
Always use this layout when creating a new project:
Step 3: Set Up Thread-Safe BaseTest
Use the bundled BaseTest.java, with the matching ConfigReader from config.md; it registers resources before fallible tracing/page creation and removes thread-local values during teardown.
Step 4: Build Page Object Classes
Step 5: Write Tests with Allure Annotations
Examples
Example 1: API + UI Hybrid Test
Example 2: Network Mocking
Example 3: Cross-Browser Execution
Run separate Maven processes/jobs with -Dbrowser=chromium, firefox and webkit. Do not set a process-global system property inside a parameterized test: setup already launched the browser and parallel tests race on that property. Give each job a unique artifact name.
Example 4: Parallel Execution Config
Example 5: GitHub Actions CI Pipeline
Use an authorized test origin and disposable test data/accounts. Order/API/UI actions can charge, send messages or delete records; block production integrations and clean up created records. Storage-state files contain credentials, and traces/screenshots/videos can contain secrets or personal data: restrict access, ignore in git, redact and bound retention before uploading. Pinned versions in the configuration are historical examples, not current recommendations; match Java dependency and browser/Docker versions.
Best Practices
- ✅ Use
ThreadLocal<Page>for every parallel-safe test suite - ✅ Declare all
Locatorfields at the top of the Page Object class - ✅ Return the next Page Object from navigation methods (fluent chaining)
- ✅ Use
assertThat(locator)— it auto-retries until timeout - ✅ Use
getByRole,getByLabel,getByTestIdas first-choice locators - ✅ Start tracing in
@BeforeEachand stop with a file path in@AfterEach - ✅ Use
SoftAssertionswhen validating multiple fields on a single page - ✅ Set up saved auth state (
storageState) to skip login across test classes - ❌ Never use
Thread.sleep()— replace withwaitFor()orwaitForResponse() - ❌ Never hardcode base URLs — always use
ConfigReader.getBaseUrl() - ❌ Never create a
Playwrightinstance inside a Page Object - ❌ Never use XPath for dynamic or frequently changing elements
Common Pitfalls
- Problem: Tests fail randomly in parallel mode
Solution: Ensure every test creates its own Playwright → Browser → BrowserContext → Page chain via ThreadLocal. Never share a Page across threads.
- Problem:
assertThat(locator).isVisible()times out even when the element appears
Solution: Inspect readiness/locator first; set the assertion-specific options timeout if justified. Assertions have a separate default (5 seconds); context action timeout does not change it.
- Problem:
Thread.sleep(2000)was added but tests are still flaky
Solution: Replace with page.waitForResponse("**/api/endpoint", () -> action()) or assertThat(locator).hasText("Done") which polls automatically.
- Problem: Playwright trace zip is empty or missing
Solution: Ensure tracing().start() is called before test actions and tracing().stop() is in @AfterEach — not @AfterAll.
- Problem: Allure report is blank or missing steps
Solution: Add the AspectJ agent to maven-surefire-plugin <argLine> in pom.xml — see config.md for the exact snippet.
- Problem:
storageStateauth file is stale and tests redirect to login
Solution: Re-run AuthSetup to regenerate target/auth/user-state.json before the suite, or add a @BeforeAll that conditionally refreshes it.
Related Skills
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/playwright-java/SKILL.md
Popularity
- Repository stars
- 26,510
- Repository forks
- 4,520
- Repository npm downloads, 7 days
- 6,478
- 7-day trend score
- 72
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 22 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sickn33/antigravity-awesome-skills/playwright-java)