Functions

Keyboard accessibility testing

Ecosystem testing pattern. Explicit focus and activation do not prove Tab order or WCAG compliance. Source: https://playwright.dev/docs/accessibility-testing

Formal Syntax & Structure

nextjs syntaxnextjs
await page.keyboard.press('Enter')

Working Example

Example Snippetnextjs
import {test,expect} from '@playwright/test';test('quantity works with keyboard',async({page})=>{ await page.goto('/catalog'); const add=page.getByRole('button',{name:'Add one'}); await add.focus();await expect(add).toBeFocused(); await page.keyboard.press('Enter'); await expect(page.getByRole('status')).toHaveText('2 selected');});
Next.js Reference