Skip to content

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

input clear: fail honestly when a pure clear leaves text behind

MagMueller369678054c9b
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.py
index de7750ae2..317ac3ea5 100644
--- a/browser_use/browser/watchdogs/default_action_watchdog.py
+++ b/browser_use/browser/watchdogs/default_action_watchdog.py
@@ -1841,6 +1841,9 @@ class DefaultActionWatchdog(BaseWatchdog):
if clear:
cleared_successfully = await self._clear_text_field(object_id=object_id, cdp_session=cdp_session)
if not cleared_successfully:
+ if not text:
+ # Pure clear: surface the failure instead of letting the action report success
+ raise BrowserError('Failed to clear text field: field still contains previous text')
self.logger.warning('⚠️ Text field clearing failed, typing may append to existing text')
# Step 4: Type the text character by character using proper human-like key events