Skip to content

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

Fix exception handling for text input in DOM elements by raising BrowserError within the try-except block, ensuring proper error reporting.

mertunsall4e88b221b6a4
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 1f2bcca72..10e9da65b 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -2935,8 +2935,7 @@ class BrowserSession(BaseModel):
await element_handle.fill(text)
except Exception as e:
self.logger.error(f'Error during input text into element: {type(e).__name__}: {e}')
-
- raise BrowserError(f'Failed to input text into element: {repr(element_node)}')
+ raise BrowserError(f'Failed to input text into element: {repr(element_node)}')
except Exception as e:
# Get current page URL safely for error message