grafana/k6 · error
converting result ( of type %t) to border
Error message
converting result (%v of type %t) to border: %w
What it means
offsetPosition() runs the injected getElementBorderWidth script and converts the result to a {Top, Left float64} border struct; convert() failed, meaning the JS returned something unconvertible (null, strings, or a differently-shaped object). Note the message itself has a formatting bug: %t is applied to a non-bool value, so the type prints as %!t(...) garbage.
Solutions
- Ensure the element is rendered and laid out before using a pos offset: await el.waitFor({ state: 'visible' })
- Prefer plain click() (center of the element) when you don't truly need an offset
- If an offset is required, verify the element's border style is computable (not display:none, not detached shadow DOM)
- File a k6 issue about the garbled %t formatting so the real type is logged
Example fix
// before
await el.click({ pos: { x: 10, y: 10 } }); // element hidden
// after
await el.waitFor({ state: 'visible' });
await el.click(); // center click, no offset conversion needed Defensive patterns
Strategy: validation
Validate before calling
// only use pos offsets on laid-out, visible standard elements
await el.waitFor({ state: 'visible' });
const box = await el.boundingBox();
if (!box) throw new Error('element not laid out; skip pos offset'); Try / catch
try {
await el.click({ pos: { x: 5, y: 5 } });
} catch (e) {
if (/to border/.test(String(e))) {
await el.click(); // fall back to center click
} else throw e;
} Prevention
- Avoid pos offsets on custom elements and closed shadow DOM
- Ensure elements are rendered before offset-based clicks
When it happens
Trigger: Using click({ pos: { x, y } }) / pointer options with an offset on an element where getElementBorderWidth returns null or a non-numeric shape: custom elements, elements whose computed style is unavailable (in a detached shadow root or display:none), or pages stubbing getComputedStyle.
Common situations: Clicking by offset on custom web components or elements in closed shadow DOM; offset clicks on elements that are not yet laid out; k6 versions before the offset path was hardened — the mangled %t output makes logs confusing regardless of cause.
Related errors
- finding offset position
- another element is intercepting with pointer action
- clicking on element
- finding clickable point
- parsing click options
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/06e7ef780ba77672.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:438
func (h *ElementHandle) offsetPosition(apiCtx context.Context, offset *Position) (*Position, error) {
fn := `
(node, injected) => {
return injected.getElementBorderWidth(node);
}
`
opts := evalOptions{
forceCallable: true,
returnByValue: true,
}
result, err := h.evalWithScript(apiCtx, opts, fn)
if err != nil {
return nil, err
}
var border struct{ Top, Left float64 }
if err := convert(result, &border); err != nil {
return nil, fmt.Errorf("converting result (%v of type %t) to border: %w", result, result, err)
}
box, err := h.BoundingBox()
if err != nil {
return nil, fmt.Errorf("finding offset position: %w", err)
}
if box == nil || (border.Left == 0 && border.Top == 0) {
return nil, ErrElementNotVisible
}
// Make point relative to the padding box to align with offsetX/offsetY.
return &Position{
X: box.X + border.Left + offset.X,
Y: box.Y + border.Top + offset.Y,
}, nil
}
View on GitHub (pinned to 3fcf5388d7)