{"record":{"id":"b23f5f3f226738b5","repo":"grafana/k6","slug":"parsing-new-frame-check-options-w-b23f5f","errorCode":null,"errorMessage":"parsing new frame check options: %w","messagePattern":"parsing new frame check options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":33,"sourceCode":"\t\"go.k6.io/k6/v2/internal/js/modules/k6/browser/k6ext\"\n\tk6common \"go.k6.io/k6/v2/js/common\"\n)\n\n// mapPage to the JS module.\n//\n//nolint:funlen\nfunc mapPage(vu moduleVU, p *common.Page) mapping { //nolint:gocognit,cyclop\n\trt := vu.Runtime()\n\tmaps := mapping{\n\t\t\"bringToFront\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, p.BringToFront() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"check\": func(selector string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseFrameCheckOptions(rt, opts, p.MainFrame().Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing new frame check options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, p.Check(selector, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"click\": func(selector string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseFrameClickOptions(rt, opts, p.MainFrame().Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\terr := p.Click(selector, popts)\n\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"close\": func(opts sobek.Value) *sobek.Promise {\n\t\t\t// TODO when opts are implemented for this function, parse them here before calling promise()","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/page_mapping.go#L15-L51","documentation":"Thrown synchronously by page.check(selector, opts) in the k6 browser module when the options object fails to parse. FrameCheckOptions.Parse delegates to ElementHandleBasePointerOptions.Parse, where the only failing branch is 'position': it must export to map[string]float64, i.e. an object whose x and y are numbers (internal/js/modules/k6/browser/common/element_handle_options.go:188-195). The wrapper adds the 'parsing new frame check options' prefix; force, noWaitAfter, timeout and strict are coerced and never fail.","triggerScenarios":"page.check('#accept', { position: 'center' }) — position as a string instead of {x, y}; position: { x: '10', y: 10 } with a string coordinate; position: 10 or any non-object value; position object containing nested objects or NaN values.","commonSituations":"Porting Playwright snippets that use shorthand position names instead of coordinates; coordinates read from JSON fixtures where numbers got quoted; assuming 'position: center' (a CSS-like keyword) is supported — only a coordinate object is.","solutions":["Pass position as numeric coordinates: page.check(selector, { position: { x: 10, y: 20 } })","Omit position entirely when clicking the element center is acceptable — it is the default behavior","If coordinates come from data, coerce them: { position: { x: Number(px), y: Number(py) } } and verify they are finite before the call"],"exampleFix":"// before\nawait page.check('#tos', { position: 'center' });\n// parsing new frame check options: ...cannot convert position...\n\n// after\nawait page.check('#tos', { position: { x: 100, y: 150 } });\n// or simply omit position:\nawait page.check('#tos');","handlingStrategy":"validation","validationCode":"function validPosition(p) {\n  return p === undefined || (typeof p === 'object' && p !== null\n    && Number.isFinite(p.x) && Number.isFinite(p.y));\n}\nif (!validPosition(opts?.position)) throw new Error('position must be { x: number, y: number }');\nawait page.check(selector, opts);","typeGuard":"/** @param {unknown} p */\nfunction isPosition(p) {\n  return typeof p === 'object' && p !== null\n    && Number.isFinite(/** @type {any} */ (p).x)\n    && Number.isFinite(/** @type {any} */ (p).y);\n}","tryCatchPattern":"try {\n  await page.check(selector, opts);\n} catch (e) {\n  if (String(e).includes('parsing new frame check options')) {\n    // most likely a bad position object; retry without it\n    await page.check(selector);\n  } else throw e;\n}","preventionTips":["position only accepts numeric { x, y } — no keywords like 'center'","Coerce fixture data: { position: { x: Number(p.x), y: Number(p.y) } }","Omit position when element-center clicking is acceptable"],"tags":["k6","browser","page","check","options","position"],"backgroundTag":"invalid-option-type","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"}