---
title: "evaluate(pageFunction[, arg]) | Grafana k6 documentation"
description: "Browser module: frame.evaluate(pageFunction[, arg]) method"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# evaluate(pageFunction\[, arg])

Executes JavaScript code in the page and returns the value of the `pageFunction` invocation.

Expand table

| Parameter    | Type               | Defaults | Description                                                              |
|--------------|--------------------|----------|--------------------------------------------------------------------------|
| pageFunction | function or string |          | Function to be evaluated in the page context. This can also be a string. |
| arg          | string             | `''`     | Optional argument to pass to `pageFunction`                              |

### Returns

Expand table

| Type           | Description                                 |
|----------------|---------------------------------------------|
| `Promise<any>` | The value of the `pageFunction` invocation. |
