{"record":{"id":"2a4bbf186b279e07","repo":"grafana/k6","slug":"getting-bounding-box-of-parent-frame-w","errorCode":null,"errorMessage":"getting bounding box of parent frame: %w","messagePattern":"getting bounding box of parent frame: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":111,"sourceCode":"\n\tframe, err := h.ownerFrame(apiCtx)\n\tif err != nil {\n\t\treturn Position{}, fmt.Errorf(\"checking hit target at %v: %w\", point, err)\n\t}\n\n\tif frame == nil || frame.parentFrame == nil {\n\t\th.logger.Debugf(\"ElementHandle:translatePointToPage\", \"no parent frame\")\n\t\treturn point, nil\n\t}\n\n\tel, err := frame.FrameElement()\n\tif err != nil {\n\t\treturn Position{}, err\n\t}\n\n\tbox, err := el.BoundingBox()\n\tif err != nil {\n\t\treturn Position{}, fmt.Errorf(\"getting bounding box of parent frame: %w\", err)\n\t}\n\n\tif box.contains(point) {\n\t\th.logger.Debugf(\"ElementHandle:translatePointToPage\", \"point is already in the page\")\n\t\treturn point, nil\n\t}\n\n\t// Translate from frame coordinates to page coordinates.\n\tpoint.X += box.X\n\tpoint.Y += box.Y\n\n\th.logger.Debugf(\"ElementHandle:translatePointToPage\", \"point after translation: %v\", point)\n\n\treturn point, nil\n}\n\n// checkHitTargetAt checks if the element is hit by the pointer at the given point.\n//","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L93-L129","documentation":"Thrown by ElementHandle.translatePointToPage while converting a click/hover point from iframe coordinates to page coordinates. After resolving the element's owner frame and its <iframe> FrameElement, computing that iframe element's bounding box failed. The %w tail carries the real cause, which is almost always the underlying CDP GetBoxModel failure for the iframe node.","triggerScenarios":"Calling a pointer action (click, dblclick, hover, check) on an element inside a nested frame while the parent <iframe> element is hidden (display:none), zero-sized, detached mid-action, or while its frame is still navigating; el.BoundingBox() on the FrameElement in translatePointToPage returns the error that gets wrapped here.","commonSituations":"Scripts that click inside iframes immediately after page load before the iframe has rendered; SPAs that lazily mount or resize iframes; iframes hidden behind tabs/accordions; CI runs where rendering is slow and the default timeout is too small.","solutions":["Wait for the iframe and its content to be visible before acting: page.frame({ name/id }) plus frame.waitForSelector on the target element, or use an explicit locator chain like page.locator('iframe[title=\"x\"] >> button')","Increase the action timeout option (e.g. el.click({ timeout: 30_000 })) so slow iframe rendering finishes first","Scroll the iframe into view (el.scrollIntoViewIfNeeded()) before the pointer action","If the iframe is intentionally hidden, make it visible first (remove display:none) or target a different element"],"exampleFix":"// before\nconst el = page.locator('#inside-iframe-btn');\nawait el.click(); // iframe not rendered yet\n\n// after\nawait page.locator('iframe#my-iframe').waitFor({ state: 'visible' });\nconst frame = page.frame({ name: 'my-iframe' });\nawait frame.locator('#inside-iframe-btn').click({ timeout: 30_000 });","handlingStrategy":"retry","validationCode":"// ensure the iframe itself is rendered before acting inside it\nawait page.locator('iframe#app').waitFor({ state: 'visible' });\nconst frame = page.frame({ name: 'app' });\nif (frame === null) throw new Error('iframe frame not registered yet');","typeGuard":null,"tryCatchPattern":"try {\n  await el.click({ timeout: 10_000 });\n} catch (e) {\n  if (/getting bounding box of parent frame/.test(String(e))) {\n    await page.waitForTimeout(1000); // let iframe settle\n    await el.click({ timeout: 10_000 }); // one retry\n  } else throw e;\n}","preventionTips":["Always wait for the iframe element (visible state) before interacting with elements inside it","Never interact inside iframes during or immediately after page navigation","Set action timeouts that account for slow iframe rendering in CI"],"tags":["browser","iframe","bounding-box","pointer-action","cdp"],"backgroundTag":"element-not-visible","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"}