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
fix: Wrapped select() in try-catch to handle input types that don't support text selection
Saurav Pandaeb6eee149a3f
diff --git a/browser_use/actor/element.py b/browser_use/actor/element.pyindex b12b5bef5..ad7da6b6d 100644--- a/browser_use/actor/element.py+++ b/browser_use/actor/element.py@@ -837,9 +837,15 @@ class Element:params={'functionDeclaration': """function() {- // First select all text to ensure we're working with the whole field- this.select();- // Then set value to empty+ // Try to select all text first (only works on text-like inputs)+ // This handles cases where cursor is in the middle of text+ try {+ this.select();+ } catch (e) {+ // Some input types (date, color, number, etc.) don't support select()+ // That's fine, we'll just clear the value directly+ }+ // Set value to emptythis.value = "";// Dispatch events to notify frameworks like Reactthis.dispatchEvent(new Event("input", { bubbles: true }));diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex b980bb41b..206bf97bd 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -769,9 +769,15 @@ class DefaultActionWatchdog(BaseWatchdog):params={'functionDeclaration': """function() {- // First select all text to ensure we're working with the whole field- this.select();- // Then set value to empty+ // Try to select all text first (only works on text-like inputs)+ // This handles cases where cursor is in the middle of text+ try {+ this.select();+ } catch (e) {+ // Some input types (date, color, number, etc.) don't support select()+ // That's fine, we'll just clear the value directly+ }+ // Set value to emptythis.value = "";// Dispatch events to notify frameworks like Reactthis.dispatchEvent(new Event("input", { bubbles: true }));