grafana/k6 · error

getting bounding box of parent frame: %w

Error message

getting bounding box of parent frame: %w

What it means

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.

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 93accf6570)

Solutions

  1. Ensure the iframe is visible and laid out (non-zero size) before clicking inside it.
  2. Re-query and retry the click once — the iframe box is usually measurable on a second attempt after layout settles.
  3. Wait for the iframe's content element to be actionable before the click.
  4. If the widget intentionally collapses, click earlier or wait for its expanded state.

Example fix

// before
await page.frameLocator('#chat-widget').locator('#send').click();
// iframe collapses to zero height -> getting bounding box of parent frame: ...

// after
const widget = page.locator('#chat-widget');
await widget.waitFor({ state: 'visible' });   // iframe expanded and sized
await page.frameLocator('#chat-widget').locator('#send').click();
Defensive patterns

Strategy: retry

Validate before calling

// ensure the iframe element is visible and sized before clicking inside it
const iframe = page.locator('#widget');
await iframe.waitFor({ state: 'visible' });
const box = await iframe.boundingBox();
if (!box || box.width === 0 || box.height === 0) {
  throw new Error('iframe has no layout box; cannot click inside it');
}

Try / catch

try {
  await frameLocator.locator(sel).click();
} catch (e) {
  if (/getting bounding box of parent frame/.test(String(e))) {
    await page.locator('#widget').waitFor({ state: 'visible' });
    await frameLocator.locator(sel).click(); // retry once the iframe is laid out
  } else {
    throw e;
  }
}

Prevention

When it happens

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

Common situations: Clicking elements in iframes that get hidden or unmounted during interaction (cookie banners collapsing, widgets minimizing); iframes styled invisible while still hosting content.

Related errors


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