grafana/k6 · error
parsing setChecked options: %w
Error message
parsing setChecked options: %w
What it means
Thrown synchronously by ElementHandle.setChecked() when its options fail to parse. setChecked uses ElementHandleSetCheckedOptions, which embeds the base-pointer options; in common/element_handle_options.go the only Parse step that can return an error is exporting 'position' to map[string]float64 (strict/force/noWaitAfter/timeout/trial are lenient coercions). The mapping returns (nil, error), so it throws at call time rather than rejecting a promise.
Source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:224
return nil, fmt.Errorf("parsing selectOption options: %w", err)
}
return promise(vu, func() (any, error) {
return eh.SelectOption(convValues, popts) //nolint:wrapcheck
}), nil
},
"selectText": func(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 selectText options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SelectText(popts) //nolint:wrapcheck
}), nil
},
"setChecked": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing setChecked options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SetChecked(checked, popts) //nolint:wrapcheck
}), nil
},
"setInputFiles": func(files sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleSetInputFilesOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing setInputFiles options: %w", err)
}
var pfiles common.Files
if err := pfiles.Parse(vu.Context(), files); err != nil {
return nil, fmt.Errorf("parsing setInputFiles parameter: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.SetInputFiles(&pfiles, popts) //nolint:wrapcheck
}), nil
},View on GitHub (pinned to 93accf6570)
Solutions
- Pass position as { x: <number>, y: <number> } or omit it
- Coerce fixture coordinates with Number() and validate with Number.isFinite
- Guard options with a shared isPosition check for all pointer-based element actions
- Use try/catch around the call since the throw is synchronous
Example fix
// before
await el.setChecked(true, { position: 'center', strict: true });
// after
await el.setChecked(true, { strict: true }); Defensive patterns
Strategy: type-guard
Validate before calling
const p = opts?.position;
if (p !== undefined && (typeof p !== 'object' || Array.isArray(p) ||
!Number.isFinite(Number(p.x)) || !Number.isFinite(Number(p.y)))) {
throw new Error('setChecked(): position must be { x: number, y: number }');
} Type guard
function isSetCheckedOpts(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 strictOk = o.strict === undefined || typeof o.strict === 'boolean';
return posOk && strictOk;
} Try / catch
try {
await el.setChecked(shouldCheck, opts);
} catch (e) {
if (/parsing setChecked options/.test(String(e.message))) {
console.log(`fix setChecked options: ${e.message}`);
} else throw e;
} Prevention
- Only position can fail parsing here; strict is a lenient boolean coercion
- Share one options builder between check/setChecked/uncheck so position stays numeric everywhere
- Use try/catch: the error is thrown synchronously, not via promise rejection
When it happens
Trigger: el.setChecked(true, { position: 'center' }), { position: { x: '1', y: 2 } }, or position as array/number/boolean. Everything else in the options object is coerced and cannot produce this error.
Common situations: Sharing one options literal between click() and setChecked() where the position field was serialized to a string; coordinate values coming from CSV/JSON fixtures without numeric conversion.
Related errors
- parsing check options: %w
- parsing element click options: %w
- parsing element double click options: %w
- parsing element fill options: %w
- parsing element hover options: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/1f88f6ca3e106ae2.
Report an issue: GitHub.