Skip to content

Latest commit

 

History

History
186 lines (117 loc) · 3.92 KB

File metadata and controls

186 lines (117 loc) · 3.92 KB

AsyncBrowserAgent API Reference

T

T = TypeVar("T", bound=BaseModel)

ERROR_ACT_START_FAIL

ERROR_ACT_START_FAIL = 9000

ERROR_ACT_TASK_FAILED

ERROR_ACT_TASK_FAILED = 9001

ERROR_ACT_TIMEOUT

ERROR_ACT_TIMEOUT = 9002

ERROR_OBSERVE_FAIL

ERROR_OBSERVE_FAIL = 9020

ERROR_EXTRACT_FAIL

ERROR_EXTRACT_FAIL = 9040

ERROR_EXTRACT_START_FAIL

ERROR_EXTRACT_START_FAIL = 9041

ERROR_EXTRACT_TIMEOUT

ERROR_EXTRACT_TIMEOUT = 9042

AsyncBrowserAgent

class AsyncBrowserAgent(BaseService)

BrowserAgent handles browser automation and agent logic.

⚠️ Note: Currently, for agent services (including ComputerUseAgent, BrowserUseAgent, and MobileUseAgent), we do not provide services for overseas users registered with alibabacloud.com.

init

def __init__(self, session, browser)

navigate

async def navigate(url: str) -> str

Navigates a specific page to the given URL.

Arguments:

url: The URL to navigate to.

Returns:

A string indicating the result of the navigation.

screenshot

async def screenshot(page=None,
                     full_page: bool = True,
                     quality: int = 80,
                     clip: Optional[Dict[str, float]] = None,
                     timeout: Optional[int] = None) -> str

Asynchronously takes a screenshot of the specified page.

Arguments:

  • page Optional[Page] - The Playwright Page object to take a screenshot of. If None, the agent's currently focused page will be used.
  • full_page bool - Whether to capture the full scrollable page.
  • quality int - The quality of the image (0-100), for JPEG format.
  • clip Optional[Dict[str, float]] - An object specifying the clipping region {x, y, width, height}.
  • timeout Optional[int] - Custom timeout for the operation in seconds.

Returns:

str: A base64 encoded data URL of the screenshot, or an error message.

close

async def close() -> bool

Asynchronously closes the remote browser agent session. This will terminate the browser process managed by the agent.

act

async def act(action_input: Union[ObserveResult, ActOptions],
              page=None) -> "ActResult"

Asynchronously perform an action on a web page.

Arguments:

  • page Optional[Page] - The Playwright Page object to act on. If None, the agent's currently focused page will be used automatically.
  • action_input Union[ObserveResult, ActOptions] - The action to perform.

Returns:

ActResult: The result of the action.

observe

async def observe(options: ObserveOptions,
                  page=None) -> Tuple[bool, List[ObserveResult]]

Asynchronously observe elements or state on a web page.

Arguments:

  • page Optional[Page] - The Playwright Page object to observe. If None, the agent's currently focused page will be used.
  • options ObserveOptions - Options to configure the observation behavior.

Returns:

Tuple[bool, List[ObserveResult]]: A tuple containing a success boolean and a list of observation results.

extract

async def extract(options: ExtractOptions, page=None) -> Tuple[bool, T]

Asynchronously extract information from a web page.

Arguments:

  • page Optional[Page] - The Playwright Page object to extract from. If None, the agent's currently focused page will be used.
  • options ExtractOptions - Options to configure the extraction, including schema.

Returns:

Tuple[bool, T]: A tuple containing a success boolean and the extracted data as a Pydantic model instance, or None on failure.

See Also


Documentation generated automatically from source code using pydoc-markdown.