AGENT SKILL

pw-test-generator

Generates a Playwright (TypeScript) test spec from a described user flow or scenario. Use when an SDET says "write a Playwright test for login", "generate a spec for the checkout flow", "turn this scenario into a test", or pastes acceptance criteria that need automating. Produces a runnable draft using role/testid locators and web-first assertions — the engineer still runs it.

License 许可
MIT
最近更新
2026-07-15
Stars
★ 4
Forks
8

01 前言 Front Matter

name
pw-test-generator
license
MIT
metadata
{ "pack": "playwright", "author": "TheTestingAcademy", "version": "1.0.0" }
description
Generates a Playwright (TypeScript) test spec from a described user flow or scenario. Use when an SDET says "write a Playwright test for login", "generate a spec for the checkout flow", "turn this scenario into a test", or pastes acceptance criteria that need automating. Produces a runnable draft using role/testid locators and web-first assertions — the engineer still runs it.

03 SKILL.md 正文

PW Test Generator

You draft a Playwright spec the engineer must still run and review — never a "finished" test. Your job is to translate a flow into resilient, best-practice code.

When to use

  • A user flow, scenario, or acceptance criteria is provided and needs a spec.
  • Someone says "write/generate a Playwright test for X".
  • A manual test case needs converting to automation.

Workflow

  1. Restate the flow as ordered steps (arrange → act → assert). Confirm the entry URL, the user role, and the observable success signal.
  2. Map each step to a locator strategy. Prefer getByRole (with accessible name), then getByLabel, then getByTestId. Flag any step where you had to guess a selector — mark it // TODO: confirm selector.
  3. Choose assertions. Use web-first, auto-retrying assertions (await expect(locator).toBeVisible(), toHaveText, toHaveURL). Assert the end state, not intermediate sleeps.
  4. Draft the spec with a clear test.describe, one test per scenario, and test.step() for readability. Reuse fixtures if the flow needs auth/data.
  5. List assumptions — selectors guessed, data needed, preconditions — so the engineer can verify before running.

Output shape

import { test, expect } from '@playwright/test';

test.describe('Checkout flow', () => {
  test('completes purchase with a valid card', async ({ page }) => {
    await test.step('open cart', async () => {
      await page.goto('/cart');
      await expect(page.getByRole('heading', { name: 'Your Cart' })).toBeVisible();
    });
    await test.step('checkout', async () => {
      await page.getByRole('button', { name: 'Checkout' }).click();
      await page.getByLabel('Card number').fill('4111111111111111');
      await page.getByRole('button', { name: 'Pay now' }).click();
    });
    await expect(page.getByTestId('order-confirmation')).toBeVisible();
  });
});

Guardrails

  • This is a draft the engineer must run and review — never assume a selector exists; mark every guessed locator with // TODO: confirm.
  • Never fabricate a data-testid, route, or accessible name you weren't shown.
  • No waitForTimeout, no networkidle, no manual sleeps — use web-first waits.
  • No XPath, no nth-child, no CSS-class selectors; role/testid/label only.
  • Assert observable state, not implementation details.

04 同仓库更多 Skills

PramodDutta
PramodDutta/skillmasterclass

se-wait-fixer

Scans Selenium Java code for Thread.sleep and for implicit+explicit wait mixing, then replaces them with WebDriverWait/ExpectedConditions or FluentWait to fix synchronization. Use when an SDET says "remove Thread.sleep from my tests", "fix the flaky waits", "my implicit and explicit waits conflict", or pastes code full of hard sleeps. Produces refactors the engineer must run and confirm.

★ 4
PramodDutta
PramodDutta/skillmasterclass

se-test-generator

Generates a runnable Selenium 4 + TestNG test in Java from a plain-language scenario, using explicit waits and stable locators. Use when an SDET says "write a Selenium test for login", "generate a TestNG test for the checkout flow", "automate this scenario in Selenium", or pastes Gherkin/steps and wants Java WebDriver code. Produces a draft test the engineer must review and run.

★ 4
PramodDutta
PramodDutta/skillmasterclass

se-report-integrator

Integrates reporting (Allure or ExtentReports) into a Selenium + TestNG suite with listeners, screenshot-on-failure, and step logging. Use when an SDET says "add Allure to my tests", "set up ExtentReports", "capture a screenshot on failure", "add a TestNG listener for reporting", or wants readable run reports. Produces listener and config code the engineer must run to generate a report.

★ 4
PramodDutta
PramodDutta/skillmasterclass

se-page-object-builder

Builds a Page Object Model class in Java (PageFactory @FindBy or explicit locators) with action methods and a WebDriverWait for a given page. Use when an SDET says "create a page object for the login page", "build a POM class", "refactor these locators into a page object", or pastes a page's fields and wants a reusable POM. Produces a draft class the engineer must review and run.

★ 4
PramodDutta
PramodDutta/skillmasterclass

se-locator-strategist

Recommends and repairs Selenium locator strategy — replaces brittle absolute XPath with By.id, By.cssSelector, or Selenium 4 relative locators, and explains the trade-offs. Use when an SDET says "this XPath keeps breaking", "make this locator more stable", "why is my locator flaky", "convert this XPath to CSS", or pastes selectors to harden. Produces proposals the engineer must verify in the DOM.

★ 4
PramodDutta
PramodDutta/skillmasterclass

se-grid-configurator

Configures Selenium Grid 4 (hub-and-node or standalone, including Docker) and wires RemoteWebDriver for parallel and distributed runs. Use when an SDET says "set up Selenium Grid", "run my tests on a remote grid", "dockerize Selenium Grid 4", "point my tests at RemoteWebDriver", or wants parallel execution across nodes. Produces config and code the engineer must run and validate in their environment.

★ 4