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

# $(selector)

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

Queries the element for the given selector in the [ElementHandle](/docs/k6/latest/javascript-api/k6-browser/elementhandle/)’s subtree.

Expand table

| Parameter | Type     | Default | Description                           |
|-----------|----------|---------|---------------------------------------|
| selector  | `string` |         | A selector to query the elements for. |

### Returns

Expand table

| Type                            | Description                                                                                                                                                                                     |
|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Promise<null | ElementHandle>` | A Promise that fulfills with the [ElementHandle](/docs/k6/latest/javascript-api/k6-browser/elementhandle/) for the first element found. If no element is found, the Promise resolves to `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 textbox = await page.$('#text1');
  // ...
  await page.close();
}
```
