{"record":{"id":"e3dd91cb1f873ccb","repo":"grafana/k6","slug":"checking-hit-target-at-v-w","errorCode":null,"errorMessage":"checking hit target at %v: %w","messagePattern":"checking hit target at (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":96,"sourceCode":"\twidth := math.Max(quad[0], math.Max(quad[2], math.Max(quad[4], quad[6]))) - x\n\theight := math.Max(quad[1], math.Max(quad[3], math.Max(quad[5], quad[7]))) - y\n\n\tposition, err := h.frame.position()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting position of parent frame: %w\", err)\n\t}\n\n\treturn &Rect{X: x + position.X, Y: y + position.Y, Width: width, Height: height}, nil\n}\n\n// translatePointToPage translates the point to the page's coordinates if the\n// point is relative to the parent frame.\nfunc (h *ElementHandle) translatePointToPage(apiCtx context.Context, point Position) (Position, error) {\n\th.logger.Debugf(\"ElementHandle:translatePointToPage\", \"point before translation: %v\", point)\n\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) {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait page.frameLocator('#widget').locator('#buy').click();\n// -> checking hit target at {X:...,Y:...}: ...\n\n// after\nconst buy = page.frameLocator('#widget').locator('#buy');\nfor (let i = 0; i < 2; i++) {\n  try { await buy.click(); break; }\n  catch (e) { if (i === 1 || !String(e).includes('checking hit target')) throw e; }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await iframeLocator.click();\n} catch (e) {\n  if (/checking hit target at/.test(String(e))) {\n    await sleep(250);              // let the frame tree settle\n    await iframeLocator.click();   // single retry with a re-resolved locator\n  } else {\n    throw e;\n  }\n}","preventionTips":["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."],"tags":["iframe","frame","click","coordinates","element-handle"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}