---
title: "toBeChecked() | Grafana k6 documentation"
description: "Asserts that a checkbox or radio button is checked"
---

# toBeChecked()

The `toBeChecked()` method asserts that a checkbox or radio button is checked. This is a retrying assertion that automatically waits for the element to become checked.

## Syntax

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

```javascript
await expect(locator).toBeChecked();
await expect(locator).not.toBeChecked();
await expect(locator).toBeChecked(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 `toBeChecked()` method checks if a checkbox or radio button is checked. This assertion is specifically designed for form elements that have a checked state.

This is a retrying assertion that will automatically re-check the element’s state until it becomes checked 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 checkbox functionality
  await page.goto('https://quickpizza.grafana.com');

  // Check a checkbox
  await page.locator('#accept-terms').check();
  await expect(page.locator('#accept-terms')).toBeChecked();

  // Check a radio button
  await page.locator('input[name="gender"][value="male"]').check();
  await expect(page.locator('input[name="gender"][value="male"]')).toBeChecked();

  // Verify another option is not checked
  await expect(page.locator('input[name="gender"][value="female"]')).not.toBeChecked();
}
```
