AI-assisted test automation
From acceptance criterion to Playwright test, result back in the ticket.
An acceptance criterion and a test case go to Claude Code. It writes a Playwright test with a page object. The test runs, and the result with a screenshot becomes a TestRail result and a Jira comment, ready to post.
The loop · run of 27 Nov 2026, 14:51
QA-214 through the whole loop
2 of 2 checks for QA-214 passed
-
1 · Ticket
QA-214, three acceptance criteria
- AC1 Invalid e-mail: message at the field
- AC2 Error linked to the field for screen readers
- AC3 No request is created
Plus TestRail case C1182 with three steps. Both invented for this sample.
-
2 · Instruction to Claude Code
Ticket and case in, rules for the test
Read ticket/QA-214.json and ticket/C1182.json. Write a Playwright test in TypeScript for C1182 against the support form at the app URL from the fixture. Use the page object in tests/pages/SupportFormPage.ts and extend it if needed. Locate elements by role, label or test id, never by CSS position.
Full instruction in the code section below.
-
3 · Generated test
Every criterion, its own assertions
- AC1
emailErrortoHaveText'Please enter a valid e-mail address.' - AC2
emailtoHaveAttributearia-invalidand toHaveAccessibleDescription - AC3
sentCounttoHaveText'0', no status message
Plus a counter-check with a valid e-mail. Page object, fixture, annotations for Jira and TestRail. Full file in the code section.
- AC1
-
4 · Result
Screenshot and two payloads

