Skip to content

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

Refactor navigate_to function and update tool descriptions for improved clarity and efficiency.

Magnus Müllera915a0b95c3e
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 244d8915c..29cff2852 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1444,13 +1444,13 @@ class BrowserSession(BaseModel):
async def navigate_to(self, url: str, new_tab: bool = False) -> None:
"""Navigate to a URL using the standard event system.
-
+
Args:
url: URL to navigate to
new_tab: Whether to open in a new tab
"""
from browser_use.browser.events import NavigateToUrlEvent
-
+
event = self.event_bus.dispatch(NavigateToUrlEvent(url=url, new_tab=new_tab))
await event
await event.event_result(raise_if_any=True, raise_if_none=False)
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index a0050ea0c..4ea335dd2 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -671,6 +671,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
@self.registry.action(
"""Scroll the page by specified number of pages (set down=True to scroll down, down=False to scroll up, num_pages=number of pages to scroll like 0.5 for half page, 10.0 for ten pages, etc.). Optional index parameter to scroll within a specific element or its scroll container (works well for dropdowns and custom UI components). If you want to scroll the entire page, don't use index.
Instead of scrolling step after step, use a high number of pages at once like 10 to get to the bottom of the page.
+ If you know where you want to scroll to, use scroll_to_text instead of this tool.
""",
param_model=ScrollAction,
)
@@ -739,7 +740,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
return ActionResult(error=error_msg)
@self.registry.action(
- description='Scroll to a text in the current page',
+ description='Scroll to a text in the current page. This helps you to be efficient. Prefer this tool over scrolling step by step.',
)
async def scroll_to_text(text: str, browser_session: BrowserSession): # type: ignore
# Dispatch scroll to text event