Browser Actions
browser_actions
¶
Pydantic models for headless browser automation.
Defines the strongly-typed contracts for the playWithBrowser
feature of the Scrape.do API. It provides models for every supported
browser interaction, enabling users to chain automation workflows with
full type safety and IDE support.
ClickAction
¶
WaitAction
¶
WaitSelectorAction
¶
Bases: BaseModel
Pauses browser execution until a specific element appears in the DOM.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
Literal['WaitSelector']
|
The literal action identifier. |
wait_selector |
str
|
The CSS selector to wait for. |
timeout |
Optional[int]
|
Maximum time to wait in milliseconds. Defaults to None. |
ScrollXAction
¶
ScrollYAction
¶
ScrollToAction
¶
FillAction
¶
ExecuteAction
¶
ScreenShotAction
¶
Bases: BaseModel
Captures a screenshot during the execution of browser actions.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
Literal['ScreenShot']
|
The literal action identifier. |
full_screenshot |
Optional[bool]
|
If True, captures the entire scrollable page. |
particular_screenshot |
Optional[str]
|
CSS selector of a specific element to capture. |
validate_screenshot_logic()
¶
Ensures mutually exclusive screenshot targeting parameters are not combined.
Capturing Full Screenshot And Particular Screenshot
A single screenshot action can either capture the entire scrollable
page OR a specific DOM element, but not both simultaneously.
To capture both, provide two separate ScreenShotAction objects in
the play_with_browser list.
Returns:
| Type | Description |
|---|---|
Self
|
The validated instance from which the method was called from |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
WaitForRequestCompletionAction
¶
Bases: BaseModel
Pauses execution until network requests matching a specific pattern complete.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
Literal['WaitForRequestCompletion']
|
The literal action identifier. |
url_pattern |
str
|
The regex or string pattern of the URL to wait for. |
timeout |
int
|
Maximum time to wait in milliseconds before failing. |
BrowserAction
module-attribute
¶
BrowserAction = Annotated[
Union[
ClickAction,
WaitAction,
WaitSelectorAction,
ScrollXAction,
ScrollYAction,
ScrollToAction,
FillAction,
ExecuteAction,
ScreenShotAction,
WaitForRequestCompletionAction,
],
Field(discriminator="action"),
]
Defines the valid types that can be passed to the
play_with_browser parameter in the RequestParameters
model