AI PROMPT LIBRARY

Automation Script Creation.

Prompt templates for generating test automation scripts in popular frameworks — Playwright, Cypress, REST Assured, axe-core, k6, and more. Each prompt produces a reviewed starting draft, not production-ready code. Each prompt is a starting draft. Fill in the {{VARIABLES}}, review the output, and keep human ownership of the final result.

5
prompts

Review every output. AI-generated code, test cases, and bug reports require human verification before use. Never paste secrets, credentials, or personal data into any AI tool.

Generate Playwright TypeScript Tests for a Feature

Generate a complete Playwright TypeScript test file for a given feature, covering positive, negative, and edge cases with role-based locators and no hard waits.

intermediate
Automation QA, SDET, DeveloperPlaywrightWorks with: Claude, ChatGPT, Gemini, Copilot, Cursor
playwrighttypescripte2eautomationtest-generation
prompt template
You are a senior QA automation engineer with deep expertise in Playwright and TypeScript. Before writing any code, briefly state your assumptions about the feature, then generate a Playwright TypeScript test file.

Feature to test: {{FEATURE_NAME}}
Application URL: {{APP_URL}}
User roles involved: {{USER_ROLES}}
Acceptance criteria:
{{ACCEPTANCE_CRITERIA}}

Test data available:
{{TEST_DATA}}

Known selectors or data-testid attributes (leave blank if unknown):
{{KNOWN_SELECTORS}}

Requirements for the generated tests:
- Use role-based locators (getByRole, getByLabel, getByText) as the first choice; use data-testid attributes as the second choice; avoid CSS class or XPath selectors.
- Cover at minimum: positive (happy path), negative (invalid input / unauthorised access), and edge cases (boundary values, empty states, concurrent actions if relevant).
- Do NOT use hard waits (page.waitForTimeout). Use Playwright auto-waiting and explicit expect assertions instead.
- Each test must have a clear, human-readable name describing what it verifies and what the expected outcome is.
- Group related tests using describe blocks named after the acceptance criteria or user role they cover.
- Extract repeated selectors and test data into constants at the top of the file.
- Add a short comment above each test explaining what scenario it covers and why it matters (one line only).
- If you have to guess at a selector because {{KNOWN_SELECTORS}} is empty, call it out with a TODO comment so a human can verify it.

Output format:
1. A brief "Assumptions" section listing anything you inferred that the team should verify.
2. The complete TypeScript test file, ready to save as a .spec.ts file.

Generate Cypress Tests for a Feature

Generate a Cypress test file (JavaScript or TypeScript) for a given feature, covering happy path, negative, and edge cases using Cypress best practices.

intermediate
Automation QA, SDET, DeveloperCypressWorks with: Claude, ChatGPT, Gemini, Copilot, Cursor
cypressjavascripttypescripte2eautomation
prompt template
You are a senior QA automation engineer with deep Cypress expertise. Before generating code, state your assumptions explicitly. Then generate a Cypress test file.

Feature to test: {{FEATURE_NAME}}
Base URL: {{BASE_URL}}
Language preference: {{LANGUAGE}} (javascript or typescript)
User roles: {{USER_ROLES}}
Acceptance criteria:
{{ACCEPTANCE_CRITERIA}}

Test data (use synthetic/fake values only — never real user data):
{{TEST_DATA}}

Known selectors or data-cy attributes (leave blank if unknown):
{{KNOWN_SELECTORS}}

Requirements:
- Use cy.get('[data-cy="..."]') as first preference for selectors; fall back to cy.contains() or ARIA-based queries via @testing-library/cypress if installed.
- Do NOT use arbitrary cy.wait(number) calls. Use cy.intercept() to wait for network requests, and Cypress built-in retry-ability for DOM assertions.
- Cover at minimum: positive (happy path), negative (invalid input, unauthorised access), and at least two edge cases.
- Wrap logically related tests in describe() blocks named after the scenario or user role.
- Use beforeEach() for shared setup (navigation, login state).
- If a selector is unknown, add a // TODO: verify selector comment so a human knows to check it.
- List your assumptions before the code block.

Output:
1. An "Assumptions" section.
2. The complete Cypress test file.

Generate REST Assured API Tests

Generate a REST Assured (Java) test class covering happy-path, negative, and schema-validation scenarios for a given API endpoint.

intermediate
Automation QA, SDET, DeveloperREST AssuredPostmanKarateWorks with: Claude, ChatGPT, Gemini, Copilot, Cursor
rest-assuredjavaapi-testingautomation
prompt template
You are a senior QA automation engineer specialising in REST Assured and Java API testing. Before generating code, state your assumptions. Then generate a REST Assured test class.

