Cucumber Playwright
Testing & Qualitycucumber-playwrightCucumber Playwright is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Cucumber BDD with Playwright policies. Use when writing Gherkin scenarios with Playwright step definitions. Do NOT use for Cypress-based BDD -- use cucumber-cypress instead. Do NOT use for non-BDD Playwright tests.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/testing/cucumber-playwright/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/cucumber-playwright, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Cucumber + Playwright Policies
Use @cucumber/cucumber with @playwright/test for BDD E2E testing.
Project Structure
features/*.feature
step_definitions/*.steps.ts
support/
├── hooks.ts # Browser lifecycle
├── world.ts # Shared page context
cucumber.js
World Object (REQUIRED)
Share Playwright page across steps:
// support/world.ts
import { setWorldConstructor, World } from '@cucumber/cucumber'
import { BrowserContext, Page } from '@playwright/test'
export class PlaywrightWorld extends World {
context!: BrowserContext
page!: Page
}
setWorldConstructor(PlaywrightWorld)
Hooks for Browser Lifecycle
// support/hooks.ts
import { Before, After, BeforeAll, AfterAll } from '@cucumber/cucumber'
import { chromium, Browser } from '@playwright/test'
let browser: Browser
BeforeAll(async () => { browser = await chromium.launch() })
AfterAll(async () => { await browser.close() })
Before(async function (this: PlaywrightWorld) {
this.context = await browser.newContext()
this.page = await this.context.newPage()
})
After(async function (this: PlaywrightWorld) {
await this.context.close()
})
Step Definition Policies
Use Semantic Selectors
// GOOD: Role-based
await this.page.getByRole('button', { name: 'Login' }).click()
await this.page.getByTestId('email-input').fill(email)
// BAD: CSS selectors
await this.page.click('.btn-submit')
Always Type this as PlaywrightWorld
Given('I am on the login page', async function (this: PlaywrightWorld) {
await this.page.goto('/login')
})
Use Playwright Assertions
import { expect } from '@playwright/test'
await expect(this.page).toHaveURL('/dashboard')
await expect(this.page.getByText(message)).toBeVisible()
Commands
npx cucumber-js
npx cucumber-js --tags "@smoke"
npx cucumber-js features/login.feature
Configuration
For setup details, use context7 to query @cucumber/cucumber documentation.