grafana/k6 · error
parsing element double click options: %w
Error message
parsing element double click options: %w
What it means
Thrown synchronously by ElementHandle.dblclick() when its options fail to parse. ElementHandleDblclickOptions embeds base-pointer options plus button, delay and modifiers; in common/element_handle_options.go the failing steps are exporting 'position' to map[string]float64 and 'modifiers' to []string. As with the other mapping methods, the (nil, error) return becomes a synchronous JS exception, not a promise rejection.
Source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:60
return promise(vu, func() (any, error) {
err := eh.Click(popts)
return nil, err //nolint:wrapcheck
}), nil
},
"contentFrame": func() *sobek.Promise {
return promise(vu, func() (any, error) {
f, err := eh.ContentFrame()
if err != nil {
return nil, err //nolint:wrapcheck
}
return mapFrame(vu, f), nil
})
},
"dblclick": func(opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleDblclickOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing element double click options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.Dblclick(popts) //nolint:wrapcheck
}), nil
},
"dispatchEvent": func(typ string, eventInit sobek.Value) *sobek.Promise {
return promise(vu, func() (any, error) {
return nil, eh.DispatchEvent(typ, exportArg(eventInit)) //nolint:wrapcheck
})
},
"fill": func(value string, opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing element fill options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.Fill(value, popts) //nolint:wrapcheck
}), nilView on GitHub (pinned to 93accf6570)
Solutions
- Pass position as { x: <number>, y: <number> } and modifiers as a string array
- Unpack boundingBox() results explicitly instead of passing the box or a string
- Normalize modifiers once (Array.isArray check) in a shared helper used by all actions
- Wrap in try/catch and match /parsing element double click options/ to distinguish option errors from runtime action errors
Example fix
// before
await el.dblclick({ modifiers: 'Ctrl', position: `${x},${y}` });
// after
await el.dblclick({ modifiers: ['Control'], position: { x: x, y: y } }); Defensive patterns
Strategy: type-guard
Validate before calling
if (opts?.position !== undefined &&
(typeof opts.position !== 'object' || Array.isArray(opts.position) ||
!Number.isFinite(Number(opts.position.x)) || !Number.isFinite(Number(opts.position.y)))) {
throw new Error('dblclick(): position must be { x: number, y: number }');
}
if (opts?.modifiers !== undefined &&
!(Array.isArray(opts.modifiers) && opts.modifiers.every(m => typeof m === 'string'))) {
throw new Error('dblclick(): modifiers must be an array of strings');
} Type guard
function isDblclickOpts(o) {
if (o == null) return true;
const posOk = o.position === undefined ||
(typeof o.position === 'object' && !Array.isArray(o.position) &&
Number.isFinite(Number(o.position.x)) && Number.isFinite(Number(o.position.y)));
const modOk = o.modifiers === undefined ||
(Array.isArray(o.modifiers) && o.modifiers.every(m => typeof m === 'string'));
return posOk && modOk;
} Try / catch
try {
await el.dblclick(opts);
} catch (e) {
if (/parsing element double click options/.test(String(e.message))) {
console.log(`fix dblclick options: ${e.message}`);
} else throw e;
} Prevention
- Unpack boundingBox() to { x, y } explicitly rather than passing derived strings or arrays
- Normalize modifiers once for click/dblclick/hover/tap via a shared helper
- The inner cause after the colon names the exact failing field; read it before changing code
When it happens
Trigger: el.dblclick({ position: 'center' }), { position: { x: 10 } } with y missing is fine (missing keys become 0) but { position: '10,20' } or { position: 42 } fails the ExportTo; { modifiers: 'Control' } or { modifiers: [true] } fails the []string export.
Common situations: Reusing a hover/click options literal across actions where one call site stored position as a serialized string; passing DOMRect values without unpacking to {x, y}; ported Playwright tests that compute modifiers dynamically and occasionally produce a single string.
Related errors
- parsing check options: %w
- parsing element click options: %w
- parsing element fill options: %w
- parsing element hover options: %w
- parsing element input value options: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/31f8d523775c4d1d.
Report an issue: GitHub.