{"record":{"id":"1ce202cdf489578d","repo":"grafana/k6","slug":"finding-offset-position-w","errorCode":null,"errorMessage":"finding offset position: %w","messagePattern":"finding offset position: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":443,"sourceCode":"\t\t}\n\t`\n\topts := evalOptions{\n\t\tforceCallable: true,\n\t\treturnByValue: true,\n\t}\n\tresult, err := h.evalWithScript(apiCtx, opts, fn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar border struct{ Top, Left float64 }\n\tif err := convert(result, &border); err != nil {\n\t\treturn nil, fmt.Errorf(\"converting result (%v of type %t) to border: %w\", result, result, err)\n\t}\n\n\tbox, err := h.BoundingBox()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"finding offset position: %w\", err)\n\t}\n\n\tif box == nil || (border.Left == 0 && border.Top == 0) {\n\t\treturn nil, ErrElementNotVisible\n\t}\n\n\t// Make point relative to the padding box to align with offsetX/offsetY.\n\treturn &Position{\n\t\tX: box.X + border.Left + offset.X,\n\t\tY: box.Y + border.Top + offset.Y,\n\t}, nil\n}\n\nfunc (h *ElementHandle) ownerFrame(apiCtx context.Context) (*Frame, error) {\n\tframeID, err := h.frame.page.getOwnerFrame(apiCtx, h)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L425-L461","documentation":"offsetPosition() calls BoundingBox() to anchor an offset-based click/hover point; this error wraps that failure. The wrapped error is usually 'element is not visible: ... Could not compute box model' for hidden, zero-layout, or detached elements.","triggerScenarios":"click()/dblclick()/hover() with a `position` option on an element that is display:none, has zero size, was detached, or whose bounding box otherwise cannot be computed.","commonSituations":"Offset-clicking before the element renders; element inside a collapsed iframe; stale handle after navigation; position coordinates outside the element on tiny elements.","solutions":["Wait for the element to be visible first (waitForSelector state 'visible')","Re-locate the element right before the action","Use { force: true } to skip actionability checks when the hidden state is intentional","Verify the position coordinates fall inside the element's box"],"exampleFix":"// before\nawait handle.click({ position: { x: 5, y: 5 } }); // finding offset position: element is not visible\n\n// after\nawait page.waitForSelector('#btn', { state: 'visible' });\nawait (await page.$('#btn')).click({ position: { x: 5, y: 5 } });","handlingStrategy":"validation","validationCode":"const box = await handle.boundingBox();\nif (!box || box.width === 0 || box.height === 0) {\n  await page.waitForSelector(sel, { state: 'visible' });\n}\nawait handle.click({ position: { x: 5, y: 5 } });","typeGuard":null,"tryCatchPattern":"try {\n  await handle.click({ position: pos });\n} catch (e) {\n  if (String(e).includes('finding offset position')) {\n    await handle.click(); // retry at center\n  } else { throw e; }\n}","preventionTips":["Ensure position coordinates lie inside the element box","Wait for visible before offset clicks","Re-locate handles before interacting"],"tags":["browser","element-handle","offset","visibility"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}