grafana/k6 · error
parsing select option options: %w
Error message
parsing select option options: %w
What it means
Thrown when locator.selectOption(values, opts) cannot parse its second (options) argument into FrameSelectOptionOptions, which embeds ElementHandleBaseOptions (force, noWaitAfter booleans; timeout number in ms) plus a strict boolean. The mapping wraps the cause as 'parsing select option options: %w'. This is separate from the values argument error ('parsing select option values') — it only concerns the trailing options object.
Source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:358
if !ok {
return nil, nil
}
return s, nil
}), nil
},
"inputValue": func(opts sobek.Value) (*sobek.Promise, error) {
copts := common.NewFrameInputValueOptions(lo.Timeout())
if err := copts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing input value options: %w", err)
}
return promise(vu, func() (any, error) {
return lo.InputValue(copts) //nolint:wrapcheck
}), nil
},
"selectOption": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
copts := common.NewFrameSelectOptionOptions(lo.Timeout())
if err := copts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing select option options: %w", err)
}
convValues, err := ConvertSelectOptionValues(vu.Runtime(), values)
if err != nil {
return nil, fmt.Errorf("parsing select option values: %w", err)
}
return promise(vu, func() (any, error) {
return lo.SelectOption(convValues, copts) //nolint:wrapcheck
}), nil
},
"press": func(key string, opts sobek.Value) (*sobek.Promise, error) {
copts := common.NewFramePressOptions(lo.Timeout())
if err := copts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing press options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.Press(key, copts) //nolint:wrapcheck
}), nil
},View on GitHub (pinned to 93accf6570)
Solutions
- Pass the options object as the second argument: selectOption('blue', { timeout: 5000 })
- Keep only supported keys: force, noWaitAfter, strict, timeout (numeric ms)
- Omit the second argument when defaults are fine
- Verify argument order: values first, options second
Example fix
// before
await page.locator('select.color').selectOption('blue', '5s');
// after
await page.locator('select.color').selectOption('blue', { timeout: 5000 }); Defensive patterns
Strategy: validation
Validate before calling
function assertSelectOptionOpts(opts) {
if (opts === null || opts === undefined) return;
if (typeof opts !== 'object' || Array.isArray(opts)) {
throw new TypeError('selectOption options must be a plain object');
}
const okKeys = new Set(['force', 'noWaitAfter', 'strict', 'timeout']);
for (const k of Object.keys(opts)) {
if (!okKeys.has(k)) continue; // unknown keys are ignored by the parser
const t = typeof opts[k];
if (k === 'timeout' && t !== 'number') throw new TypeError('timeout must be a number (ms)');
if (k !== 'timeout' && t !== 'boolean') throw new TypeError(`${k} must be a boolean`);
}
} Type guard
function isSelectOptionOptions(v) {
if (v === null || v === undefined) return true;
if (typeof v !== 'object' || Array.isArray(v)) return false;
return (v.timeout === undefined || typeof v.timeout === 'number') &&
(v.force === undefined || typeof v.force === 'boolean') &&
(v.noWaitAfter === undefined || typeof v.noWaitAfter === 'boolean') &&
(v.strict === undefined || typeof v.strict === 'boolean');
} Try / catch
try {
await locator.selectOption(values, opts);
} catch (e) {
if (/parsing select option options/.test(String(e.message))) {
throw new Error(`Bad selectOption options (second argument): ${JSON.stringify(opts)}`);
}
throw e;
} Prevention
- Remember the signature: values first, options object second
- Do not reuse click options (position/modifiers) for selectOption
- Use numeric millisecond timeouts
When it happens
Trigger: Calling locator.selectOption('blue', 'fast') or selectOption('blue', 30000) — a scalar in the opts slot; passing { timeout: '1s' } under strict parsing; passing a third positional argument where only two exist.
Common situations: Chaining selectOption with a timeout string copied from documentation examples; reusing click() options (with position/modifiers) that selectOption does not read; migrating from Playwright where option shapes differ slightly.
Related errors
- parsing get attribute options: %w
- parsing inner HTML options: %w
- parsing inner text options: %w
- parsing text content options: %w
- parsing input value options: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/84933e40de375139.
Report an issue: GitHub.