{"record":{"id":"4fad99d1bfea6e40","repo":"grafana/k6","slug":"parsing-mouse-down-options-w","errorCode":null,"errorMessage":"parsing mouse down options: %w","messagePattern":"parsing mouse down options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/mouse_mapping.go","lineNumber":37,"sourceCode":"\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)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Down(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"up\": 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 up options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Up(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"move\": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseMoveOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse move options: %w\", err)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/mouse_mapping.go#L19-L55","documentation":"Thrown by mouse.down(options) when parseMouseDownUpOptions fails. The down/up parser (browser/mouse_mapping.go:124-145) accepts 'button' (string) and 'clickCount' (integer); a non-integer clickCount or a non-object options value is wrapped with this message. mouse.down is used for press-and-hold interaction sequences (often paired with mouse.move and mouse.up for drag).","triggerScenarios":"page.mouse().down({ clickCount: 2.0 }) when 2.0 arrives as float64 from a computed value, { clickCount: '2' } from config, or a non-object argument in the options slot.","commonSituations":"Custom drag implementations that compute clickCount; multi-click press patterns ported from CDP scripts; options objects assembled dynamically where clickCount lost its integer type.","solutions":["Use an integer literal: page.mouse().down({ clickCount: 2 }).","Coerce computed counts: Math.trunc(count) with a Number.isInteger guard.","Omit clickCount (defaults to 1) for a simple press.","Keep 'button' a string: 'left', 'right', or 'middle'."],"exampleFix":"// before\nawait page.mouse().down({ clickCount: clicks }); // clicks = 2.0\n\n// after\nawait page.mouse().down({ clickCount: Math.trunc(clicks) });","handlingStrategy":"validation","validationCode":"const opts = clicks == null ? {} : { clickCount: Math.trunc(Number(clicks)) };\nif (opts.clickCount != null && !Number.isInteger(opts.clickCount)) throw new Error('clickCount must be an integer');\nawait page.mouse().down(opts);","typeGuard":"function isDownUpOptions(o) {\n  if (o == null) return true;\n  if (typeof o !== 'object') return false;\n  return (o.clickCount == null || Number.isInteger(o.clickCount)) && (o.button == null || typeof o.button === 'string');\n}","tryCatchPattern":"try { await page.mouse().down(opts); } catch (e) { if (/parsing mouse down options|clickCount must be an integer/.test(e.message)) { await page.mouse().down({ clickCount: parseInt(opts.clickCount, 10) }); } else throw e; }","preventionTips":["Pass clickCount as an integer literal; omit it for a single press.","Math.trunc computed counts before use.","Use identical normalized options for the matching mouse.up call."],"tags":["k6","browser","mouse","mouse-down","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"}