Docs
API 1.39
Status
Actions

evaluate

The `evaluate` step.

Runs your own JavaScript in the page. The healer cannot see inside it, so lint warns W006, and it requires a paid organisation.

Type: object

#Keys

KeyTypeDescription
evaluate.argsobjectA JSON object passed to the script as its arguments.
evaluate.intostringThe variable that receives the script's return value, written vars.<name>.
evaluate.max_result_bytesintegerThe largest return value accepted, in bytes. Required, at most 1048576 (lint E003).
evaluate.scriptstringThe JavaScript function body to run, such as return document.title, at most 16 KB (lint E003).
evaluate.timeout_msintegerHow long the script may run, in milliseconds. Required, at most 5000 (lint E003).

Every step also takes the common step keys: expect, id, if, name, on_error, optional, retry, side_effect, timeout_ms, x_kaab.

#Example

{
  "evaluate": {
    "script": "return window.__STATE__.total",
    "into": "vars.total",
    "timeout_ms": 5000,
    "max_result_bytes": 1048576
  }
}

From the contract fixture evaluate-opaque, a program the test suite validates.

Was this page helpful?