Skip to content

Instantly share code, notes, and snippets.

@adamliptrot-oc
Last active March 11, 2025 10:29
Show Gist options
  • Select an option

  • Save adamliptrot-oc/b19e5d9a730e53522e808bf7927bbb2c to your computer and use it in GitHub Desktop.

Select an option

Save adamliptrot-oc/b19e5d9a730e53522e808bf7927bbb2c to your computer and use it in GitHub Desktop.
Keyboard-only tests with Playwright
test('user can access carousel items', async ({ page }) => {
const carouselPrev = page.getByRole('button', {name: 'previous'});
const firstDeal = page.getByTestId('first-deal-item');
carouselPrev.focus();
await page.keyboard.press('Tab');
await expect(firstDeal).toBeFocused();
await page.keyboard.press('Enter');
await expect(firstDeal).toHaveClass(/selected/);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment