{"record":{"id":"d1fe663e297e7c13","repo":"grafana/k6","slug":"translating-point-to-page-w","errorCode":null,"errorMessage":"translating point to page: %w","messagePattern":"translating point to page: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1759,"sourceCode":"\n\t\t// Get the clickable point\n\t\tif p != nil {\n\t\t\tp, err = h.offsetPosition(apiCtx, opts.Position)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"getting element position: %w\", err)\n\t\t\t}\n\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)","sourceCodeStart":1741,"sourceCodeEnd":1777,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L1741-L1777","documentation":"Stage of the k6 browser module's pointer-action pipeline for elements inside iframes: translatePointToPage converts the click/tap point from frame-relative to page-relative coordinates when the owning frame has a parent. This error wraps failure of that translation: resolving the owner frame, getting the iframe's FrameElement, or reading that frame element's BoundingBox failed (frame navigated/closed, cross-origin frame access limits, or detached frame element).","triggerScenarios":"click()/tap() on elements inside an iframe whose document navigates or is removed between the state checks and the translation; iframes whose bounding box cannot be resolved (hidden iframe, display:none container); nested iframe hierarchies where an intermediate frame detaches.","commonSituations":"Payment/ad/auth widgets embedded in iframes that reload on their own schedule; tests acting in an iframe right as the host page rerenders the iframe element; iframes hidden via CSS until user action.","solutions":["Re-acquire the frame chain before acting: page.frame(...) or waitForSelector inside the frame, so owner frames are live.","Wait for the iframe itself to be visible and settled: ensure the iframe element has a bounding box before acting on its content.","Retry the action once — iframe navigation races are often transient.","If the widget navigates predictably (e.g., after an inner click), pair the trigger with waitForNavigation on the frame."],"exampleFix":"// before\nconst frame = page.frames().find(f => f.name() === 'widget');\nconst el = await frame.$('#pay');\nawait el.click(); // widget iframe reloaded mid-action -> translation fails\n\n// after\nawait page.waitForSelector('iframe[name=\"widget\"]', { state: 'visible' });\nconst frame = page.frames().find(f => f.name() === 'widget');\nconst el = await frame.waitForSelector('#pay', { state: 'visible' });\nawait el.click();","handlingStrategy":"retry","validationCode":"const frameEl = await page.waitForSelector('iframe[name=\"widget\"]', { state: 'visible', timeout: '30s' });\nconst box = await frameEl.boundingBox();\nif (!box) { throw new Error('iframe has no bounding box; skip in-frame action'); }\nconst frame = page.frames().find(f => f.name() === 'widget');\nconst el = await frame.waitForSelector(sel, { state: 'visible' });\nawait el.click();","typeGuard":null,"tryCatchPattern":"for (let i = 0; i < 2; i++) {\n  try { await el.click(); break; }\n  catch (e) {\n    if (i === 1 || !String(e).includes('translating point to page')) throw e;\n    // iframe may have navigated: rebuild the frame chain and handle\n    const frame = page.frames().find(f => f.name() === frameName);\n    el = await frame.waitForSelector(sel, { state: 'visible' });\n  }\n}","preventionTips":["Verify the iframe element itself is visible and has a box before acting inside it.","Rebuild frame references after any in-frame navigation; never cache frames across reloads."],"tags":["k6","browser","element-handle","iframe","pointer-action","coordinates"],"backgroundTag":"iframe-navigation","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"}