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
Refactor wait action to adjust for initial wait time and simplify ActionResult return
Magnus Müller0e64c846ae24
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex ff9a180b1..503fa83eb 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -130,23 +130,23 @@ class Controller(Generic[Context]):await browser_session.go_back()msg = '🔙 Navigated back'logger.info(msg)- return ActionResult(extracted_content=msg, include_in_memory=True, long_term_memory='Navigated back')+ return ActionResult(extracted_content=msg)- # wait for x seconds-- @self.registry.action('Wait for x seconds default 3 (max 10 seconds)')+ @self.registry.action(+ 'Wait for x seconds default 3 (max 10 seconds). This can be used to wait until the page is fully loaded.'+ )async def wait(seconds: int = 3):# Cap wait time at maximum 10 seconds- actual_seconds = min(max(seconds, 0), 10)+ # 3 seconds already waited by calling the llm+ actual_seconds = min(max(seconds - 3, 0), 10)+if actual_seconds != seconds:- msg = f'🕒 Waiting for {actual_seconds} seconds (capped from {seconds} seconds, max 10 seconds)'+ msg = f'🕒 Waiting for {actual_seconds + 3} seconds (capped from {seconds} seconds, max 10 seconds)'else:- msg = f'🕒 Waiting for {actual_seconds} seconds'+ msg = f'🕒 Waiting for {actual_seconds + 3} seconds'logger.info(msg)await asyncio.sleep(actual_seconds)- return ActionResult(- extracted_content=msg, include_in_memory=True, long_term_memory=f'Waited for {actual_seconds} seconds'- )+ return ActionResult(extracted_content=msg)# Element Interaction Actions