Docs/SDK/Screenshot API

Screenshot API

Capture screenshots of the current page and search text to find its pixel coordinate.

screenshot() - Capture Screenshot

Captures a screenshot of the current page.

from predicate import screenshot
import base64

# Capture PNG screenshot
data_url = screenshot(browser, format="png")

# Save to file
image_data =

Parameters:

Returns: Base64-encoded data URL string

find_text_rect() / findTextRect() - Search text to get its pixel coordinates

Finds all occurrences of text on the page and returns their exact pixel coordinates. This is useful for locating UI elements by their visible text content without needing element IDs or selectors.

from predicate import find_text_rect, click_rect

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

    # Find "Sign In" button
    result = find_text_rect(browser, "Sign In")

Parameters:

Returns: TextRectSearchResult with:

Use Cases:

Notes: