prompt parameter, returns an AILocator - a lazy Playwright Locator that resolves the element’s position via AI on first use.
When called with only a
selector (no prompt), page.locator(selector) behaves exactly like the standard Playwright page.locator(selector) - no AI is involved.| Parameter | Type | Required | Description |
|---|---|---|---|
selector | str | No | CSS or XPath selector passed to Playwright’s built-in locator(). |
prompt | str | No | Natural-language description of the element. When provided, returns an AILocator that resolves via AI. |
ai | str | No | Controls AI behavior. Default "fallback" tries the selector first, then AI. |
**kwargs | No | Additional keyword arguments forwarded to Playwright’s locator(). |
Locator - standard Playwright Locator when only a selector is given, or AILocator when a prompt is provided.
AILocator
Whenprompt is provided, the returned AILocator supports all standard Playwright Locator methods:
- Actions:
click(),fill(),type(),select_option(),check(),uncheck(),clear(),hover(),focus(),press() - Queries:
text_content(),inner_text(),inner_html(),get_attribute(),input_value(),count() - State:
is_visible(),is_hidden(),is_enabled(),is_disabled(),is_editable(),is_checked() - Chaining:
first(),last(),nth(),filter(),locator(),get_by_text(),get_by_role(),get_by_label(),get_by_placeholder() - Utilities:
wait_for(),screenshot(),playwright_locator(access rawLocator)

