Docs/SDK/Action API

Action API

Interact with elements on the page using clicks, typing, and keyboard input.

click() - Click by Element ID

Clicks an element by ID. Uses Playwright mouse click by default, with optional human-like cursor movement via CursorPolicy (NEW in 2026-01-15).

from predicate import click

result = click(browser, button.id)
if result.success:
    print

Parameters:

Returns: ActionResult with:

Human-like Cursor Movement (CursorPolicy)

Use CursorPolicy(mode="human", ...) to move the cursor along a human-like path before clicking. This is useful for demos, bot-detection sensitive pages, and trace/debugging.

from predicate import CursorPolicy, PredicateBrowser, click, find, snapshot

with PredicateBrowser() as browser:
    browser.page.goto("https://example.com")
    browser.page.wait_for_load_state("networkidle"

click_rect() / clickRect() - Click by Coordinates

Clicks at the center of a rectangle. Shows visual feedback (red border).

from predicate import click_rect

# Click at specific coordinates
click_rect(browser, {"x": 100, "y": 200, "w": 50, "h": 30})

Parameters:

type_text() / typeText() - Type into Input

Types text into an input field.

from predicate import type_text

# Find input and type
snap = snapshot(browser)
email_input = find(snap, "role=textbox")
type_text(browser, email_input.id, "user@example.com")

Parameters:

Human-like Typing

Use the delay_ms parameter to add realistic delays between keystrokes:

from predicate import type_text

# Instant typing (default)
type_text(browser, input.id, "Hello world")

# Human-like typing with 10ms delay between keystrokes
type_text(browser, input.id, "Hello world", delay_ms

scroll_to() / scrollTo() - Scroll Element into View

Scrolls an element into view using the native browser scrollIntoView() API.

from predicate import scroll_to

# Scroll element to center of viewport with smooth animation
scroll_to(browser, element.id, behavior="smooth", block="center")

# Instant scroll to top of viewport
scroll_to(browser, element.id, behavior

Parameters:

Returns: ActionResult

press() - Keyboard Input

Presses a keyboard key (Enter, Escape, Tab, etc.).

from predicate import press

press(browser, "Enter")   # Submit form
press(browser, "Escape")  # Close modal

Parameters:

Returns: ActionResult

Complete Example

from predicate import PredicateBrowser, snapshot, find, click, type_text, press

with PredicateBrowser(api_key="sk_...") as browser:
    browser.page.goto("https://example.com/login")
    
    # Take snapshot