> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notte.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# EvaluateJsAction

> Evaluate JavaScript code on the current page and return the result

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

Useful for extracting structured data from a page without LLM processing.

The code is evaluated as a JavaScript expression. For simple cases use a single expression.
For multi-statement logic, use an IIFE (Immediately Invoked Function Expression):
`(() => { /* statements */ return result; })()`

You will not get any output from console.log(), so simply use the return value if your goal is to gather information

**Example:**

```python theme={null}
session.execute(type="evaluate_js", code="document.title")
session.execute(type="evaluate_js", code="Array.from(document.querySelectorAll('a')).map(a => a.href)")
session.execute(type="evaluate_js", code="(() => { const els = document.querySelectorAll('a'); return els.length; })()")
```

## Fields

<ParamField path="type" type="Literal['evaluate_js']" default="evaluate_js" />

<ParamField path="category" type="str" default="Special Browser Actions" />

<ParamField path="description" type="str" default="Evaluate JavaScript code on the current page and return the result. For simple cases, provide a single expression (e.g. `document.title`). For multi-statement code, wrap in an IIFE: `(() => { ...; return result; })()`" />

<ParamField path="code" type="str" required>
  The JavaScript code to evaluate on the page. Use a single expression or an IIFE for multi-statement code.
</ParamField>

## Module

`notte_core.actions.actions`
