{"record":{"id":"987534ecb30297cd","repo":"grafana/k6","slug":"finding-clickable-point-w","errorCode":null,"errorMessage":"finding clickable point: %w","messagePattern":"finding clickable point: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":219,"sourceCode":"\tcase bool:\n\t\treturn &v, nil\n\t}\n\n\treturn nil, fmt.Errorf(\n\t\t\"checking state %q of element %q\", state, reflect.TypeOf(result))\n}\n\nfunc (h *ElementHandle) click(p *Position, opts *MouseClickOptions) error {\n\treturn h.frame.page.Mouse.click(p.X, p.Y, opts)\n}\n\n// This will get the clickable point of the element relative to the page even\n// when the element is in an iframe. In some cases this isn't the case and we\n// need to translate the point to the page.\nfunc (h *ElementHandle) clickablePoint() (*Position, error) {\n\tr, err := h.BoundingBox()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"finding clickable point: %w\", err)\n\t}\n\treturn &Position{X: r.X + r.Width/2, Y: r.Y + r.Height/2}, nil\n}\n\nfunc (h *ElementHandle) dblclick(p *Position, opts *MouseClickOptions) error {\n\treturn h.frame.page.Mouse.click(p.X, p.Y, opts)\n}\n\n// DefaultTimeout returns the default timeout for this element handle.\n// If the receiver or any of the chained fields are nil (which can happen\n// when the element handle is no longer attached to a live frame), the\n// package-level DefaultTimeout constant is returned instead of panicking.\nfunc (h *ElementHandle) DefaultTimeout() time.Duration {\n\tif h == nil || h.frame == nil || h.frame.manager == nil || h.frame.manager.timeoutSettings == nil {\n\t\treturn DefaultTimeout\n\t}\n\treturn h.frame.manager.timeoutSettings.timeout()\n}","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L201-L237","documentation":"clickablePoint() computes the center of the element from its bounding box before a pointer action; this error means BoundingBox() failed for the element. The wrapped cause is typically ErrElementNotVisible (box model not computable), ErrElementNotAttachedToDOM, or a CDP/session error.","triggerScenarios":"Calling click/dblclick/hover/check on an element with display:none or visibility:hidden, a zero-size element, an element detached from the DOM between resolution and action, or after the page/target has crashed or navigated away.","commonSituations":"Clicking buttons in hidden tabs, accordions, or carousel slides; elements behind 'display:none until animation completes'; acting on stale handles grabbed before a navigation; headless environments where fonts/layout differ and the element collapses to 0x0.","solutions":["Wait for the element to be actionable before clicking: await el.waitFor({ state: 'visible' }) or use locators, which auto-wait","Scroll into view first with el.scrollIntoViewIfNeeded()","If the element is animated, wait for it to finish (wait for opacity/size via el.waitFor() or a custom wait)","Re-query the element fresh after any navigation instead of reusing an old handle"],"exampleFix":"// before\nconst el = page.locator('.hidden-tab >> text=Save');\nawait el.click();\n\n// after\nawait page.locator('.tab-handle').click(); // reveal the tab first\nconst el = page.locator('.hidden-tab >> text=Save');\nawait el.waitFor({ state: 'visible' });\nawait el.click();","handlingStrategy":"validation","validationCode":"if (!(await el.isVisible())) {\n  await el.waitFor({ state: 'visible', timeout: 10_000 });\n}\nconst box = await el.boundingBox();\nif (!box || box.width === 0 || box.height === 0) {\n  throw new Error('element has no clickable area');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always waitFor visible before click/hover on lazily shown elements","Check for zero-size bounding boxes before pointer actions on animated elements","Re-query elements after navigations; never reuse stale handles"],"tags":["browser","click","bounding-box","element-not-visible"],"backgroundTag":"element-not-visible","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"}