Skip to content

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

added check for history item state

Saurav Panda9339935c1fa5
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 82b8e5db4..6e4609056 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -3386,7 +3386,7 @@ class Agent(Generic[Context, AgentStructuredOutput]):
Returns True if the step appears to open a dropdown/submenu.
"""
- if not history_item or not history_item.state.interacted_element:
+ if not history_item or not history_item.state or not history_item.state.interacted_element:
return False
elem = history_item.state.interacted_element[0] if history_item.state.interacted_element else None