TestRail: status_id 1, elapsed 2s. Jira: comment on QA-214. Not sent, there is no TestRail or Jira account behind this sample.
Who does what: Claude Code writes the test from the ticket. I check every assertion against the criteria, run it, and decide what goes back into the ticket.
Measured: 6 tests, 5 passed, 1 failed as intended (the brittle selector below), 0 unexpected, 8.6 s. Playwright 1.64, Chrome.
The code
Real files, not pseudocode.
Playwright with TypeScript: the test that came out of the instruction, the page object and the fixture. Elements are found by role, label or test id. The excerpts are the files that ran.
import { test, expect } from './fixtures';
const tags = {
annotation: [
{ type: 'jira', description: 'QA-214' },
{ type: 'testrail', description: 'C1182' },
],
};
test.describe('QA-214 / C1182 support form rejects an invalid e-mail', () => {
test('invalid e-mail: error at the field, linked, no request', tags, async ({ supportForm }, testInfo) => {
await supportForm.open();
await supportForm.fill({ email: 'anna@example', category: 'Billing', message: 'My November invoice shows the wrong address.' });
await supportForm.send();
// AC1: the message is shown at the field
await expect(supportForm.emailError).toHaveText('Please enter a valid e-mail address.');
// AC2: the error is linked to the field, screen readers announce it
await expect(supportForm.email).toHaveAttribute('aria-invalid', 'true');
await expect(supportForm.email).toHaveAccessibleDescription('Please enter a valid e-mail address.');
// AC3: no request is created
await expect(supportForm.sentCount).toHaveText('0');
await expect(supportForm.status).toHaveCount(0);
const shot = testInfo.outputPath('qa-214.png');
await supportForm.page.getByRole('main').screenshot({ path: shot });
await testInfo.attach('qa-214', { path: shot, contentType: 'image/png' });
});
test('counter-check: a valid e-mail creates exactly one request', tags, async ({ supportForm }) => {
await supportForm.open();
await supportForm.fill({ email: 'anna@example.com', category: 'Billing', message: 'My November invoice shows the wrong address.' });
await supportForm.send();
await expect(supportForm.status).toHaveText(/^Request REQ-\d+ created$/);
await expect(supportForm.emailError).toHaveCount(0);
await expect(supportForm.sentCount).toHaveText('1');
});
});import type { Locator, Page } from '@playwright/test';
export type Layout = 'v1' | 'v2';
export class SupportFormPage {
readonly email: Locator;
readonly category: Locator;
readonly message: Locator;
readonly sendButton: Locator;
readonly emailError: Locator;
readonly status: Locator;
readonly sentCount: Locator;
constructor(readonly page: Page, private readonly url: string) {
this.email = page.getByLabel('E-mail', { exact: true });
this.category = page.getByLabel('Category', { exact: true });
this.message = page.getByLabel('Message', { exact: true });
this.sendButton = page.getByRole('button', { name: 'Send request' });
this.emailError = page.getByRole('alert');
this.status = page.getByRole('status');
this.sentCount = page.getByTestId('sent-count');
}
async open(layout: Layout = 'v1') {
await this.page.goto(layout === 'v2' ? `${this.url}?layout=v2` : this.url);
}
async fill(data: { email: string; category: string; message: string }) {
await this.email.fill(data.email);
await this.category.selectOption(data.category);
await this.message.fill(data.message);
}
async send() {
await this.sendButton.click();
}
}import { test as base, expect } from '@playwright/test';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { SupportFormPage } from './pages/SupportFormPage';
// Locally the demo app is opened as a file, no server needed. Live: APP_URL=https://ticket-test-probe.coreguard-karaman.com/app/
const defaultUrl = pathToFileURL(path.resolve(process.cwd(), '..', 'seite', 'app', 'index.html')).href;
export const test = base.extend<{ appUrl: string; supportForm: SupportFormPage }>({
appUrl: async ({}, use) => {
await use(process.env.APP_URL ?? defaultUrl);
},
supportForm: async ({ page, appUrl }, use) => {
await use(new SupportFormPage(page, appUrl));
},
});
export { expect };Read ticket/QA-214.json and ticket/C1182.json. Write a Playwright test in TypeScript for C1182 against the support form at the app URL from the fixture. Use the page object in tests/pages/SupportFormPage.ts and extend it if needed. Locate elements by role, label or test id, never by CSS position. Check every acceptance criterion with its own assertion and mark it with a comment (AC1, AC2, AC3). Add one counter-check with a valid e-mail. Tag the test with the Jira key and the TestRail case as annotations, and attach a screenshot of the final state. Do not change the app.
Stable selectors
The same check, one new field later.
Layout v2 adds a “Company” row at the top of the form, as a new feature would. The CSS position selector now fills the wrong field. Label and role still find the e-mail field.
Brittle · CSS position
await page.locator('form > div:nth-child(1) input').fill('anna@example');
- Layout v1passed
- Layout v2failed, as intended
Stable · label and role
await supportForm.email.fill('anna@example'); // email = page.getByLabel('E-mail', { exact: true })
- Layout v1passed
- Layout v2passed
See selectors.spec.ts
import { test, expect } from './fixtures';
// Same check twice: once with a CSS position selector, once with label and role.
// Layout v2 adds a "Company" row at the top of the form, as a new feature would.
for (const layout of ['v1', 'v2'] as const) {
test(`brittle: CSS position selector, layout ${layout}`, async ({ page, appUrl }) => {
test.fail(layout === 'v2', 'expected to break: the first row is no longer the e-mail field');
await page.goto(layout === 'v2' ? `${appUrl}?layout=v2` : appUrl);
await page.locator('form > div:nth-child(1) input').fill('anna@example');
await page.locator('form button').click();
await expect(page.locator('#email-error')).toHaveText('Please enter a valid e-mail address.');
});
test(`stable: label and role, layout ${layout}`, async ({ supportForm }) => {
await supportForm.open(layout);
await supportForm.email.fill('anna@example');
await supportForm.send();
await expect(supportForm.emailError).toHaveText('Please enter a valid e-mail address.');
});
}Cypress to Playwright
One test, two frameworks.
How the check often looks in an existing Cypress suite, next to its Playwright port. The Cypress version is an example for comparison and was not run.
Cypress · example, not run
// Comparison only, NOT run: how the same check often looks in an existing Cypress suite, // next to its Playwright port in tests/qa-214.spec.ts. Shown on the work sample page as an example. describe('QA-214 / C1182 support form rejects an invalid e-mail', () => { it('invalid e-mail: error at the field, linked, no request', () => { cy.visit('/app/'); cy.get('form > div:nth-child(1) input').type('anna@example'); cy.get('#category').select('Billing'); cy.get('#message').type('My November invoice shows the wrong address.'); cy.get('form button').click(); cy.get('#email-error').should('have.text', 'Please enter a valid e-mail address.'); cy.get('#email').should('have.attr', 'aria-invalid', 'true'); cy.get('[data-testid="sent-count"]').should('have.text', '0'); }); });
Playwright · ran on the build day
test('invalid e-mail: error at the field, linked, no request', tags, async ({ supportForm }, testInfo) => { await supportForm.open(); await supportForm.fill({ email: 'anna@example', category: 'Billing', message: 'My November invoice shows the wrong address.' }); await supportForm.send(); // AC1: the message is shown at the field await expect(supportForm.emailError).toHaveText('Please enter a valid e-mail address.'); // AC2: the error is linked to the field, screen readers announce it await expect(supportForm.email).toHaveAttribute('aria-invalid', 'true'); await expect(supportForm.email).toHaveAccessibleDescription('Please enter a valid e-mail address.'); // AC3: no request is created await expect(supportForm.sentCount).toHaveText('0'); await expect(supportForm.status).toHaveCount(0); const shot = testInfo.outputPath('qa-214.png'); await supportForm.page.getByRole('main').screenshot({ path: shot }); await testInfo.attach('qa-214', { path: shot, contentType: 'image/png' }); });
Result back in the ticket
Built from the report, ready to post.
A small script reads the Playwright JSON report and builds one TestRail result per case and one Jira comment per ticket. Nothing is sent. Field names follow the public API docs. Run ID and permissions come from your instance.
TestRail · add_result_for_case
POST index.php?/api/v2/add_result_for_case/{run_id}/1182
{
"status_id": 1,
"comment": "Playwright, Chrome, 27 Nov 2026, 14:51 CET: 2 of 2 checks passed.\n- passed: QA-214 / C1182 support form rejects an invalid e-mail › invalid e-mail: error at the field, linked, no request\n- passed: QA-214 / C1182 support form rejects an invalid e-mail › counter-check: a valid e-mail creates exactly one request",
"elapsed": "2s"
}Jira · comment on QA-214
POST /rest/api/3/issue/QA-214/comment
{
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Automated check C1182: passed (2 of 2), Playwright, Chrome, 27 Nov 2026, 14:51 CET."
}
]
},
{
"type": "bulletList",
"content": [
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "passed: QA-214 / C1182 support form rejects an invalid e-mail › invalid e-mail: error at the field, linked, no request"
}
]
}
]
},
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "passed: QA-214 / C1182 support form rejects an invalid e-mail › counter-check: a valid e-mail creates exactly one request"
}
]
}
]
}
]
}
]
}
}What backs this up
Testing is already part of my work.
Since early November I have also been testing the implementations of a software vendor’s developers against the prototypes, and I re-test their fixes in the ticket.
tests green in a sample suite I wrote in TypeScript with Playwright and page objects, on a public practice app for software testing, in 10.6 seconds.
of my pull requests in the main branch of a vendor of invoice and document management software, all with a green pipeline, plus my own Playwright browser tests.
Claude Code practically every day, now usually with agents that build and agents that review.
leading teams of up to 15 people, including onboarding and coaching.
All sources
- Ticket QA-214, case C1182 and the support form are invented for this sample. The form lives on this site under /app/ and sends nothing.
- The test files were written in Claude Code on 27 Nov 2026 from the instruction shown above. Build-day run: 27 Nov 2026, 14:51, Playwright 1.64, Chrome, 6 tests.
- Payloads: built by bauen_nutzlast.mjs from the JSON report of the same run. Not sent. TestRail status_id 1 = Passed, 5 = Failed, per the public API docs.
- Sample suite: runs on 6 Nov 2026, 12 passed in 10.6 s without retries.
- Pull requests: counted on 6 Nov 2026, 118 in the main branch.
- The Cypress file is a comparison and was not run.