grafana/k6 · error
checking %q: %w
Error message
checking %q: %w
What it means
Frame.Check() runs a pointer action that waits for the element to be actionable and then sets checked=true. This error wraps any failure: a wait timeout from the injected script, or a DOM error such as 'element is not a checkbox or radio button' converted by errorFromDOMError.
Source
Thrown at internal/js/modules/k6/browser/common/frame.go:652
document, err := f.document()
if err != nil {
return 0, fmt.Errorf("getting document: %w", err)
}
c, err := document.count(f.ctx, selector)
if err != nil {
return 0, fmt.Errorf("counting elements: %w", err)
}
return c, nil
}
// Check clicks the first element found that matches selector.
func (f *Frame) Check(selector string, popts *FrameCheckOptions) error {
f.log.Debugf("Frame:Check", "fid:%s furl:%q sel:%q", f.ID(), f.URL(), selector)
if err := f.check(selector, popts); err != nil {
return fmt.Errorf("checking %q: %w", selector, err)
}
applySlowMo(f.ctx)
return nil
}
func (f *Frame) check(selector string, opts *FrameCheckOptions) error {
check := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {
return nil, handle.setChecked(apiCtx, true, p)
}
act := f.newPointerAction(
selector, DOMElementStateAttached, opts.Strict, check, &opts.ElementHandleBasePointerOptions,
)
if _, err := call(f.ctx, act, opts.Timeout); err != nil {
return errorFromDOMError(err)
}
View on GitHub (pinned to 93accf6570)
Solutions
- Confirm the target is an <input type=checkbox|radio>; if it is a custom toggle, use click() instead.
- Use a unique selector (data-testid, for= label association) and wait for visible state before checking.
- If the input is visually hidden by design, target it via its label or use click() on the label.
Example fix
// before
frame.check('.switch'); // div toggle -> 'not a checkbox or radio button'
// after
frame.click('.switch'); // custom toggle is a button-like element
// or, for a real checkbox:
await frame.waitForSelector('input[name=agree]', { state: 'attached' });
frame.check('input[name=agree]'); Defensive patterns
Strategy: validation
Validate before calling
await frame.waitForSelector(sel, { state: 'visible', timeout: 30000 });
const isCheckable = await frame.evaluate(
'(s) => { const el = document.querySelector(s); return !!el && /checkbox|radio/.test(el.type || ""); }',
sel
); Try / catch
try {
frame.check(sel, { timeout: 30000 });
} catch (e) {
console.warn(`check(${sel}) failed:`, e.message);
} Prevention
- check()/uncheck() only for real input[type=checkbox|radio]; use click() for custom toggles.
- Target the native input, or its associated label, not a styled wrapper.
- Wait for visible state before checking.
When it happens
Trigger: Selector resolves to a non-checkbox/radio element (div, regular button); element hidden/covered so actionability checks time out; strict-mode multiple matches; element disabled.
Common situations: Custom-styled checkboxes where the real <input> is visually hidden and a styled <label> is clickable; clicking a toggle implemented as a button (needs click(), not check()); multiple checkboxes sharing a name/class.
Related errors
- clicking on %q: %w
- setting checked %q: %w
- unchecking %q: %w
- double clicking on %q: %w
- pressing %q on %q: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/101f540b4da2cb61.
Report an issue: GitHub.