---
title: "textContent() | Grafana k6 documentation"
description: "Browser module: elementHandle.textContent method"
---

# textContent()

> Warning
> 
> Use [`locator.textContent([options])`](/docs/k6/latest/javascript-api/k6-browser/locator/textcontent/) instead.

Returns the element’s text content.

### Returns

Expand table

| Type                     | Description                                                              |
|--------------------------|--------------------------------------------------------------------------|
| `Promise<string | null>` | A Promise that fulfills with the text content of the selector or `null`. |

### 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 options = await page.$('#checkbox1');
  console.log(await options.textContent());

  await page.close();
}
```
