Appearance
Class: Browser
📖 Related Tutorial
- Browser Automation Guide - Complete guide to browser automation
Overview
The Browser module provides comprehensive browser automation capabilities including navigation, element interaction, screenshot capture, and content extraction. It enables automated testing and web scraping workflows with support for proxy configuration, fingerprinting, and stealth mode.
Requirements
- Requires
agb-browser-use-1image for browser automation features
Browser module for web automation: navigate, click, type, screenshot, and extract content. Requires initialization with browser options (e.g. headless, viewport). Use session.browser.agent for high-level tasks.
Hierarchy
BaseService↳
Browser
Table of contents
Properties
Methods
Properties
typescript
agent: ``BrowserAgent``session
• Protected session: SessionLike
Inherited from
BaseService.session
Methods
callMcpTool
▸ callMcpTool(name, args, readTimeout?, connectTimeout?): Promise<OperationResult>
Parameters
| Name | Type |
|---|---|
name | string |
args | Record<string, unknown> |
readTimeout? | number |
connectTimeout? | number |
Returns
Promise<OperationResult>
Inherited from
BaseService.callMcpTool
destroy
▸ destroy(): Promise<BoolResult>
Returns
Promise<BoolResult>
handleError
▸ handleError(e): unknown
Parameters
| Name | Type |
|---|---|
e | unknown |
Returns
unknown
Inherited from
BaseService.handleError
initialize
▸ initialize(option): Promise<boolean>
Initialize the browser instance with the given options.
Note: In Python, initialize() uses sync HTTP and initialize_async() uses async HTTP. In TypeScript there is no standard synchronous HTTP API; both methods use the same async client and return Promise<boolean>. Use initialize() or initializeAsync() interchangeably (e.g. await session.browser.initialize(option)).
Parameters
| Name | Type | Description |
|---|---|---|
option | BrowserOption | BrowserOptionClass | Browser configuration options (BrowserOptionClass or plain BrowserOption). |
Returns
Promise<boolean>
Promise resolving to true if initialization succeeded, false otherwise.
initializeAsync
▸ initializeAsync(option): Promise<boolean>
Initialize the browser instance asynchronously. Same as initialize() in TypeScript (both use async HTTP). Exists for API parity with Python SDK where initialize_async uses async HTTP and initialize uses sync HTTP.
Parameters
| Name | Type | Description |
|---|---|---|
option | BrowserOption | BrowserOptionClass | Browser configuration options (BrowserOptionClass or plain BrowserOption). |
Returns
Promise<boolean>
Promise resolving to true if initialization succeeded, false otherwise.
isInitialized
▸ isInitialized(): boolean
Returns
boolean
screenshot
▸ screenshot(page, fullPage?, options?): Promise<Uint8Array>
Takes a screenshot of the specified Playwright page with enhanced options. Handles scroll-to-load for lazy content, lazy images, and viewport resizing.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
page | unknown | undefined | The Playwright Page object to screenshot. |
fullPage | boolean | false | Whether to capture the full scrollable page. Defaults to false. |
options | Record<string, unknown> | {} | Additional screenshot options (type, quality, timeout, etc.). |
Returns
Promise<Uint8Array>
Screenshot data as Uint8Array.
Throws
If browser is not initialized.
toJSON
▸ toJSON(): Record<string, unknown>
Returns
Record<string, unknown>
Inherited from
BaseService.toJSON
Best Practices
- Initialize browser with appropriate options before use
- Wait for page load completion before interacting with elements
- Use appropriate selectors (CSS, XPath) for reliable element identification
- Handle navigation timeouts and errors gracefully
- Take screenshots for debugging and verification
- Clean up browser resources after automation tasks
- Configure proxy settings properly for network requirements