Skip to content

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

Should be visable

Magnus Müllerbdb6dcb5956f
diff --git a/browser_use/dom/serializer/serializer.py b/browser_use/dom/serializer/serializer.py
index 8f53838fc..e13e982a1 100644
--- a/browser_use/dom/serializer/serializer.py
+++ b/browser_use/dom/serializer/serializer.py
@@ -105,7 +105,7 @@ class DOMTreeSerializer:
is_scrollable = node.is_scrollable
# Include if interactive (regardless of visibility), or scrollable, or has children to process
- should_include = is_interactive or is_scrollable or node.children_nodes
+ should_include = (is_interactive and is_visible) or is_scrollable or node.children_nodes
if should_include:
simplified = SimplifiedNode(original_node=node)
@@ -119,7 +119,7 @@ class DOMTreeSerializer:
simplified.children.append(simplified_child)
# Return if meaningful or has meaningful children
- if is_interactive or is_scrollable or simplified.children:
+ if (is_interactive and is_visible) or is_scrollable or simplified.children:
return simplified
elif node.node_type == NodeType.TEXT_NODE: