---
title: "toBeDisabled() | Grafana k6 documentation"
description: "Asserts that an element is disabled"
---

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

# toBeDisabled()

The `toBeDisabled()` method asserts that an element is disabled. This is a retrying assertion that automatically waits for the element to become disabled.

## Syntax

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

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

## Parameters

Expand table

| Parameter | Type                                                                                       | Description                    |
|-----------|--------------------------------------------------------------------------------------------|--------------------------------|
| options   | [RetryConfig](/docs/k6/next/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 `toBeDisabled()` method checks if an element is disabled. An element is considered disabled if it has the `disabled` attribute or property set to `true`.

This is a retrying assertion that will automatically re-check the element’s disabled state until it becomes disabled 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/');

  // Click the pizza button to see the recommendation
  await page.locator('button[name="pizza-please"]').click();

  // Wait for the recommendation to appear
  await expect(page.locator('h2[id="pizza-name"]')).toBeVisible();

  // The pizza button should now be disabled (no longer clickable)
  await expect(page.locator('button[name="pizza-please"]')).toBeDisabled();

  // Verify that we can check for disabled state
  await expect(page.locator('button[name="pizza-please"]')).not.toBeEnabled();
}
```
