{"record":{"id":"e65e1a8447f5ad2a","repo":"grafana/k6","slug":"tapping-on-q-w-e65e1a","errorCode":null,"errorMessage":"tapping on %q: %w","messagePattern":"tapping on %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/locator.go","lineNumber":620,"sourceCode":"\topts.Strict = true\n\topts.retry = true\n\tif err := l.frame.hover(l.selector, opts); err != nil {\n\t\treturn fmt.Errorf(\"hovering on %q: %w\", l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// Tap the element found that matches the locator's selector with strict mode on.\nfunc (l *Locator) Tap(opts *FrameTapOptions) error {\n\tl.log.Debugf(\"Locator:Tap\", \"fid:%s furl:%q sel:%q opts:%+v\", l.frame.ID(), l.frame.URL(), l.selector, opts)\n\n\topts.Strict = true\n\topts.retry = true\n\tif err := l.frame.tap(l.selector, opts); err != nil {\n\t\treturn fmt.Errorf(\"tapping on %q: %w\", l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// DispatchEvent dispatches an event for the element matching the\n// locator's selector with strict mode on.\nfunc (l *Locator) DispatchEvent(typ string, eventInit any, opts *FrameDispatchEventOptions) error {\n\tl.log.Debugf(\n\t\t\"Locator:DispatchEvent\", \"fid:%s furl:%q sel:%q typ:%q eventInit:%+v opts:%+v\",\n\t\tl.frame.ID(), l.frame.URL(), l.selector, typ, eventInit, opts,\n\t)\n\n\topts.Strict = true\n\tif err := l.frame.dispatchEvent(l.selector, typ, eventInit, opts); err != nil {\n\t\treturn fmt.Errorf(\"dispatching locator event %q to %q: %w\", typ, l.selector, err)","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/locator.go#L602-L638","documentation":"Thrown by Locator.Tap() when the wrapped frame.tap call fails. Strict mode is forced on and the call retries; the element must resolve to exactly one element and be tap-able (visible, stable, receiving touch events) before the timeout. Failures mirror hover: overlay intercepting pointer events, strict-mode violation, hidden/unstable element, or timeout.","triggerScenarios":"locator.tap() where the selector matches 0 or >1 elements; an element with pointer-events: none or covered by an overlay; element not visible or still animating past the timeout.","commonSituations":"Mobile-viewport tests tapping buttons under fixed footers or banners; tapping inside unexpanded panels; tests that assume touch works on desktop-like pages where the target is tiny or off-screen.","solutions":["Make the target visible and unobstructed (close overlays, expand panels)","Use a unique selector matching exactly one element","Scroll the element into view and wait for stability before tapping","Pass force: true in opts to bypass actionability checks if interception is expected"],"exampleFix":"// before\nawait page.locator('button.submit').tap(); // overlay intercepts touch\n\n// after\nawait page.locator('button.submit').waitFor();\nawait page.locator('.modal-backdrop').click({ force: true }); // dismiss overlay\nawait page.locator('button.submit').tap();","handlingStrategy":"try-catch","validationCode":"const el = page.locator('button.submit');\nawait el.waitFor({ state: 'visible' });\nawait el.tap();","typeGuard":"async function isTappable(page, sel) {\n  const handle = await page.$(sel);\n  if (!handle) return false;\n  const style = await handle.evaluate(n => getComputedStyle(n));\n  return style.pointerEvents !== 'none' && style.visibility !== 'hidden';\n}","tryCatchPattern":"try {\n  await page.locator(sel).tap();\n} catch (e) {\n  if (/intercepts pointer events|timeout/i.test(e.message)) {\n    await page.locator(sel).tap({ force: true });\n  } else throw e;\n}","preventionTips":["Set a mobile viewport in browser context options when scripting taps","Clear overlays before tap interactions","Use force:true deliberately for covered-but-intentional targets"],"tags":["browser","locator","touch","pointer-events","strict-mode"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}