{"record":{"id":"101f540b4da2cb61","repo":"grafana/k6","slug":"checking-q-w","errorCode":null,"errorMessage":"checking %q: %w","messagePattern":"checking %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":652,"sourceCode":"\tdocument, err := f.document()\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"getting document: %w\", err)\n\t}\n\n\tc, err := document.count(f.ctx, selector)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"counting elements: %w\", err)\n\t}\n\n\treturn c, nil\n}\n\n// Check clicks the first element found that matches selector.\nfunc (f *Frame) Check(selector string, popts *FrameCheckOptions) error {\n\tf.log.Debugf(\"Frame:Check\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.check(selector, popts); err != nil {\n\t\treturn fmt.Errorf(\"checking %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) check(selector string, opts *FrameCheckOptions) error {\n\tcheck := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.setChecked(apiCtx, true, p)\n\t}\n\tact := f.newPointerAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, check, &opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}\n","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame.go#L634-L670","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nframe.check('.switch'); // div toggle -> 'not a checkbox or radio button'\n\n// after\nframe.click('.switch'); // custom toggle is a button-like element\n// or, for a real checkbox:\nawait frame.waitForSelector('input[name=agree]', { state: 'attached' });\nframe.check('input[name=agree]');","handlingStrategy":"validation","validationCode":"await frame.waitForSelector(sel, { state: 'visible', timeout: 30000 });\nconst isCheckable = await frame.evaluate(\n  '(s) => { const el = document.querySelector(s); return !!el && /checkbox|radio/.test(el.type || \"\"); }',\n  sel\n);","typeGuard":null,"tryCatchPattern":"try {\n  frame.check(sel, { timeout: 30000 });\n} catch (e) {\n  console.warn(`check(${sel}) failed:`, e.message);\n}","preventionTips":["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."],"tags":["browser","check","checkbox","selector","timeout","actionability"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}