{"record":{"id":"06e7ef780ba77672","repo":"grafana/k6","slug":"converting-result-v-of-type-t-to-border-w","errorCode":null,"errorMessage":"converting result (%v of type %t) to border: %w","messagePattern":"converting result \\((.+?) of type %t\\) to border: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":438,"sourceCode":"\nfunc (h *ElementHandle) offsetPosition(apiCtx context.Context, offset *Position) (*Position, error) {\n\tfn := `\n\t\t(node, injected) => {\n\t\t\treturn injected.getElementBorderWidth(node);\n\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","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L420-L456","documentation":"offsetPosition() converts the result of injected.getElementBorderWidth into struct{Top, Left float64}. This error means the eval result did not deserialize into that {top,left} shape. Note the message itself contains a formatting bug: %t (the bool verb) is used for the result argument, so the rendered type is garbage like %!t(string=...).","triggerScenarios":"click()/dblclick()/hover() with a `position` option (the offsetPosition path) when the border-width script returns undefined or a non-object — node is not an element anymore, execution context mismatch, or injected-script version skew.","commonSituations":"Offset clicks on elements in cross-origin iframes; stale handles; custom xk6 builds with mismatched injected script; also the %t verb makes diagnosing the real type harder.","solutions":["Retry after re-locating the element","Upgrade k6 so the injected script and Go module match","Avoid the offset path: omit `position` to click the element center","Report the %t formatting bug upstream (should be %T) when filing any reproduction"],"exampleFix":"// before\nawait handle.click({ position: { x: 10, y: 10 } }); // converting result ... to border\n\n// after\nawait handle.click(); // center click, avoids getElementBorderWidth path","handlingStrategy":"try-catch","validationCode":"// Pre-check the element still exists before an offset click\nconst attached = await handle.evaluate((el) => el.isConnected);\nif (!attached) throw new Error('element detached');","typeGuard":null,"tryCatchPattern":"try {\n  await handle.click({ position: { x: 10, y: 10 } });\n} catch (e) {\n  if (String(e).includes('to border')) {\n    await handle.click(); // fall back to center click\n  } else { throw e; }\n}","preventionTips":["Prefer center clicks; use position only when necessary","Re-locate elements before offset clicks","Report the %t format bug when filing reproductions"],"tags":["browser","element-handle","offset","injected-script","format-bug"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}