Skip to content

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

Include non visable elements

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