Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix hooks example lines
Nick Sweetingf62d691bce35
diff --git a/docs/customize/hooks.mdx b/docs/customize/hooks.mdxindex e1c55d2d9..2ae18828a 100644--- a/docs/customize/hooks.mdx+++ b/docs/customize/hooks.mdx@@ -35,16 +35,15 @@ async def my_step_hook(agent):# agent.controller, agent.llm, agent.browser, agent.browser_context# agent.pause(), agent.resume(), agent.add_new_task(...), etc.+ # You also have direct access to the playwright Page and Browser Context+ page = await agent.browser_context.get_current_page()+ # https://playwright.dev/python/docs/api/class-page- visit_log = agent.state.history.urls()current_url = page.url+ visit_log = agent.state.history.urls()previous_url = visit_log[-2] if len(visit_log) >= 2 else Noneprint(f"Agent was last on URL: {previous_url} and is now on {current_url}")- # You also have direct access to the playwright Page and Browser Context- page = await agent.browser_context.get_current_page()- # https://playwright.dev/python/docs/api/class-page-# Example: listen for events on the page, interact with the DOM, run JS directly, etc.await page.on('domcontentloaded', lambda: print('page navigated to a new url...'))await page.locator("css=form > input[type=submit]").click()