Skip to content

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

Update isContentEditable handling to check readonly and disabled attributes

guybensimhon17c4284d05270
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 44b7595d5..d005be4ea 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -1084,10 +1084,16 @@ class BrowserContext:
pass
# Get element properties to determine input method
+ tag_handle = await element_handle.get_property("tagName")
+ tag_name = (await tag_handle.json_value()).lower()
is_contenteditable = await element_handle.get_property('isContentEditable')
+ readonly_handle = await element_handle.get_property("readOnly")
+ disabled_handle = await element_handle.get_property("disabled")
- # Different handling for contenteditable vs input fields
- if await is_contenteditable.json_value():
+ readonly = await readonly_handle.json_value() if readonly_handle else False
+ disabled = await disabled_handle.json_value() if disabled_handle else False
+
+ if (await is_contenteditable.json_value() or tag_name == 'input') and not (readonly or disabled):
await element_handle.evaluate('el => el.textContent = ""')
await element_handle.type(text, delay=5)
else: