Skip to content

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

Exclude tagname from attribute values like button to prevent duplicates

Magnus Müller2e2001fb556e
diff --git a/browser_use/dom/views.py b/browser_use/dom/views.py
index 830ce32df..99c3f9a5c 100644
--- a/browser_use/dom/views.py
+++ b/browser_use/dom/views.py
@@ -129,7 +129,13 @@ class DOMElementNode(DOMBaseNode):
attributes_str = ''
if include_attributes:
attributes = list(
- set([str(value) for key, value in node.attributes.items() if key in include_attributes])
+ set(
+ [
+ str(value)
+ for key, value in node.attributes.items()
+ if key in include_attributes and value != node.tag_name
+ ]
+ )
)
attributes_str = ';'.join(attributes)
text = node.get_all_text_till_next_clickable_element()