grafana/k6 · error
checking element is disabled: %w
Error message
checking element is disabled: %w
What it means
Returned by ElementHandle.isDisabled() when the state probe fails with a non-timeout error. Timeouts are intentionally swallowed (a timeout merely means the element is not disabled yet); the remaining causes are a stale/detached handle, a destroyed execution context, a CDP transport failure, or a closed page/browser.
Source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:1069
}
// IsChecked checks if a checkbox or radio is checked.
func (h *ElementHandle) IsChecked() (bool, error) {
ok, err := h.isChecked(h.ctx, 0)
// We don't care about timeout errors here!
if err != nil && !errors.Is(err, ErrTimedOut) {
return false, fmt.Errorf("checking element is checked: %w", err)
}
return ok, nil
}
// IsDisabled checks if the element is disabled.
func (h *ElementHandle) IsDisabled() (bool, error) {
ok, err := h.isDisabled(h.ctx, 0)
// We don't care anout timeout errors here!
if err != nil && !errors.Is(err, ErrTimedOut) {
return false, fmt.Errorf("checking element is disabled: %w", err)
}
return ok, nil
}
// IsEditable checks if the element is editable.
func (h *ElementHandle) IsEditable() (bool, error) {
ok, err := h.isEditable(h.ctx, 0)
// We don't care anout timeout errors here!
if err != nil && !errors.Is(err, ErrTimedOut) {
return false, fmt.Errorf("checking element is editable: %w", err)
}
return ok, nil
}
// IsEnabled checks if the element is enabled.
func (h *ElementHandle) IsEnabled() (bool, error) {View on GitHub (pinned to 93accf6570)
Solutions
- Re-query the handle right before isDisabled()
- Wait for the element to be attached first
- Confirm the page is still open before probing
- Catch and distinguish hard errors from a legitimate false return
Example fix
// before
const disabled = await h.isDisabled(); // stale handle
// after
const el = await page.$('#submit');
const disabled = await el.isDisabled(); Defensive patterns
Strategy: try-catch
Validate before calling
const el = await page.$('#submit');
if (el && (await el.isVisible())) {
const disabled = await el.isDisabled();
} Try / catch
try {
return await handle.isDisabled();
} catch (e) {
if (String(e).includes('checking element is disabled')) {
const fresh = await page.$(sel);
return fresh ? fresh.isDisabled() : true;
}
throw e;
} Prevention
- A false return is a valid answer; only thrown errors indicate operational failure
- Re-query handles before state probes in re-rendering pages
- Avoid probing after navigation or page close
When it happens
Trigger: Calling isDisabled() on a handle detached by a DOM re-render; after a navigation destroyed the context; after the page or browser was closed; a dropped CDP session.
Common situations: Reusing handles across iterations in SPAs that re-render controls; probing disabled state right after an action that navigates; end-of-scenario teardown races.
Related errors
- focusing on element: %w
- getting attribute %q of element: %w
- getting element's inner HTML: %w
- getting element's inner text: %w
- checking element is checked: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/38cf16c8fbc11105.
Report an issue: GitHub.