{"record":{"id":"af156028f788e1ef","repo":"grafana/k6","slug":"hovering-on-element-w","errorCode":null,"errorMessage":"hovering on element: %w","messagePattern":"hovering on element: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":978,"sourceCode":"\ts, ok := v.(string)\n\tif !ok {\n\t\treturn \"\", false, fmt.Errorf(\n\t\t\t\"getting attribute %q of element: unexpected type %T (expecting string)\",\n\t\t\tname, v,\n\t\t)\n\t}\n\n\treturn s, true, nil\n}\n\n// Hover scrolls element into view and hovers over its center point.\nfunc (h *ElementHandle) Hover(opts *ElementHandleHoverOptions) error {\n\thover := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.hover(apiCtx, p)\n\t}\n\thoverAction := h.newPointerAction(hover, &opts.ElementHandleBasePointerOptions)\n\tif _, err := call(h.ctx, hoverAction, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"hovering on element: %w\", err)\n\t}\n\n\tapplySlowMo(h.ctx)\n\n\treturn nil\n}\n\n// InnerHTML returns the inner HTML of the element.\nfunc (h *ElementHandle) InnerHTML() (string, error) {\n\tinnerHTML := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.innerHTML(apiCtx)\n\t}\n\topts := NewElementHandleBaseOptions(h.DefaultTimeout())\n\tinnerHTMLAction := h.newAction(\n\t\t[]string{}, innerHTML, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tv, err := call(h.ctx, innerHTMLAction, opts.Timeout)\n\tif err != nil {","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L960-L996","documentation":"ElementHandle.hover() wraps the failure of a pointer action that scrolls the element into view, waits for it to be visible, stable, and able to receive pointer events, then moves the mouse to its center via the CDP Input domain. Timeouts on any of those waits, hit-test failures, or session errors get this prefix.","triggerScenarios":"Another element covers the target so the hit test fails ('other element would receive the event'); the element is hidden, zero-sized, or off-viewport; the element animates and never stabilizes; the handle is detached; the hover-capable parent is not hovered first so the child does not exist yet; the timeout option expires.","commonSituations":"Hover menus that only render after hovering the parent item; sticky headers/footers covering targets; banners and overlays; animation-heavy marketing pages; re-renders detaching the handle.","solutions":["Hover the parent/menu trigger first, then hover the revealed child","Wait for the element: await el.waitFor({ state: 'visible' }) before hovering","Use force: true to skip actionability and hit testing: await el.hover({ force: true })","Increase the timeout: await el.hover({ timeout: '60s' })","Re-query the element handle if the page re-rendered"],"exampleFix":"// before\nconst sub = await page.$('.menu .submenu-item');\nawait sub.hover(); // submenu not open / parent not hovered\n\n// after\nawait page.$('.menu .top-item').hover();\nconst sub = await page.$('.menu .submenu-item');\nawait sub.waitFor({ state: 'visible', timeout: '5s' });\nawait sub.hover();","handlingStrategy":"try-catch","validationCode":"// Open the menu and wait for the child before hovering\nawait page.$('.menu .top-item').hover();\nconst child = await page.waitForSelector('.menu .submenu-item', { state: 'visible', timeout: '5s' });\nawait child.hover();","typeGuard":null,"tryCatchPattern":"try {\n  await el.hover({ timeout: '10s' });\n} catch (e) {\n  const msg = String(e.message);\n  if (/timed out|would receive the event|not stable/i.test(msg)) {\n    await el.hover({ force: true }); // skip actionability + hit test\n  } else if (/Could not find object|not attached/i.test(msg)) {\n    const fresh = await page.$(sel);\n    await fresh.hover();\n  } else throw e;\n}","preventionTips":["Hover the parent trigger first when submenus only render on hover","waitFor({ state: 'visible' }) before hover","Disable animations in the test environment when possible to keep elements stable"],"tags":["browser","hover","mouse","actionability","action-timeout","k6"],"backgroundTag":"element-not-actionable","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}