{"record":{"id":"34ee0896280f7c82","repo":"grafana/k6","slug":"getting-bounding-box-model-of-dom-node-w","errorCode":null,"errorMessage":"getting bounding box model of DOM node: %w","messagePattern":"getting bounding box model of DOM node: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":68,"sourceCode":"\tframe *Frame\n}\n\n// String returns a string representation of ElementHandle.\n// It exists mostly for debugging where we don't want fmt.Sprintf to just\n// go through a complex object and try to stringify it.\nfunc (h *ElementHandle) String() string {\n\treturn \"ElementHandle{\" +\n\t\t\" BaseJSHandle:  \" + h.BaseJSHandle.String() +\n\t\t\" frame: \" + h.frame.String() +\n\t\t\"}\"\n}\n\nfunc (h *ElementHandle) boundingBox() (*Rect, error) {\n\tvar box *dom.BoxModel\n\tvar err error\n\taction := dom.GetBoxModel().WithObjectID(h.remoteObject.ObjectID)\n\tif box, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"getting bounding box model of DOM node: %w\", err)\n\t}\n\n\tif box == nil || box.Border == nil {\n\t\treturn nil, ErrElementNotAttachedToDOM\n\t}\n\n\tquad := box.Border\n\tx := math.Min(quad[0], math.Min(quad[2], math.Min(quad[4], quad[6])))\n\ty := math.Min(quad[1], math.Min(quad[3], math.Min(quad[5], quad[7])))\n\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","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L50-L86","documentation":"The CDP dom.GetBoxModel call failed for the element's remote object while computing its bounding box. This wraps a protocol error — commonly the node being detached from the DOM, an expired remote object, or a dropped session.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/element_handle.go:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-query the element before calling boundingBox()/screenshot()","Wait for the element to be attached: waitForSelector(sel, {state:'attached'})","Check for navigation that invalidated the element handle"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}