grafana/k6 · error
checking hit target at %v: %w
Error message
checking hit target at %v: %w
What it means
Before clicking, k6 may need to translate a point from iframe coordinates to page coordinates (translatePointToPage); the first step is ownerFrame(apiCtx), and if that frame-tree lookup fails, the point being checked is included in this wrapped error. It indicates the frame relationship could not be resolved while preparing the click.
Source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:96
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
}
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) {View on GitHub (pinned to 93accf6570)
Solutions
- Retry the click once after re-resolving the element — frame-tree hiccups are usually transient.
- Wait for the iframe to settle (a stable element visible inside it) before clicking.
- If the iframe is expendable (ad slot), catch this error and continue instead of failing the iteration.
- Reduce concurrent navigations inside the iframe during the click window.
Example fix
// before
await page.frameLocator('#widget').locator('#buy').click();
// -> checking hit target at {X:...,Y:...}: ...
// after
const buy = page.frameLocator('#widget').locator('#buy');
for (let i = 0; i < 2; i++) {
try { await buy.click(); break; }
catch (e) { if (i === 1 || !String(e).includes('checking hit target')) throw e; }
} Defensive patterns
Strategy: try-catch
Try / catch
try {
await iframeLocator.click();
} catch (e) {
if (/checking hit target at/.test(String(e))) {
await sleep(250); // let the frame tree settle
await iframeLocator.click(); // single retry with a re-resolved locator
} else {
throw e;
}
} Prevention
- Click into iframes only after their content is visible and stable.
- Keep iframe-locator expressions re-resolvable (frameLocator chains, not cached frame objects).
- Retain a one-retry policy for hit-target/coordinate errors — they are almost always races.
When it happens
Trigger: Clicking an element inside an iframe where resolving the owning frame fails — frame detaching, target destroyed, or the frame tree changing under k6 while it computes the click position.
Common situations: Clicks on elements in fast-changing iframes (embeds, ads, payment widgets); iframe navigation racing the click; popup iframes closed by page scripts right before the click.
Related errors
- getting position of parent frame: %w
- getting bounding box of parent frame: %w
- getting document element: nil document
- frame has been detached 1
- frame has been detached
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/e3dd91cb1f873ccb.
Report an issue: GitHub.