{"record":{"id":"e060d9c40e3edbec","repo":"grafana/k6","slug":"parsing-element-hover-options-w","errorCode":null,"errorMessage":"parsing element hover options: %w","messagePattern":"parsing element hover options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":100,"sourceCode":"\t\t\t\treturn nil, eh.Focus() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"getAttribute\": func(name string) *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := eh.GetAttribute(name)\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\tif !ok {\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\treturn s, nil\n\t\t\t})\n\t\t},\n\t\t\"hover\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleHoverOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element hover options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.Hover(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"innerHTML\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn eh.InnerHTML() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"innerText\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn eh.InnerText() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"inputValue\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L82-L118","documentation":"Thrown synchronously by ElementHandle.hover() when its options fail to parse. ElementHandleHoverOptions embeds base-pointer options plus modifiers; in common/element_handle_options.go the only failing steps are exporting 'position' to map[string]float64 and 'modifiers' to []string. The (nil, error) mapping return makes it a synchronous JS exception at call time.","triggerScenarios":"el.hover({ position: 'top' }) or { position: { x: '12px' } } (unit-suffixed string), and { modifiers: 'Alt' } or { modifiers: [null] }. trial/force/timeout never fail; unknown keys are ignored.","commonSituations":"CSS-style coordinate strings ('12px') copied from stylesheets or design specs; modifiers passed as a single string from a test-data table; dynamically built hover options where position is sometimes undefined and sometimes a serialized string.","solutions":["Pass { position: { x: 12, y: 34 } } with plain numbers and modifiers as ['Alt'] etc.","Strip units and coerce with parseInt/Number before building options","Add a small type guard (isPosition/isModifiers) in test setup code for all pointer-based actions","Use try/catch around the call; .catch() will not see this synchronous throw"],"exampleFix":"// before\nawait el.hover({ position: { x: '12px', y: '34px' }, modifiers: 'Alt' });\n\n// after\nawait el.hover({ position: { x: 12, y: 34 }, modifiers: ['Alt'] });","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('hover(): 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('hover(): modifiers must be an array of strings');\n  }\n}","typeGuard":"function isHoverOpts(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.hover(opts);\n} catch (e) {\n  if (/parsing element hover options/.test(String(e.message))) {\n    console.log(`fix hover options: ${e.message}`);\n  } else throw e;\n}","preventionTips":["Pass coordinates as plain numbers; strip CSS units like 'px' before building options","Spell modifiers as an array (['Alt']), never a single string","Catch with try/catch around the call: the throw is synchronous, not a promise rejection"],"tags":["k6","browser","element-handle","hover","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}