{"record":{"id":"410fac160f2d15d1","repo":"grafana/k6","slug":"clicking-on-element-w","errorCode":null,"errorMessage":"clicking on element: %w","messagePattern":"clicking on element: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":844,"sourceCode":"\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting bounding box: %w\", err)\n\t}\n\treturn bbox, nil\n}\n\n// Click scrolls element into view and clicks in the center of the element\n// TODO: look into making more robust using retries\n// (see: https://github.com/microsoft/playwright/blob/master/src/server/dom.ts#L298)\nfunc (h *ElementHandle) Click(opts *ElementHandleClickOptions) error {\n\tclick := h.newPointerAction(\n\t\tfunc(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\t\treturn nil, handle.click(p, opts.ToMouseClickOptions())\n\t\t},\n\t\t&opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(h.ctx, click, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"clicking on element: %w\", err)\n\t}\n\tapplySlowMo(h.ctx)\n\n\treturn nil\n}\n\n// ContentFrame returns the frame that contains this element.\nfunc (h *ElementHandle) ContentFrame() (*Frame, error) {\n\tvar (\n\t\tnode *cdp.Node\n\t\terr  error\n\t)\n\taction := dom.DescribeNode().WithObjectID(h.remoteObject.ObjectID)\n\tif node, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"getting remote node %q: %w\", h.remoteObject.ObjectID, err)\n\t}\n\tif node == nil || node.FrameID == \"\" {\n\t\treturn nil, fmt.Errorf(\"element is not an iframe\")","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L826-L862","documentation":"Top-level failure wrapper for ElementHandle.Click: the whole click action (scroll into view, hit-target check, pointer dispatch) did not complete within opts.Timeout or failed otherwise. The wrapped error carries the actual cause — timeout, interception ('another element is intercepting...'), element not visible, or detached — so read the tail before acting.","triggerScenarios":"el.click() where the element never becomes actionable in the timeout window: overlays intercepting, element animating/moving, hidden, detached by SPA re-render, or the action's call(h.ctx, click, opts.Timeout) hitting the deadline at element_handle.go:842.","commonSituations":"Cookie banners/modals covering CTAs; buttons disabled or replaced mid-click in React/Vue apps; default timeouts too short on slow CI; clicks immediately after goto before hydration.","solutions":["Read the wrapped cause: 'intercepting' → remove/dismiss the overlay; 'not visible' → wait for visible; 'timed out' → raise the timeout","Wait for actionability explicitly: await el.waitFor({ state: 'visible' }) and await el.scrollIntoViewIfNeeded() before click","Pass a bigger timeout: el.click({ timeout: 30_000 }) or page.setDefaultTimeout(30_000)","If an overlay is decorative and unremovable, use el.click({ force: true }) to bypass the hit-target check"],"exampleFix":"// before\nawait page.locator('#buy').click();\n\n// after\nconst el = page.locator('#buy');\nawait el.waitFor({ state: 'visible' });\nawait el.scrollIntoViewIfNeeded();\nawait el.click({ timeout: 30_000 });","handlingStrategy":"retry","validationCode":"const el = page.locator('#buy');\nawait el.waitFor({ state: 'visible', timeout: 10_000 });\nawait el.scrollIntoViewIfNeeded();","typeGuard":null,"tryCatchPattern":"try {\n  await el.click({ timeout: 10_000 });\n} catch (e) {\n  const msg = String(e);\n  if (/intercepting/.test(msg)) { await el.click({ force: true }); }\n  else if (/not visible|timed out/.test(msg)) {\n    await el.waitFor({ state: 'visible' });\n    await el.click({ timeout: 30_000 });\n  } else throw e;\n}","preventionTips":["Always waitFor visible (and scrollIntoViewIfNeeded) before clicks on dynamic pages","Dismiss overlays in setup steps","Set page.setDefaultTimeout sized to your app's slowest interaction"],"tags":["browser","click","action-timeout","overlay","actionability"],"backgroundTag":"browser-click-timeout","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"}