{"record":{"id":"bf1711b458f27e1a","repo":"grafana/k6","slug":"parsing-set-checked-options-w","errorCode":null,"errorMessage":"parsing set checked options: %w","messagePattern":"parsing set checked options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":113,"sourceCode":"\t\t},\n\t\t\"evaluateHandle\": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {\n\t\t\tif sobekEmptyString(pageFunc) {\n\t\t\t\treturn nil, fmt.Errorf(\"evaluateHandle requires a page function\")\n\t\t\t}\n\t\t\tfuncString := pageFunc.String()\n\t\t\tgopts := exportArgs(gargs)\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tjsh, err := lo.EvaluateHandle(funcString, gopts...)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t\t}\n\t\t\t\treturn mapJSHandle(vu, jsh), nil\n\t\t\t}), nil\n\t\t},\n\t\t\"setChecked\": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameCheckOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing set checked options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.SetChecked(checked, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"check\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameCheckOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing check options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Check(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"uncheck\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameUncheckOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing uncheck options: %w\", err)","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L95-L131","documentation":"Thrown while parsing the options object of locator.setChecked(checked, options) (browser/locator_mapping.go:112). FrameCheckOptions.Parse delegates to ElementHandleBasePointerOptions.Parse, whose only failing branch is position: it must export to a map with numeric x/y. strict, force, noWaitAfter, trial and timeout are coerced and cannot fail; the checked boolean itself is a separate positional argument.","triggerScenarios":"locator.setChecked(true, { position: [5, 5] }); locator.setChecked(false, { position: 'topLeft' }); coordinates from JSON/env arriving as strings on the export path.","commonSituations":"Checkbox automation where the label overlaps the input and a position offset is used; porting Playwright scripts that pass arrays; data-driven coordinates serialized through config.","solutions":["Use position: { x: 5, y: 5 } with numbers","Remove position to click the element center","Coerce with Number() when values come from external sources","If the label intercepts clicks, prefer force: true or a position on the input box itself"],"exampleFix":"// before\nlocator.setChecked(true, { position: [5, 5] });\n// after\nlocator.setChecked(true, { position: { x: 5, y: 5 } });","handlingStrategy":"validation","validationCode":"if (opts?.position != null &&\n    !(typeof opts.position === 'object' && typeof opts.position.x === 'number' && typeof opts.position.y === 'number')) {\n  throw new Error('position must be { x: number, y: number }');\n}","typeGuard":"function isCheckOptions(o) {\n  if (o == null) return true;\n  if (typeof o !== 'object' || Array.isArray(o)) return false;\n  const p = o.position;\n  return p == null || (typeof p === 'object' && typeof p.x === 'number' && typeof p.y === 'number');\n}","tryCatchPattern":"try { await locator.setChecked(true, opts); } catch (e) { if (!String(e.message).includes('parsing set checked options')) throw e; }","preventionTips":["Position is always { x, y } numbers — never an array or named string","For overlapped checkboxes prefer a numeric offset on the input or force: true","Centralize checkbox-option construction so both check and setChecked share a validated shape"],"tags":["k6","k6-browser","locator","set-checked","position","options"],"backgroundTag":"options-validation-failed","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}