{"record":{"id":"b710869efca3fe59","repo":"grafana/k6","slug":"parsing-mouse-click-options-w","errorCode":null,"errorMessage":"parsing mouse click options: %w","messagePattern":"parsing mouse click options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/mouse_mapping.go","lineNumber":19,"sourceCode":"package browser\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\n\t\"github.com/grafana/sobek\"\n\n\t\"go.k6.io/k6/v2/internal/js/modules/k6/browser/common\"\n\tk6common \"go.k6.io/k6/v2/js/common\"\n)\n\nfunc mapMouse(vu moduleVU, m *common.Mouse) mapping {\n\trt := vu.Runtime()\n\treturn mapping{\n\t\t\"click\": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseClickOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse click options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Click(x, y, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"dblClick\": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseDblClickOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse double click options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.DblClick(x, y, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"down\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseDownUpOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse down options: %w\", err)","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/mouse_mapping.go#L1-L37","documentation":"Thrown by mouse.click(x, y, options) when the options object fails parseMouseClickOptions. That parser accepts only 'button' (any value, stringified), 'clickCount', and 'delay' — both integers — and requires the argument to be object-convertible (browser/mouse_mapping.go:63-95). Non-integer clickCount/delay (string, float, boolean) or a non-object options value surfaces wrapped in this message.","triggerScenarios":"page.mouse().click(10, 20, { clickCount: '2' }), { delay: 50.5 }, { delay: true }, or passing a number where options belongs. Note floats like 50.0 written as literals export as int64 and pass, but computed floats (50.5) fail.","commonSituations":"Delay values computed from pacing logic (e.g. jitter producing floats); options built from JSON config where all values are strings; fast clicks configured via clickCount read from a CSV.","solutions":["Use integer literals for clickCount and delay: { clickCount: 2, delay: 100 }.","Round computed values: { delay: Math.round(jitterMs) }.","Coerce config-sourced values: Number(cfg.delay) and verify Number.isInteger.","Omit options entirely for a plain left click at the coordinates."],"exampleFix":"// before\nawait page.mouse().click(10, 20, { clickCount: String(n), delay: jitter });\n\n// after\nawait page.mouse().click(10, 20, { clickCount: parseInt(n, 10), delay: Math.round(jitter) });","handlingStrategy":"validation","validationCode":"function mouseClickOpts(o = {}) {\n  for (const k of ['clickCount', 'delay']) {\n    if (o[k] != null && !Number.isInteger(o[k])) throw new Error(`${k} must be an integer, got ${o[k]}`);\n  }\n  return o;\n}\nawait page.mouse().click(x, y, mouseClickOpts(cfg.mouse));","typeGuard":"function isMouseClickOptions(o) {\n  if (o == null) return true;\n  if (typeof o !== 'object') return false;\n  return (o.clickCount == null || Number.isInteger(o.clickCount)) && (o.delay == null || Number.isInteger(o.delay));\n}","tryCatchPattern":"try { await page.mouse().click(x, y, opts); } catch (e) { if (/parsing mouse click options|must be an integer/.test(e.message)) { /* coerce clickCount/delay to integers and retry */ } throw e; }","preventionTips":["Use integer literals for clickCount and delay.","Round computed delays with Math.round before passing them.","Coerce config-sourced numbers with Number() plus Number.isInteger check in one shared helper."],"tags":["k6","browser","mouse","click","options-parsing"],"backgroundTag":"invalid-options-argument","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}