Skip to content

Lupa API Reference / commands/locator / query

Function: query()

query(query): Locator

Defined in: src/commands/locator.ts:352

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

typescript
import { query } from '@pawel-up/lupa/commands'

await query({ text: 'Submit' }).click()
typescript
import { query } from '@pawel-up/lupa/commands'

await query({ label: 'Subscribe' }).check()
typescript
import { query } from '@pawel-up/lupa/commands'

await query({ placeholder: 'Username' }).fill('admin')