mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
Null checks
This commit is contained in:
@@ -960,7 +960,7 @@ You will be given a query and the markdown of a webpage that has been filtered t
|
||||
)
|
||||
|
||||
@self.registry.action(
|
||||
"""Execute JS. MUST: wrap in IIFE (function(){...})() or (async function(){...})(), add try-catch, validate elements exist. Use for: hover, drag, custom selectors, forms, extract/filter links, iframes, shadow DOM, React/Vue/Angular. Limit output. Examples: (function(){try{const el=document.querySelector('#id');return el?el.value:'not found'}catch(e){return 'Error: '+e.message}})() ✓ | document.querySelector('#id').value ✗. Shadow: iterate hosts, check shadowRoot. Return JSON.stringify() for objects. Do not use comments""",
|
||||
"""Execute JS. MUST: wrap in IIFE (function(){...})() or (async function(){...})(), add try-catch, validate elements exist. Check null before accessing properties. Use for: hover, drag, custom selectors, forms, extract/filter links, iframes, shadow DOM, React/Vue/Angular. Limit output. Examples: (function(){try{const el=document.querySelector('#id');return el?el.value:'not found'}catch(e){return 'Error: '+e.message}})() ✓ | document.querySelector('#id').value ✗. Shadow: iterate hosts, check shadowRoot. Return JSON.stringify() for objects. Do not use comments""",
|
||||
)
|
||||
async def evaluate(code: str, browser_session: BrowserSession):
|
||||
# Execute JavaScript with proper error handling and promise support
|
||||
|
||||
Reference in New Issue
Block a user