{"record":{"id":"6df6644fbd19f543","repo":"grafana/k6","slug":"parsing-element-handle-click-option-modifiers-w","errorCode":null,"errorMessage":"parsing element handle click option modifiers: %w","messagePattern":"parsing element handle click option modifiers: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle_options.go","lineNumber":309,"sourceCode":"\n\tif common.IsNullish(opts) {\n\t\treturn nil\n\t}\n\n\trt := k6ext.Runtime(ctx)\n\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tswitch k {\n\t\tcase optionButton:\n\t\t\to.Button = obj.Get(k).String()\n\t\tcase optionClickCount:\n\t\t\to.ClickCount = obj.Get(k).ToInteger()\n\t\tcase optionDelay:\n\t\t\to.Delay = obj.Get(k).ToInteger()\n\t\tcase optionModifiers:\n\t\t\tvar m []string\n\t\t\tif err := rt.ExportTo(obj.Get(k), &m); err != nil {\n\t\t\t\treturn fmt.Errorf(\"parsing element handle click option modifiers: %w\", err)\n\t\t\t}\n\t\t\to.Modifiers = m\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (o *ElementHandleClickOptions) ToMouseClickOptions() *MouseClickOptions {\n\to2 := NewMouseClickOptions()\n\to2.Button = o.Button\n\to2.ClickCount = o.ClickCount\n\to2.Delay = o.Delay\n\treturn o2\n}\n\nfunc NewElementHandleDblclickOptions(defaultTimeout time.Duration) *ElementHandleDblclickOptions {\n\treturn &ElementHandleDblclickOptions{","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle_options.go#L291-L327","documentation":"Parsing the modifiers option of ElementHandle click-family options failed to export the value to []string. modifiers must be an array whose entries are strings (the recognized names are 'Alt', 'Control', 'Shift', 'Meta'); a non-array value or an array containing non-string entries makes rt.ExportTo fail.","triggerScenarios":"page.click('#id', { modifiers: 'Alt' }) — a bare string instead of an array; { modifiers: [1, 2] } with non-string entries; { modifiers: { Alt: true } } object form; dynamically built arrays that picked up null/undefined entries.","commonSituations":"Assuming a single modifier can be passed as a plain string; copying option shapes from other automation tools; building modifiers at runtime with push() of unvalidated values.","solutions":["Always pass modifiers as an array of strings: { modifiers: ['Shift'] }","Use the exact names 'Alt', 'Control', 'Shift', 'Meta'","If building dynamically, coerce each entry with String() and filter empties before passing"],"exampleFix":"// before\nawait page.click('#btn', { modifiers: 'Shift' });\n\n// after\nawait page.click('#btn', { modifiers: ['Shift'] });","handlingStrategy":"validation","validationCode":"const allowed = ['Alt', 'Control', 'Shift', 'Meta'];\nconst opts = { modifiers: ['Shift'] };\nconst valid = Array.isArray(opts.modifiers) && opts.modifiers.every(m => typeof m === 'string' && allowed.includes(m));\nif (!valid) throw new Error('modifiers must be an array of Alt|Control|Shift|Meta');\nawait page.click('#btn', opts);","typeGuard":"function isModifierList(v) {\n  const allowed = ['Alt', 'Control', 'Shift', 'Meta'];\n  return v === undefined || (Array.isArray(v) && v.every(m => typeof m === 'string' && allowed.includes(m)));\n}","tryCatchPattern":null,"preventionTips":["modifiers is always an array, even for a single key","Spell modifiers exactly 'Alt', 'Control', 'Shift', 'Meta'","Validate option objects built at runtime before passing them"],"tags":["browser","options","click","type-mismatch"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}