grafana/k6 · error

getting position of parent frame

Error message

getting position of parent frame: %w

What it means

While converting an element's box-model coordinates to page coordinates, frame.position() failed for the parent (likely OOP) iframe — typically because the iframe's layout object or execution context is unavailable (detached frame, not-yet-loaded OOP frame).

Solutions

  1. Wait for the frame to load before measuring (frame.waitForLoadState)
  2. Re-acquire the element handle after navigation
  3. Retry once the iframe finishes rendering
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/element_handle.go:83 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

	var err error
	action := dom.GetBoxModel().WithObjectID(h.remoteObject.ObjectID)
	if box, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {
		return nil, fmt.Errorf("getting bounding box model of DOM node: %w", err)
	}

	if box == nil || box.Border == nil {
		return nil, ErrElementNotAttachedToDOM
	}

	quad := box.Border
	x := math.Min(quad[0], math.Min(quad[2], math.Min(quad[4], quad[6])))
	y := math.Min(quad[1], math.Min(quad[3], math.Min(quad[5], quad[7])))
	width := math.Max(quad[0], math.Max(quad[2], math.Max(quad[4], quad[6]))) - x
	height := math.Max(quad[1], math.Max(quad[3], math.Max(quad[5], quad[7]))) - y

	position, err := h.frame.position()
	if err != nil {
		return nil, fmt.Errorf("getting position of parent frame: %w", err)
	}

	return &Rect{X: x + position.X, Y: y + position.Y, Width: width, Height: height}, nil
}

// translatePointToPage translates the point to the page's coordinates if the
// point is relative to the parent frame.
func (h *ElementHandle) translatePointToPage(apiCtx context.Context, point Position) (Position, error) {
	h.logger.Debugf("ElementHandle:translatePointToPage", "point before translation: %v", point)

	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

View on GitHub (pinned to 3fcf5388d7)