{"record":{"id":"9afc8c778e685b61","repo":"grafana/k6","slug":"checking-hit-target-w","errorCode":null,"errorMessage":"checking hit target: %w","messagePattern":"checking hit target: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1766,"sourceCode":"\t\t} else {\n\t\t\tp, err = h.clickablePoint()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"pointer action: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Further translation of the point might be necessary if the point\n\t\t// is still relative to the parent frame it is in and not the page.\n\t\t*p, err = h.translatePointToPage(apiCtx, *p)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"translating point to page: %w\", err)\n\t\t}\n\n\t\t// Do a final actionability check to see if element can receive events\n\t\t// at mouse position in question\n\t\tif !opts.Force {\n\t\t\tif ok, err := h.checkHitTargetAt(apiCtx, *p); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"checking hit target: %w\", err)\n\t\t\t}\n\t\t}\n\t\t// Are we only \"trialing\" the action but not actually performing\n\t\t// it (ie. running the actionability checks).\n\t\tif opts.Trial {\n\t\t\treturn nil, nil //nolint:nilnil\n\t\t}\n\n\t\tb := NewBarrier()\n\t\th.frame.manager.addBarrier(b)\n\t\tdefer h.frame.manager.removeBarrier(b)\n\t\tif res, err = fn(apiCtx, h, p); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"evaluating pointer action: %w\", err)\n\t\t}\n\t\t// Do we need to wait for navigation to happen\n\t\tif !opts.NoWaitAfter {\n\t\t\tif err = b.Wait(apiCtx); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"waiting for navigation: %w\", err)","sourceCodeStart":1748,"sourceCodeEnd":1784,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1748-L1784","documentation":"Final actionability stage of the k6 browser module's pointer-action pipeline (unless opts.Force): checkHitTargetAt evaluates the injected script at the computed point to verify the element (or a descendant) would actually receive the pointer event, recursing through iframes. When the check reports failure, the dominant cause is error:intercept — 'another element is intercepting pointer action' — i.e., a different node sits on top at that point; evaluation/context failures also surface here.","triggerScenarios":"click()/tap() when a cookie banner, modal backdrop, sticky header, spinner overlay, or chat widget covers the element; the element's center covered by its own child label/badge; hit-target evaluation failing because the frame navigated or the execution context was destroyed.","commonSituations":"Cookie-consent and GDPR banners on first visit; full-page loading overlays not fully faded (opacity animations) while checks pass 'visible/stable'; sticky navbars covering scrolled-to targets; elements whose clickable center falls on a covering pseudo-element.","solutions":["Dismiss the overlay first: click the consent/close button or wait for the overlay to detach: page.waitForSelector('.overlay', { state: 'detached' }).","Click a different spot of the element with { position: { x, y } } away from the covering child/overlay.","If interception is expected and acceptable, pass { force: true } to skip hit-target verification.","Ensure animations on overlays complete (wait for opacity/visibility transitions) before acting."],"exampleFix":"// before\nconst el = await page.$('#accept-terms');\nawait el.click(); // cookie banner covers the button\n\n// after\nawait page.click('#cookie-consent-accept', { timeout: '5s' }).catch(() => {});\nawait page.waitForSelector('.cookie-banner', { state: 'detached', timeout: '10s' }).catch(() => {});\nconst el = await page.waitForSelector('#accept-terms', { state: 'visible' });\nawait el.click();","handlingStrategy":"try-catch","validationCode":"// proactively remove known overlays before pointer actions\nawait page.click('#cookie-consent-accept', { timeout: '3s' }).catch(() => {});\nawait page.waitForSelector('.cookie-banner', { state: 'detached', timeout: '5s' }).catch(() => {});\nawait el.click();","typeGuard":null,"tryCatchPattern":"try {\n  await el.click({ timeout: '30s' });\n} catch (e) {\n  if (String(e).includes('intercept') || String(e).includes('checking hit target')) {\n    await el.click({ position: { x: 5, y: 5 } }); // try uncovered spot\n  } else { throw e; }\n}","preventionTips":["Standardize a consent-banner dismissal step at the start of every page flow.","Wait for fading overlays to fully detach, not just become transparent, before clicking.","Reserve force:true for cases where interception is understood and acceptable."],"tags":["k6","browser","element-handle","pointer-action","intercept","overlay"],"backgroundTag":"click-intercepted","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"}