Lupa API Reference / commands/locator / query
Function: query()
query(
query):Locator
Defined in: src/commands/locator.ts:464
Creates a locator that can execute multiple actions like click, type, etc. It interacts with the Playwright's Page object, but via RPC calls.
Parameters
query
The query to use to locate the element.
Returns
A locator.
Examples
Clicking on a button with text "Submit".
typescript
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).click()Checking a checkbox with label "Subscribe".
typescript
import { query } from '@pawel-up/lupa/commands'
await query({ label: 'Subscribe' }).check()Filling a text input with "admin" username.
typescript
import { query } from '@pawel-up/lupa/commands'
await query({ placeholder: 'Username' }).fill('admin')