Skip to content

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

tag name validation rejects valid custom-element names (e.g. my-button)

Magnus Müller5de8a6e3e145
diff --git a/browser_use/dom/utils.py b/browser_use/dom/utils.py
index a9aada27b..029aec9d6 100644
--- a/browser_use/dom/utils.py
+++ b/browser_use/dom/utils.py
@@ -14,7 +14,7 @@ def generate_css_selector_for_element(enhanced_node) -> str | None:
# Get base selector from tag name (simplified since we don't have xpath in EnhancedDOMTreeNode)
tag_name = enhanced_node.tag_name.lower().strip()
- if not tag_name or not re.match(r'^[a-zA-Z][a-zA-Z0-9]*$', tag_name):
+ if not tag_name or not re.match(r'^[a-zA-Z][a-zA-Z0-9-]*$', tag_name):
return None
css_selector = tag_name