---
title: "toBeEnabled() | Grafana k6 documentation"
description: "Asserts that an element is enabled and interactive"
---

# toBeEnabled()

The `toBeEnabled()` method asserts that an element is enabled and interactive. This is a retrying assertion that automatically waits for the element to become enabled.

## Syntax

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

```javascript
await expect(locator).toBeEnabled();
await expect(locator).not.toBeEnabled();
await expect(locator).toBeEnabled(options);
```

## Parameters

Expand table

| Parameter | Type                                                                                         | Description                    |
|-----------|----------------------------------------------------------------------------------------------|--------------------------------|
| options   | [RetryConfig](/docs/k6/latest/javascript-api/jslib/testing/retrying-assertions/retryconfig/) | Optional configuration options |

## Returns

Expand table

| Type    | Description                                       |
|---------|---------------------------------------------------|
| Promise | A promise that resolves when the assertion passes |

## Description

The `toBeEnabled()` method checks if an element is enabled and interactive. An element is considered enabled if:

- It exists in the DOM
- It does not have the `disabled` attribute
- It is not disabled through CSS or JavaScript
- It can receive user interactions

This is a retrying assertion that will automatically re-check the element’s enabled state until it becomes enabled or the timeout is reached.

## Usage

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

```javascript
import { browser } from 'k6/browser';
import { expect } from 'https://jslib.k6.io/k6-testing/0.6.1/index.js';

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

export default async function () {
  const page = await browser.newPage();
  await page.goto('https://quickpizza.grafana.com/');

  // Check that the pizza button is enabled
  await expect(page.locator('button[name="pizza-please"]')).toBeEnabled();

  // Check that buttons are generally enabled on the page
  await expect(page.locator('button')).toBeEnabled();
}
```
