---
title: "evaluateHandle(pageFunction[, arg]) | Grafana k6 documentation"
description: "Browser module: page.evaluateHandle(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).

# evaluateHandle(pageFunction\[, arg])

Executes JavaScript code in the page and returns the value of the `pageFunction` invocation as a [JSHandle](/docs/k6/latest/javascript-api/k6-browser/jshandle/).

The only difference between `page.evaluate()` and `page.evaluateHandle()` is that `page.evaluateHandle()` returns [JSHandle](/docs/k6/latest/javascript-api/k6-browser/jshandle/).

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<JSHandle>` | The [JSHandle](/docs/k6/latest/javascript-api/k6-browser/jshandle/) ) instance associated with the page. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  await page.goto('https://test.k6.io/browser.php');
  const resultHandle = await page.evaluateHandle(() => document.body);
  console.log(resultHandle.jsonValue());
}
```
