{"record":{"id":"a9ac8ae39bc02a24","repo":"grafana/k6","slug":"w-w-a9ac8a","errorCode":null,"errorMessage":"%w: %w","messagePattern":"%w: %w","errorType":"exception","errorClass":"ErrElementNotVisible","httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":825,"sourceCode":"\t\t\tparts[i] = part.Body\n\t\t} else {\n\t\t\tparts[i] = part.Name + \"=\" + part.Body\n\t\t}\n\t}\n\n\treturn strings.Join(parts, \" >> \")\n}\n\n// AsElement returns this element handle.\nfunc (h *ElementHandle) AsElement() *ElementHandle {\n\treturn h\n}\n\n// BoundingBox returns this element's bounding box.\nfunc (h *ElementHandle) BoundingBox() (*Rect, error) {\n\tbbox, err := h.boundingBox()\n\tif err != nil && strings.Contains(err.Error(), \"Could not compute box model\") {\n\t\treturn nil, fmt.Errorf(\"%w: %w\", ErrElementNotVisible, err)\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting bounding box: %w\", err)\n\t}\n\treturn bbox, nil\n}\n\n// Click scrolls element into view and clicks in the center of the element\n// TODO: look into making more robust using retries\n// (see: https://github.com/microsoft/playwright/blob/master/src/server/dom.ts#L298)\nfunc (h *ElementHandle) Click(opts *ElementHandleClickOptions) error {\n\tclick := h.newPointerAction(\n\t\tfunc(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\t\treturn nil, handle.click(p, opts.ToMouseClickOptions())\n\t\t},\n\t\t&opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(h.ctx, click, opts.Timeout); err != nil {","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L807-L843","documentation":"BoundingBox() maps chromium's 'Could not compute box model' CDP failure to the sentinel ErrElementNotVisible joined with the underlying error, producing 'element is not visible: getting bounding box model of DOM node: ...'. Chromium cannot compute a box model for elements with no layout object — hidden, detached, or display:none nodes.","triggerScenarios":"boundingBox(), click, hover — anything needing geometry — on an element that is display:none/visibility:hidden, detached from the DOM, or otherwise has no layout object.","commonSituations":"Calling boundingBox() before render completes; element removed by a React/Vue re-render; element under a display:none ancestor; asserting geometry of hidden validation messages.","solutions":["Wait for the element to be visible before asking for geometry","Re-locate the element to get a live handle","In JS, match the 'element is not visible' prefix and treat it as a soft assertion rather than a hard failure","Ensure the element actually has layout (not display:none) when geometry is expected"],"exampleFix":"// before\nconst box = await handle.boundingBox(); // element is not visible: ...\n\n// after\nawait page.waitForSelector(sel, { state: 'visible' });\nconst box = await (await page.$(sel)).boundingBox();","handlingStrategy":"validation","validationCode":"if (!(await handle.isVisible())) {\n  await page.waitForSelector(sel, { state: 'visible' });\n  handle = await page.$(sel);\n}\nconst box = await handle.boundingBox();","typeGuard":null,"tryCatchPattern":"try {\n  const box = await handle.boundingBox();\n} catch (e) {\n  if (String(e).startsWith('element is not visible')) {\n    // soft-fail: element hidden, no geometry exists\n  } else { throw e; }\n}","preventionTips":["Never ask geometry of hidden elements; check isVisible() first","Re-locate handles after re-renders","Treat 'element is not visible' as an expected, matchable condition"],"tags":["browser","bounding-box","visibility","cdp"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}