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/ae2c27fb0461766396cfd1b112af42a0 to your computer and use it in GitHub Desktop.

Select an option

Save adamliptrot-oc/ae2c27fb0461766396cfd1b112af42a0 to your computer and use it in GitHub Desktop.
Use accessible attributes in selectors with Playwright
// get button with accessible name of "login" and aria-expanded=false
await page.getByRole('button', {name: "login", expanded: false});
// get h2 with accessible name of "conditions"
await page.getByRole('heading', {level: 2, name: "Conditions"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment