Skip to content

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

Remove duplicates

Magnus Müller2fb2344c71a1
diff --git a/browser_use/dom/views.py b/browser_use/dom/views.py
index 6118262e3..86bbe0183 100644
--- a/browser_use/dom/views.py
+++ b/browser_use/dom/views.py
@@ -127,6 +127,7 @@ class DOMElementNode(DOMBaseNode):
# Add element with highlight_index
if node.highlight_index is not None:
attributes_str = ''
+ text = node.get_all_text_till_next_clickable_element()
if include_attributes:
attributes = list(
set(
@@ -137,8 +138,9 @@ class DOMElementNode(DOMBaseNode):
]
)
)
+ if text in attributes:
+ attributes.remove(text)
attributes_str = ';'.join(attributes)
- text = node.get_all_text_till_next_clickable_element()
if text:
formatted_text.append(
f'[{node.highlight_index}]<{node.tag_name} {attributes_str}>{text}</{node.tag_name}>'