Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fixed unsafe css selector problems
Gregor Žuničcd0938bbdc26
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 1202dc8dc..e7faab638 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -4044,7 +4044,10 @@ class BrowserSession(BaseModel):collapsed_value = re.sub(r'\s+', ' ', value).strip()# Escape embedded double-quotes.safe_value = collapsed_value.replace('"', '\\"')- css_selector += f'[{safe_attribute}*="{safe_value}"]'++ # if safe_value is empty, don't add it to the selector (could be empty after the filters)+ if safe_value:+ css_selector += f'[{safe_attribute}*="{safe_value}"]'else:css_selector += f'[{safe_attribute}="{value}"]'diff --git a/browser_use/dom/playground/extraction.py b/browser_use/dom/playground/extraction.pyindex 9b2f51748..928e8232c 100644--- a/browser_use/dom/playground/extraction.py+++ b/browser_use/dom/playground/extraction.py@@ -33,7 +33,7 @@ async def test_focus_vs_all_elements():# 10 Sample websites with various interactive elementssample_websites = [- 'https://v0-website-with-clickable-elements.vercel.app/cross-origin',+ 'https://glosbe.com/','https://www.google.com/travel/flights','https://www.amazon.com/s?k=laptop','https://github.com/trending',