{"record":{"id":"9d0f55037138aac9","repo":"grafana/k6","slug":"parsing-element-click-options-w","errorCode":null,"errorMessage":"parsing element click options: %w","messagePattern":"parsing element click options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":40,"sourceCode":"\t\t\t\tif errors.Is(err, common.ErrElementNotVisible) || errors.Is(err, common.ErrElementNotAttachedToDOM) {\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\treturn box, err\n\t\t\t})\n\t\t},\n\t\t\"check\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); 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, eh.Check(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"click\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleClickOptions(eh.Timeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element click options: %w\", err)\n\t\t\t}\n\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\terr := eh.Click(popts)\n\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"contentFrame\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tf, err := eh.ContentFrame()\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 mapFrame(vu, f), nil\n\t\t\t})\n\t\t},\n\t\t\"dblclick\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleDblclickOptions(eh.DefaultTimeout())","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L22-L58","documentation":"Thrown synchronously by ElementHandle.click() when its options fail to parse. ElementHandleClickOptions embeds the base-pointer options plus button, clickCount, delay and modifiers; in common/element_handle_options.go only two steps can fail: exporting 'position' to map[string]float64 and exporting 'modifiers' to []string (the latter is first wrapped as 'parsing element handle click option modifiers', then again by this message). The mapping returns (nil, error), so the failure is a synchronous JS exception at call time.","triggerScenarios":"el.click({ position: 'topLeft' }) or { position: { x: '5' } } (non-numeric coordinates), el.click({ modifiers: 'Shift' }) (string instead of array), or { modifiers: ['Shift', 2] } (non-string array element). button/clickCount/delay/timeout are lenient coercions and never fail; unknown option keys are ignored.","commonSituations":"Playwright-to-k6 script ports that pass modifiers as a comma-separated string, or position taken from outer-chain property files where values arrive as strings. Also occurs when a shared options object is reused across page.mouse and element APIs with incompatible shapes.","solutions":["Use { modifiers: ['Alt', 'Shift', 'Control', 'Meta'] } (array of strings) and { position: { x: 10, y: 10 } } with numeric x/y","Fix the source producing strings: Number(x), Number(y), and split(' ') for modifiers","Validate the options object with a type guard before calling click","Catch synchronously with try/catch around the call, since no promise is returned on failure"],"exampleFix":"// before\nawait el.click({ modifiers: 'Shift', position: [10, 10] });\n\n// after\nawait el.click({ modifiers: ['Shift'], position: { x: 10, y: 10 } });","handlingStrategy":"type-guard","validationCode":"if (opts) {\n  if (opts.position !== undefined &&\n      (typeof opts.position !== 'object' || Array.isArray(opts.position) ||\n       !Number.isFinite(Number(opts.position.x)) || !Number.isFinite(Number(opts.position.y)))) {\n    throw new Error('click(): position must be { x: number, y: number }');\n  }\n  if (opts.modifiers !== undefined &&\n      !(Array.isArray(opts.modifiers) && opts.modifiers.every(m => typeof m === 'string'))) {\n    throw new Error('click(): modifiers must be an array of strings');\n  }\n}","typeGuard":"function isClickOpts(o) {\n  if (o == null) return true;\n  const posOk = o.position === undefined ||\n    (typeof o.position === 'object' && !Array.isArray(o.position) &&\n     Number.isFinite(Number(o.position.x)) && Number.isFinite(Number(o.position.y)));\n  const modOk = o.modifiers === undefined ||\n    (Array.isArray(o.modifiers) && o.modifiers.every(m => typeof m === 'string'));\n  return posOk && modOk;\n}","tryCatchPattern":"try {\n  await el.click(opts);\n} catch (e) {\n  if (/parsing element click options/.test(String(e.message))) {\n    console.log(`fix click options: ${e.message}`);\n  } else throw e;\n}","preventionTips":["Always spell modifiers as an array: ['Shift'], never 'Shift'","Keep coordinates numeric end-to-end; convert fixture strings with Number() at load time","Unknown option keys are silently ignored, so typos never error: review option names manually"],"tags":["k6","browser","element-handle","click","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}