{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L93-L129","documentation":"Inside translatePointToPage, after resolving the owning frame k6 fetches the iframe's element via FrameElement() and calls BoundingBox() on it; a failure there is wrapped as 'getting bounding box of parent frame'. Without the iframe's page-relative box, the point cannot be translated from frame to page coordinates.","triggerScenarios":"The iframe element itself cannot be measured: iframe removed from the parent document, iframe hidden with display:none (zero-size/no box model), or the parent document navigated while the click point was being translated.","commonSituations":"Clicking elements in iframes that get hidden or unmounted during interaction (cookie banners collapsing, widgets minimizing); iframes styled invisible while still hosting content.","solutions":["Ensure the iframe is visible and laid out (non-zero size) before clicking inside it.","Re-query and retry the click once — the iframe box is usually measurable on a second attempt after layout settles.","Wait for the iframe's content element to be actionable before the click.","If the widget intentionally collapses, click earlier or wait for its expanded state."],"exampleFix":"// before\nawait page.frameLocator('#chat-widget').locator('#send').click();\n// iframe collapses to zero height -> getting bounding box of parent frame: ...\n\n// after\nconst widget = page.locator('#chat-widget');\nawait widget.waitFor({ state: 'visible' });   // iframe expanded and sized\nawait page.frameLocator('#chat-widget').locator('#send').click();","handlingStrategy":"retry","validationCode":"// ensure the iframe element is visible and sized before clicking inside it\nconst iframe = page.locator('#widget');\nawait iframe.waitFor({ state: 'visible' });\nconst box = await iframe.boundingBox();\nif (!box || box.width === 0 || box.height === 0) {\n  throw new Error('iframe has no layout box; cannot click inside it');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await frameLocator.locator(sel).click();\n} catch (e) {\n  if (/getting bounding box of parent frame/.test(String(e))) {\n    await page.locator('#widget').waitFor({ state: 'visible' });\n    await frameLocator.locator(sel).click(); // retry once the iframe is laid out\n  } else {\n    throw e;\n  }\n}","preventionTips":["Do not click inside zero-size or hidden iframes; wait for them to expand first.","Watch for collapsing widgets (chat, banners) and interact in their expanded state.","Prefer locator APIs over raw handles so frames and elements are re-resolved per attempt."],"tags":["iframe","bounding-box","click","layout","element-handle"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}