···1313This page covers API usage. To better understand locators and their usage, read [Playwright's "Locators" documentation](https://playwright.dev/docs/locators).
1414:::
15151616+::: tip Difference from `testing-library`
1717+Vitest's `page.getBy*` methods return a locator object, not a DOM element. This makes locator queries composable and allows Vitest to retry interactions and assertions when needed.
1818+1919+Compared to testing-library queries:
2020+2121+- Use locator chaining (`.getBy*`, `.filter`, `.nth`) instead of `within(...)`.
2222+- Keep locators around and interact with them later (`await locator.click()`), instead of resolving elements up front.
2323+- Single-element escape hatches like `.element()` and `.query()` are strict and throw if multiple elements match.
2424+2525+```ts
2626+import { expect } from 'vitest'
2727+import { page } from 'vitest/browser'
2828+2929+const deleteButton = page
3030+ .getByRole('row')
3131+ .filter({ hasText: 'Vitest' })
3232+ .getByRole('button', { name: /delete/i })
3333+3434+await deleteButton.click()
3535+await expect.element(deleteButton).toBeEnabled()
3636+```
3737+:::
3838+1639## getByRole
17401841```ts