Form accessibility
A sign-up form with a name, an email, and a consent checkbox. Errors appear
below the fields and are connected to them through ARIA.
Contract:
- every field has a label, and its accessible name equals the label text;
- on error the field gets `aria-invalid="true"`;
- the error is connected to the field via `aria-describedby` and is exposed as
its accessible description;
- errors are live regions: `role="alert"` and `aria-live="assertive"`;
- after a failed submit the focus moves to the first invalid field;
- Tab order: name → email → consent → `Отправить` ("Submit");
- submitting from the keyboard (Enter) works.
Error texts: `Укажите имя` ("Enter a name"), `Укажите корректный email`
("Enter a valid email"), `Подтвердите согласие` ("Confirm consent"). Success:
`Заявка отправлена` ("Request sent").
Write Playwright tests:
- the accessible names of the fields;
- the error-to-field link (`aria-describedby` and the description);
- `aria-invalid`;
- focus on the first invalid field;
- the focus order;
- the alert/live region;
- keyboard submission.
Elements: `signup-form`, `name`, `email`, `consent`, `submit`, `success`,
`name-error`, `email-error`, `consent-error`. Find fields via `get_by_label`,
errors via `get_by_test_id` or `get_by_role`.
The message texts are the literal strings the page renders; assertions compare
them exactly.
The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.
Log in and askHint 1
Assert the relationships, not just the text: label ↔ input and error ↔ field.
Which attributes expose those relationships to a screen reader?