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

# toBeEditable()

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

## Syntax

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

```javascript
await expect(locator).toBeEditable();
await expect(locator).not.toBeEditable();
await expect(locator).toBeEditable(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 `toBeEditable()` method checks if an element is editable. An element is considered editable if it can receive user input. This includes:

- Input fields that are not disabled or readonly
- Textareas that are not disabled or readonly
- Elements with `contenteditable="true"`

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

  // Go to a test page that demonstrates editable functionality
  await page.goto('https://quickpizza.grafana.com/login');

  // Check that input fields are editable
  await expect(page.locator('#username')).toBeEditable();
  await expect(page.locator('#password')).toBeEditable();
  await expect(page.locator('#message')).toBeEditable();

  // Check readonly field is not editable
  await expect(page.locator('#readonly-field')).not.toBeEditable();

  // Check contenteditable elements
  await expect(page.locator('[contenteditable="true"]')).toBeEditable();
  await expect(page.locator('[contenteditable="false"]')).not.toBeEditable();
}
```
