grafana/k6 · error

getting bounding box of parent frame

Error message

getting bounding box of parent frame: %w

What it means

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.

Solutions

  1. 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')
  2. Increase the action timeout option (e.g. el.click({ timeout: 30_000 })) so slow iframe rendering finishes first
  3. Scroll the iframe into view (el.scrollIntoViewIfNeeded()) before the pointer action
  4. If the iframe is intentionally hidden, make it visible first (remove display:none) or target a different element

Example fix

// before
const el = page.locator('#inside-iframe-btn');
await el.click(); // iframe not rendered yet

// after
await page.locator('iframe#my-iframe').waitFor({ state: 'visible' });
const frame = page.frame({ name: 'my-iframe' });
await frame.locator('#inside-iframe-btn').click({ timeout: 30_000 });
Defensive patterns

Strategy: retry

Validate before calling

// ensure the iframe itself is rendered before acting inside it
await page.locator('iframe#app').waitFor({ state: 'visible' });
const frame = page.frame({ name: 'app' });
if (frame === null) throw new Error('iframe frame not registered yet');

Try / catch

try {
  await el.click({ timeout: 10_000 });
} catch (e) {
  if (/getting bounding box of parent frame/.test(String(e))) {
    await page.waitForTimeout(1000); // let iframe settle
    await el.click({ timeout: 10_000 }); // one retry
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/2a4bbf186b279e07. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/element_handle.go:111

	frame, err := h.ownerFrame(apiCtx)
	if err != nil {
		return Position{}, fmt.Errorf("checking hit target at %v: %w", point, err)
	}

	if frame == nil || frame.parentFrame == nil {
		h.logger.Debugf("ElementHandle:translatePointToPage", "no parent frame")
		return point, nil
	}

	el, err := frame.FrameElement()
	if err != nil {
		return Position{}, err
	}

	box, err := el.BoundingBox()
	if err != nil {
		return Position{}, fmt.Errorf("getting bounding box of parent frame: %w", err)
	}

	if box.contains(point) {
		h.logger.Debugf("ElementHandle:translatePointToPage", "point is already in the page")
		return point, nil
	}

	// Translate from frame coordinates to page coordinates.
	point.X += box.X
	point.Y += box.Y

	h.logger.Debugf("ElementHandle:translatePointToPage", "point after translation: %v", point)

	return point, nil
}

// checkHitTargetAt checks if the element is hit by the pointer at the given point.
//

View on GitHub (pinned to 3fcf5388d7)