{"record":{"id":"5b1b1ac1f1ee4842","repo":"grafana/k6","slug":"tapping-element-w","errorCode":null,"errorMessage":"tapping element: %w","messagePattern":"tapping element: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1505,"sourceCode":"\tif !ok {\n\t\treturn fmt.Errorf(\"unexpected type %T\", result)\n\t}\n\tif v != \"done\" {\n\t\treturn errorFromDOMError(v)\n\t}\n\n\treturn nil\n}\n\n// Tap scrolls element into view and taps in the center of the element.\nfunc (h *ElementHandle) Tap(opts *ElementHandleTapOptions) error {\n\ttap := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.tap(apiCtx, p)\n\t}\n\ttapAction := h.newPointerAction(tap, &opts.ElementHandleBasePointerOptions)\n\n\tif _, err := call(h.ctx, tapAction, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"tapping element: %w\", err)\n\t}\n\n\tapplySlowMo(h.ctx)\n\n\treturn nil\n}\n\nfunc (h *ElementHandle) tap(_ context.Context, p *Position) error {\n\treturn h.frame.page.Touchscreen.tap(p.X, p.Y)\n}\n\n// TextContent returns the text content of the element.\n// The second return value is true if the text content exists, and false otherwise.\nfunc (h *ElementHandle) TextContent() (string, bool, error) {\n\ttextContent := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.textContent(apiCtx)\n\t}\n\topts := NewElementHandleBaseOptions(h.DefaultTimeout())","sourceCodeStart":1487,"sourceCodeEnd":1523,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1487-L1523","documentation":"Wrapped failure from ElementHandle.Tap (elementHandle.tap()). Tap is a pointer action built by newPointerAction: scroll into view, actionability checks (visible/stable/enabled), hit-target check, then Touchscreen.tap dispatch. The wrapped error can originate at any of those stages — element not visible or without layout, unstable, intercepted by another element, or the CDP touch-event dispatch itself failing.","triggerScenarios":"Tapping an element covered by an overlay or sticky header (hit-target check fails with 'another element is intercepting with pointer action'); tapping a hidden/display:none element (scroll fails with 'Node does not have a layout object'); continuously animating element never becomes stable; timeout exceeded while retrying pointer checks.","commonSituations":"Cookie banners or modals covering the tap target; fixed headers intercepting after scrolling; mobile-emulated pages where the target moves on scroll; taps issued on pages without touch handlers so nothing responds as expected.","solutions":["Wait for the element first: page.waitForSelector(sel, { state: 'visible' }) and dismiss any covering overlay","Increase the timeout: el.tap({ timeout: '30s' })","If actionability checks are the blocker and interception is expected, use force: el.tap({ force: true })","If the tap target shifts after scroll, tap at an explicit position: el.tap({ position: { x: 10, y: 10 } })"],"exampleFix":"// before\npage.$('#btn').tap(); // overlay intercepts the tap\n\n// after\nconst banner = page.$('#cookie-banner');\nif (banner && banner.isVisible()) page.$('#accept').click();\npage.waitForSelector('#btn', { state: 'visible' }).tap({ timeout: '20s' });","handlingStrategy":"try-catch","validationCode":"const el = page.waitForSelector('#btn', { state: 'visible' });\nif (!el.isEnabled()) {\n  throw new Error('#btn is disabled; tap would fail actionability');\n}","typeGuard":null,"tryCatchPattern":"try {\n  el.tap({ timeout: '20s' });\n} catch (e) {\n  const msg = String(e);\n  if (msg.includes('intercepting')) {\n    page.$('#accept-cookies')?.click();\n    el.tap();\n  } else if (msg.includes('tapping element')) {\n    el.tap({ force: true }); // last resort: skip checks\n  } else {\n    throw e;\n  }\n}","preventionTips":["Dismiss cookie banners/modals before tapping","Wait for visible + enabled states before tap","Prefer tap on mobile-emulated pages where handlers listen for touch events"],"tags":["browser","touch","actionability","pointer-events","element-handle"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}