Skip to content

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 ​

LocatorQuery

The query to use to locate the element.

Returns ​

Locator

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')