Skip to content

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

change tool error message from DOM to browser-state

Magnus Müller9e04ab19b19d
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 5d898bc30..f775232f9 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -266,7 +266,7 @@ class Tools(Generic[Context]):
# Look up the node from the selector map
node = await browser_session.get_element_by_index(params.index)
if node is None:
- raise ValueError(f'Element index {params.index} not found in DOM')
+ raise ValueError(f'Element index {params.index} not found in browser state')
event = browser_session.event_bus.dispatch(
ClickElementEvent(node=node, while_holding_ctrl=params.while_holding_ctrl or False)
@@ -315,7 +315,7 @@ class Tools(Generic[Context]):
# Look up the node from the selector map
node = await browser_session.get_element_by_index(params.index)
if node is None:
- raise ValueError(f'Element index {params.index} not found in DOM')
+ raise ValueError(f'Element index {params.index} not found in browser state')
# Dispatch type text event with node
try:
@@ -686,7 +686,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
node = await browser_session.get_element_by_index(params.frame_element_index)
if node is None:
# Element does not exist
- msg = f'Element index {params.frame_element_index} not found in DOM'
+ msg = f'Element index {params.frame_element_index} not found in browser state'
return ActionResult(error=msg)
# Dispatch scroll event with node - the complex logic is handled in the event handler
@@ -772,7 +772,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
# Look up the node from the selector map
node = await browser_session.get_element_by_index(params.index)
if node is None:
- raise ValueError(f'Element index {params.index} not found in DOM')
+ raise ValueError(f'Element index {params.index} not found in browser state')
# Dispatch GetDropdownOptionsEvent to the event handler
@@ -798,7 +798,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
# Look up the node from the selector map
node = await browser_session.get_element_by_index(params.index)
if node is None:
- raise ValueError(f'Element index {params.index} not found in DOM')
+ raise ValueError(f'Element index {params.index} not found in browser state')
# Dispatch SelectDropdownOptionEvent to the event handler
from browser_use.browser.events import SelectDropdownOptionEvent
diff --git a/docs/customize/examples/prompting-guide.mdx b/docs/customize/examples/prompting-guide.mdx
index 60ad8ca70..bcdc0009e 100644
--- a/docs/customize/examples/prompting-guide.mdx
+++ b/docs/customize/examples/prompting-guide.mdx
@@ -34,7 +34,7 @@ task = """
3. Use scroll action to scroll down 2 pages
4. Use extract_structured_data to extract the names of the first 5 items
5. Wait for 2 seconds if the page is not loaded, refresh it and wait 10 sec
-6. Use send_keys action with "Tab", "Tab", "ArrowDown", send "Hello World" and press "Enter"
+6. Use send_keys action with "Tab Tab ArrowDown Enter"
"""
```