Tool Evaluate Script
Category: Browser Automation · Tier: Free
Run JavaScript in the page context and return the result. The script runs as an expression.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| script | string | Yes | JavaScript to execute in the page context |
| _browserToken | string | No | Browser session token |
Examples
{ "script": "document.title" }
→ "CBrowser | Cognitive Browser Automation"
{ "script": "document.querySelectorAll('a').length" }
→ 42
{ "script": "(() => { const el = document.querySelector('h1'); return { text: el.textContent, tag: el.tagName }; })()" }
→ { "text": "Welcome", "tag": "H1" }
For complex scripts, wrap in an IIFE: (() => { ... return result; })().
Related
extract— Structured data extractionget_console_messages— Read console logs- Browser Automation Tools — All 25 tools
- Tools Overview — All 120 tools by category