{"record":{"id":"60e4994b87a4233b","repo":"grafana/k6","slug":"unchecking-q-w","errorCode":null,"errorMessage":"unchecking %q: %w","messagePattern":"unchecking %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":706,"sourceCode":"// SetChecked sets the checked state of the first element found that matches the selector.\nfunc (f *Frame) SetChecked(selector string, checked bool, popts *FrameCheckOptions) error {\n\tf.log.Debugf(\"Frame:SetChecked\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.setChecked(selector, checked, popts); err != nil {\n\t\treturn fmt.Errorf(\"setting checked %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\n// Uncheck the first found element that matches the selector.\nfunc (f *Frame) Uncheck(selector string, popts *FrameUncheckOptions) error {\n\tf.log.Debugf(\"Frame:Uncheck\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.uncheck(selector, popts); err != nil {\n\t\treturn fmt.Errorf(\"unchecking %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) uncheck(selector string, opts *FrameUncheckOptions) error {\n\tuncheck := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.setChecked(apiCtx, false, p)\n\t}\n\tact := f.newPointerAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, uncheck, &opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}\n","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame.go#L688-L724","documentation":"Frame.Uncheck() delegates to setChecked(..., false) inside a pointer action with waits. This error wraps any failure of that pipeline — wait timeout, wrong element kind ('not a checkbox or radio button'), or element not connected at the moment of the operation.","triggerScenarios":"Unchecking a selector that matches no checkbox/radio, a hidden or overlapped checkbox, multiple strict-mode matches, or an element detached by re-render between the wait and the action.","commonSituations":"Unchecking pre-checked consent boxes behind cookie banners; list rows with many same-named checkboxes; SPA re-mounts the input during unchecked state.","solutions":["Use a unique selector for the specific checkbox (data-testid).","Dismiss overlays and waitForSelector visible before unchecking.","Bump the timeout option if rendering is slow."],"exampleFix":"// before\nframe.uncheck('.consent'); // matches many boxes -> strict failure\n\n// after\nawait frame.waitForSelector('input.consent[data-testid=ads]', { state: 'visible' });\nframe.uncheck('input.consent[data-testid=ads]');","handlingStrategy":"validation","validationCode":"await frame.waitForSelector(sel, { state: 'visible', timeout: 30000 });\nconst kind = await frame.evaluate('(s) => document.querySelector(s)?.type', sel);\nif (kind !== 'checkbox' && kind !== 'radio') throw new Error(`${sel} is ${kind}, not checkable`);","typeGuard":null,"tryCatchPattern":"try {\n  frame.uncheck(sel);\n} catch (e) {\n  console.warn(`uncheck(${sel}) failed:`, e.message);\n}","preventionTips":["Use unique selectors for one checkbox among many.","Handle cookie/consent overlays in setup.","Wait for visible state before unchecking."],"tags":["browser","uncheck","checkbox","selector","timeout","strict-mode"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}