grafana/k6 · error
checking element is checked %q: %w
Error message
checking element is checked %q: %w
What it means
Frame.IsChecked() runs an action that waits for an element matching the selector to be attached (within opts.Timeout) and then queries its checked state. This error wraps failures of that wait/action — most often 'waiting for selector ... timed out' when no element attaches in time, converted via errorFromDOMError.
Source
Thrown at internal/js/modules/k6/browser/common/frame.go:735
}
act := f.newPointerAction(
selector, DOMElementStateAttached, opts.Strict, uncheck, &opts.ElementHandleBasePointerOptions,
)
if _, err := call(f.ctx, act, opts.Timeout); err != nil {
return errorFromDOMError(err)
}
return nil
}
// IsChecked returns true if the first element that matches the selector
// is checked. Otherwise, returns false.
func (f *Frame) IsChecked(selector string, opts *FrameIsCheckedOptions) (bool, error) {
f.log.Debugf("Frame:IsChecked", "fid:%s furl:%q sel:%q", f.ID(), f.URL(), selector)
checked, err := f.isChecked(selector, opts)
if err != nil {
return false, fmt.Errorf("checking element is checked %q: %w", selector, err)
}
return checked, nil
}
func (f *Frame) isChecked(selector string, opts *FrameIsCheckedOptions) (bool, error) {
isChecked := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
v, err := handle.isChecked(apiCtx, 0) // Zero timeout when checking state
if errors.Is(err, ErrTimedOut) { // We don't care about timeout errors here!
return v, nil
}
return v, err
}
act := f.newAction(
selector, DOMElementStateAttached, opts.Strict, isChecked, []string{}, false, withRetry, true, opts.Timeout,
)
v, err := call(f.ctx, act, opts.Timeout)
if err != nil {View on GitHub (pinned to 93accf6570)
Solutions
- Wait for the element to be attached before querying: waitForSelector(sel, { state: 'attached' }).
- Increase opts.Timeout.
- Use a unique selector and the correct frame (page vs iframe).
Example fix
// before
const ok = frame.isChecked('#agree', { timeout: 2000 });
// after
await frame.waitForSelector('#agree', { state: 'attached', timeout: 30000 });
const ok = frame.isChecked('#agree', { timeout: 30000 }); Defensive patterns
Strategy: try-catch
Validate before calling
await frame.waitForSelector(sel, { state: 'attached', timeout: 30000 }); Try / catch
let checked = false;
try {
checked = frame.isChecked(sel, { timeout: 30000 });
} catch (e) {
console.warn(`isChecked(${sel}) failed, treating as false:`, e.message);
} Prevention
- Wait for the element to attach before querying state.
- Pass explicit timeouts instead of relying on defaults in slow environments.
- Query the correct frame.
When it happens
Trigger: Selector matches nothing within the timeout (element not attached); strict-mode multiple matches; frame navigating so the execution context is destroyed during the wait.
Common situations: Checking state of an element that renders conditionally after an async action (fetch completes late); asserting on the wrong frame; short timeouts during CI slowness.
Related errors
- focusing %q: %w
- finding iframe with selector %q: %w
- waiting for element state %q: %w
- waiting for selector %q: %w
- clicking on %q: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/3cea9e7e66eebd30.
Report an issue: GitHub.