Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

controller docs updating

Nick Sweetingf11aa8b5af4f
diff --git a/docs/customize/custom-functions.mdx b/docs/customize/custom-functions.mdx
index 282020449..0c729c313 100644
--- a/docs/customize/custom-functions.mdx
+++ b/docs/customize/custom-functions.mdx
@@ -13,7 +13,7 @@ from browser_use import Controller, ActionResult
# Initialize the controller
controller = Controller()
[email protected]('Ask user for information')
[email protected]('Ask user for information', domains=['https://difficult.example.com']) # pass domains= or page_filter= to limit actions to certain pages
def ask_human(question: str) -> str:
answer = input(f'\n{question}\nInput: ')
return ActionResult(extracted_content=answer)
@@ -41,21 +41,27 @@ agent = Agent(
## Browser-Aware Functions
-For actions that need browser access, simply add the `browser` parameter inside the function parameters:
+For actions that need page or browser access, simply add the `browser_session` or `page` parameter inside the function parameters:
-<Note>
- Please note that browser-use’s `Browser` class is a wrapper class around
- Playwright’s `Browser`. The `Browser.playwright_browser` attr can be used
- to directly access the Playwright browser object if needed.
-</Note>
+```python
+from playwright.async_api import Page
+from browser_use import Controller, ActionResult
+
+controller = Controller()
[email protected]('Open website')
+async def open_website(url: str, page: Page):
+ await page.goto(url)
+ return ActionResult(extracted_content='Website opened')
+```
```python
-from browser_use import Browser, Controller, ActionResult
+from browser_use import BrowserSession, Controller, ActionResult
controller = Controller()
+
@controller.action('Open website')
-async def open_website(url: str, browser: Browser):
- page = await browser.get_current_page()
+async def open_website(url: str, browser_session: BrowserSession):
+ page = await browser_session.get_current_page()
await page.goto(url)
return ActionResult(extracted_content='Website opened')
```
@@ -129,5 +135,4 @@ If you want less actions to be used by the agent, you can exclude them from the
controller = Controller(exclude_actions=['open_tab', 'search_google'])
```
-
For more examples like file upload or notifications, visit [examples/custom-functions](https://github.com/browser-use/browser-use/tree/main/examples/custom-functions).