Skip to main content

Session

A CDP session representing a single browser tab.

Usage

Source

Session(
    cdp,
    width=992,
    height=744,
)

Provides methods for navigation, viewport control, JavaScript evaluation, and DOM queries needed for screenshot capture.

Parameters

cdp: SyncCDP | SyncPipeCDP

The SyncCDP connection to use.

width: int = 992

Initial viewport width in pixels.

height: int = 744
Initial viewport height in pixels.

Functions

Name Description
close() Close this session (tab).
evaluate() Evaluate a JavaScript expression and return the result.
get_element_bounds() Get the bounding box of an element matched by a CSS selector.
get_elements_union_bounds() Get the union bounding box of all elements matched by the given selectors.
navigate() Navigate to a URL and wait for the page to load.
set_user_agent() Set a custom User-Agent string.
set_viewport() Set the viewport dimensions.