{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L826-L862","documentation":"Top-level wrapper for ElementHandle.Click. The click runs a pipeline — scroll into view, visible/stable/enabled actionability waits, hit-target check, mouse down/up, optional navigation wait — under opts.Timeout. Any pipeline failure surfaces as 'clicking on element: <cause>', most often a timeout waiting for actionability or 'another element is intercepting with pointer action'.","triggerScenarios":"handle.click() on an element that never becomes visible/stable/enabled within the timeout, an overlay intercepting the hit target (error:intercept), the element detaching mid-action, or the post-click navigation wait timing out.","commonSituations":"Cookie banners and modals covering the target; endlessly animating SPAs that never reach 'stable'; disabled buttons; default 30s timeout exceeded on slow environments; handles reused across re-renders.","solutions":["Increase the timeout option for the click","Pass { force: true } to skip actionability and hit-target checks when an overlay is expected and the click must still land","Dismiss intercepting overlays (cookie banners, loaders) before clicking","Re-locate the element immediately before clicking so it is fresh","Pass { noWaitAfter: true } if the post-click navigation wait is what times out"],"exampleFix":"// before\nawait handle.click({ timeout: 5000 }); // clicking on element: timeout\n\n// after\nawait page.$('#cookie-accept')?.click?.(); // clear overlay\nawait handle.click({ timeout: 30000 });\n// or, when the overlay is benign:\nawait handle.click({ force: true });","handlingStrategy":"retry","validationCode":"// Cheap pre-flight: the actionability checks click will run\nconst visible = await handle.isVisible();\nconst enabled = await handle.isEnabled();\nif (!visible || !enabled) throw new Error('element not actionable');","typeGuard":null,"tryCatchPattern":"try {\n  await handle.click({ timeout: 30000 });\n} catch (e) {\n  const msg = String(e);\n  if (msg.includes('intercepting')) {\n    await (await page.$('#cookie-accept')).click(); // clear overlay, retry\n    await handle.click({ timeout: 30000 });\n  } else if (msg.includes('timed out')) {\n    await handle.click({ force: true }); // last resort: skip checks\n  } else { throw e; }\n}","preventionTips":["Default to generous timeouts in CI","Handle cookie/banner overlays before main flows","Force-click only when interception is understood","Re-locate elements immediately before clicking"],"tags":["browser","click","actionability","timeout","intercept"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}