Skip to content

Clicking and Typing

import { Aside } from ‘@astrojs/starlight/components’;

Click an element selected by CSS selector, text, or absolute coordinates.

NameTypeRequiredDescription
selectorstringconditionalCSS or text selector (e.g. button.submit, text=Sign in)
xnumberconditionalViewport-relative x coordinate
ynumberconditionalViewport-relative y coordinate
buttonenumnoleft (default), right, or middle
clickCountnumbernoDefaults to 1; use 2 for double-click
timeoutMsnumbernoHow long to wait for the element to become actionable

Either a selector or a (x, y) pair is required.

{
"tool": "ptah_browser_click",
"arguments": {
"selector": "text=Accept all cookies"
}
}

Ptah will scroll the element into view, wait for it to become stable and enabled, and then click. If the element is covered by another element or detached during the wait, the call retries until the timeout expires.

Type text into a focused input or a specific selector.

NameTypeRequiredDescription
selectorstringnoIf provided, focuses the element before typing
textstringyesText to type
delayMsnumbernoPer-keystroke delay; defaults to 0 for instant input
clearFirstbooleannoIf true, selects all existing text and replaces it
{
"tool": "ptah_browser_type",
"arguments": {
"selector": "input[name=email]",
"text": "[email protected]",
"clearFirst": true
}
}

Use JavaScript escape sequences for control characters. For more complex key sequences (e.g. Tab, Enter, Shift+A) use ptah_browser_evaluate with Playwright’s keyboard API:

await page.keyboard.press('Enter');