mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
88 lines
2.6 KiB
Plaintext
88 lines
2.6 KiB
Plaintext
---
|
|
title: "All Parameters"
|
|
description: "Complete API reference for Browser Actor classes, methods, and parameters including BrowserSession, Page, Element, and Mouse"
|
|
icon: "list"
|
|
mode: "wide"
|
|
---
|
|
|
|
## Browser (BrowserSession)
|
|
|
|
Main browser session manager.
|
|
|
|
### Key Methods
|
|
|
|
```python
|
|
from browser_use import Browser
|
|
|
|
browser = Browser()
|
|
await browser.start()
|
|
|
|
# Page management
|
|
page = await browser.new_page("https://example.com")
|
|
pages = await browser.get_pages()
|
|
current = await browser.get_current_page()
|
|
await browser.close_page(page)
|
|
|
|
# To stop the browser session
|
|
await browser.stop()
|
|
```
|
|
|
|
### Constructor Parameters
|
|
|
|
See [Browser Parameters](../browser/all-parameters) for complete configuration options.
|
|
|
|
## Page
|
|
|
|
Browser tab/iframe for page-level operations.
|
|
|
|
### Navigation
|
|
- `goto(url: str)` - Navigate to URL
|
|
- `go_back()`, `go_forward()`, `reload()` - History navigation
|
|
|
|
### Element Finding
|
|
- `get_elements_by_css_selector(selector: str) -> list[Element]` - CSS selector
|
|
- `get_element(backend_node_id: int) -> Element` - By CDP node ID
|
|
- `get_element_by_prompt(prompt: str, llm) -> Element | None` - AI-powered
|
|
- `must_get_element_by_prompt(prompt: str, llm) -> Element` - AI (raises if not found)
|
|
|
|
### JavaScript & Controls
|
|
- `evaluate(page_function: str, *args) -> str` - Execute JS (arrow function format)
|
|
- `press(key: str)` - Send keyboard input ("Enter", "Control+A")
|
|
- `set_viewport_size(width: int, height: int)` - Set viewport
|
|
- `screenshot(format='jpeg', quality=None) -> str` - Take screenshot
|
|
|
|
### Information
|
|
- `get_url() -> str`, `get_title() -> str` - Page info
|
|
- `mouse -> Mouse` - Get mouse interface
|
|
|
|
### AI Features
|
|
- `extract_content(prompt: str, structured_output: type[T], llm) -> T` - Extract data
|
|
|
|
## Element
|
|
|
|
Individual DOM element interactions.
|
|
|
|
### Interactions
|
|
- `click(button='left', click_count=1, modifiers=None)` - Click element
|
|
- `fill(text: str, clear=True)` - Fill input
|
|
- `hover()`, `focus()` - Mouse/focus actions
|
|
- `check()` - Toggle checkbox/radio
|
|
- `select_option(values: str | list[str])` - Select dropdown options
|
|
- `drag_to(target: Element | Position)` - Drag and drop
|
|
|
|
### Properties
|
|
- `get_attribute(name: str) -> str | None` - Get attribute
|
|
- `get_bounding_box() -> BoundingBox | None` - Position/size
|
|
- `get_basic_info() -> ElementInfo` - Complete element info
|
|
- `screenshot(format='jpeg') -> str` - Element screenshot
|
|
|
|
## Mouse
|
|
|
|
Coordinate-based mouse operations.
|
|
|
|
### Operations
|
|
- `click(x: int, y: int, button='left', click_count=1)` - Click at coordinates
|
|
- `move(x: int, y: int, steps=1)` - Move mouse
|
|
- `down(button='left')`, `up(button='left')` - Press/release buttons
|
|
- `scroll(x=0, y=0, delta_x=None, delta_y=None)` - Scroll at coordinates
|