- deterministic clicks
- file handling
- calling APIs
- human-in-the-loop
- browser interactions
- calling LLMs
- get 2fa codes
- send emails
- Playwright integration (see GitHub example)
- …
@tools.action(...) to your function.
description(required) - What the tool does, the LLM uses this to decide when to call it.allowed_domains- List of domains where tool can run (e.g.['*.example.com']), defaults to all domains
Available Objects
Your function has access to these objects:browser_session: BrowserSession- Current browser session for CDP accesscdp_client- Direct Chrome DevTools Protocol clientpage_extraction_llm: BaseChatModel- The LLM you pass into agent. This can be used to do a custom llm call here.file_system: FileSystem- File system accessavailable_file_paths: list[str]- Available files for upload/processinghas_sensitive_data: bool- Whether action contains sensitive data
Browser Interaction Examples
You can usebrowser_session to directly interact with page elements using CSS selectors:
Page:
get_elements_by_css_selector(selector: str)- Returns list of matching elementsget_element_by_prompt(prompt: str, llm)- Returns element or None using LLMmust_get_element_by_prompt(prompt: str, llm)- Returns element or raises error
Element:
click()- Click the elementtype(text: str)- Type text into the elementget_text()- Get element text content- See
browser_use/actor/element.pyfor more methods