Lupa API Reference / commands/locator / Locator
Class: Locator
Defined in: src/commands/locator.ts:363
A bridge to Playwright's Locator object, used to locate elements on the page and execute actions on them. It uses RPC calls to interact with the Playwright's Page object.
Not all Playwright's Locator actions are supported. Only actions that are relevant to testing are implemented.
Constructors
Constructor
new Locator(
query):Locator
Defined in: src/commands/locator.ts:370
Creates a locator.
Parameters
query
The query to use to locate the element.
Returns
Locator
A locator.
Methods
blur()
blur(
options?):Promise<void>
Defined in: src/commands/locator.ts:389
Calls blur on the element.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the blur action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Focus me' }).blur()check()
check(
options?):Promise<void>
Defined in: src/commands/locator.ts:423
Ensure that checkbox or radio element is checked.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the check action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ label: 'Subscribe' }).check()clear()
clear(
options?):Promise<void>
Defined in: src/commands/locator.ts:406
Clear the input field.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the clear action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ label: 'Email' }).clear()click()
click(
options?):Promise<void>
Defined in: src/commands/locator.ts:440
Clicks on the element.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the click action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).click()dblclick()
dblclick(
options?):Promise<void>
Defined in: src/commands/locator.ts:475
Double clicks the element.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the double click action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).dblclick()fill()
fill(
text,options?):Promise<void>
Defined in: src/commands/locator.ts:458
Fills the input field.
Parameters
text
string
Value to set for the <input>, <textarea> or [contenteditable] element.
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the fill action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ placeholder: 'Username' }).fill('admin')hover()
hover(
options?):Promise<void>
Defined in: src/commands/locator.ts:492
Hovers over the element.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the hover action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).hover()press()
press(
key,options?):Promise<void>
Defined in: src/commands/locator.ts:510
Presses the given key.
Parameters
key
string
The key to press.
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the press action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).press('Enter')tap()
tap(
options?):Promise<void>
Defined in: src/commands/locator.ts:527
Taps the element.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the tap action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Submit' }).tap()uncheck()
uncheck(
options?):Promise<void>
Defined in: src/commands/locator.ts:544
Ensure that checkbox or radio element is unchecked.
Parameters
options?
Optional settings to modify the action.
Returns
Promise<void>
A promise that resolves when the uncheck action is completed.
Example
import { query } from '@pawel-up/lupa/commands'
await query({ text: 'Subscribe' }).uncheck()