Endpoint to test: {{HTTP_METHOD}} {{ENDPOINT_PATH}}
Base URL / environment: {{BASE_URL}}
Authentication mechanism: {{AUTH_MECHANISM}}
Request body schema (JSON or description):
{{REQUEST_SCHEMA}}

Response body schema (JSON or description):
{{RESPONSE_SCHEMA}}

Business rules and acceptance criteria:
{{ACCEPTANCE_CRITERIA}}

Test data (synthetic only — no real credentials or PII):
{{TEST_DATA}}

Requirements:
- Use REST Assured's given/when/then fluent DSL.
- Cover: 200-range happy path, 4xx error cases (invalid input, missing fields, unauthorised), and at least one schema validation test using JSON Schema validation or Hamcrest matchers.
- Extract base URL, authentication headers, and shared request specs into a BaseApiTest class or RequestSpecification constant.
- Mark tests with JUnit 5 (@Test) and group them in a describe-equivalent structure using @Nested classes.
- Do NOT hardcode secrets. Use System.getenv() or a properties file reference for tokens and passwords, and add a comment explaining where to set them.
- If request or response schema details are incomplete, add TODO comments for a human to fill in.

Output:
1. An "Assumptions" section.
2. The complete Java test class.

Generate axe-core Accessibility Tests

Generate Playwright + axe-core TypeScript tests to catch automated accessibility violations on key pages, with instructions for interpreting and triage-ing results.

beginner
Automation QA, SDET, Developeraxe-corePlaywrightWorks with: Claude, ChatGPT, Gemini, Copilot, Cursor
accessibilityaxe-coreplaywrightwcagautomationa11y
prompt template
You are a senior QA automation engineer with expertise in web accessibility and axe-core integration. Generate Playwright TypeScript tests that run axe-core accessibility scans.

Pages / components to test: {{PAGES_OR_COMPONENTS}}
Application base URL: {{BASE_URL}}
WCAG level to target: {{WCAG_LEVEL}} (e.g. WCAG 2.1 AA)
Any known violations to exclude from the scan (if suppressed with justification): {{KNOWN_EXCLUSIONS}}
Auth required before testing? {{AUTH_REQUIRED}}
Auth user type for testing: {{AUTH_USER}}

Requirements:
- Install @axe-core/playwright (AxeBuilder) via import — do not use axe-playwright (deprecated).
- Run a full-page axe scan on each specified page after navigation and any required auth setup.
- Where a component or interactive state is specified (e.g. an open modal, an expanded accordion), include the interaction steps before the scan.
- Assert that violations.length === 0 with a custom error message that prints the first violation summary to help debug failures.
- Group tests by page in describe() blocks.
- Add a comment explaining that axe-core catches ~30–40% of WCAG issues — manual testing with a screen reader is still required for full coverage.
- Do NOT silence violations using disableRules() unless the caller passes them in {{KNOWN_EXCLUSIONS}} with a justification comment.
- List your assumptions before the code.

Output:
1. An "Assumptions" section.
2. The complete TypeScript test file using @axe-core/playwright.

Generate a k6 Smoke Test for an API or Page

Generate a k6 smoke test script that validates core functionality under a minimal load before a production deploy or load test run.

beginner
Automation QA, SDET, Developerk6Works with: Claude, ChatGPT, Gemini, Copilot, Cursor
k6performancesmoke-testapi-testingload-testing
prompt template
You are a senior performance engineer with expert knowledge of k6. Generate a k6 smoke test script in JavaScript.

Target endpoints or user flows: {{ENDPOINTS_OR_FLOWS}}
Base URL: {{BASE_URL}}
Authentication: {{AUTH_MECHANISM}}
Expected response time threshold (p95): {{RESPONSE_TIME_THRESHOLD}} ms
Acceptable error rate: {{ERROR_RATE_THRESHOLD}} (e.g. 0% or <1%)
Duration for smoke test: {{DURATION}} (e.g. 30s, 1m)
Virtual users for smoke test: {{VUS}} (smoke tests typically use 1–5 VUs)

Requirements:
- Define k6 options with the smoke-test thresholds (http_req_failed rate and http_req_duration p95).
- Use checks() to assert HTTP status codes and key response body fields for each request.
- Extract the base URL and auth token into variables using __ENV so they can be injected from CI without hardcoding secrets.
- Group related requests using group() blocks named after the user flow or feature.
- Add a brief summary comment at the top explaining this is a smoke test (minimal load, sanity-check purpose) distinct from a load test.
- If the endpoint requires a multi-step flow (e.g. auth then action), model the steps in sequence with appropriate assertions at each step.
- Do NOT hardcode tokens or passwords. Use __ENV.API_TOKEN with a comment explaining how to set it.
- List assumptions before the code.

Output:
1. An "Assumptions" section.
2. The complete k6 smoke test script (.js file).