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
fixed `FRAME` elements
Gregor Žunič0913a8a34574
diff --git a/browser_use/dom/serializer/serializer.py b/browser_use/dom/serializer/serializer.pyindex 26ef9b62a..d660a648b 100644--- a/browser_use/dom/serializer/serializer.py+++ b/browser_use/dom/serializer/serializer.py@@ -143,10 +143,10 @@ class DOMTreeSerializer:if node.node_name.lower() in DISABLED_ELEMENTS:return None- if node.node_name == 'IFRAME':+ if node.node_name == 'IFRAME' or node.node_name == 'FRAME':if node.content_document:simplified = SimplifiedNode(original_node=node, children=[])- for child in node.content_document.children:+ for child in node.content_document.children_nodes or []:simplified_child = self._create_simplified_tree(child)if simplified_child:simplified.children.append(simplified_child)@@ -159,7 +159,7 @@ class DOMTreeSerializer:is_scrollable = node.is_actually_scrollable# Include if interactive (regardless of visibility), or scrollable, or has children to process- should_include = (is_interactive and is_visible) or is_scrollable or node.children_and_shadow_roots+ should_include = (is_interactive and is_visible) or is_scrollable or bool(node.children_and_shadow_roots)if should_include:simplified = SimplifiedNode(original_node=node, children=[])diff --git a/browser_use/dom/views.py b/browser_use/dom/views.pyindex 0f182888f..e07918e7f 100644--- a/browser_use/dom/views.py+++ b/browser_use/dom/views.py@@ -91,14 +91,28 @@ class SimplifiedNode:is_new: bool = Falseexcluded_by_parent: bool = False # New field for bbox filtering+ def _clean_original_node_json(self, node_json: dict) -> dict:+ """Recursively remove children_nodes and shadow_roots from original_node JSON."""+ # Remove the fields we don't want in SimplifiedNode serialization+ if 'children_nodes' in node_json:+ del node_json['children_nodes']+ if 'shadow_roots' in node_json:+ del node_json['shadow_roots']++ # Clean nested content_document if it exists+ if node_json.get('content_document'):+ node_json['content_document'] = self._clean_original_node_json(node_json['content_document'])++ return node_json+def __json__(self) -> dict:original_node_json = self.original_node.__json__()- del original_node_json['children_nodes']- del original_node_json['shadow_roots']+ # Remove children_nodes and shadow_roots to avoid duplication with SimplifiedNode.children+ cleaned_original_node_json = self._clean_original_node_json(original_node_json)return {'should_display': self.should_display,'interactive_index': self.interactive_index,- 'original_node': original_node_json,+ 'original_node': cleaned_original_node_json,'children': [c.__json__() for c in self.children],}