grafana/k6 · error
parsing select options values
Error message
parsing select options values: %w
What it means
Thrown when the `values` argument of `frame.selectOption(selector, values, opts)` cannot be converted by ConvertSelectOptionValues. Accepted shapes: a single string, a single object {value?, label?, index?}, an ElementHandle, or an array mixing strings and such objects. Rejections: array items that are numbers/booleans/null ('options: expected string or object, got %T'), value/label not strings ('options[value]: expected string, got %T'), index not an integer ('options[index]: expected int, got %T'), or a top-level unsupported type like a number ('options: unsupported type').
Solutions
- Wrap numeric selections in objects: [{ index: 1 }] instead of [1]
- Ensure value/label are strings and index is an integer
- Validate/normalize the values array before the call when it comes from external data
Example fix
// before
await frame.selectOption('#qty', [2, { value: 'xl' }]);
// after
await frame.selectOption('#qty', [{ index: 2 }, { value: 'xl' }]); Defensive patterns
Strategy: type-guard
Validate before calling
function normalizeSelectValues(values) {
const arr = Array.isArray(values) ? values : [values];
return arr.map(v => {
if (typeof v === 'string') return v;
if (v && typeof v === 'object' && !Array.isArray(v)) {
if (v.value !== undefined && typeof v.value !== 'string') throw new Error('value must be a string');
if (v.label !== undefined && typeof v.label !== 'string') throw new Error('label must be a string');
if (v.index !== undefined && !Number.isInteger(v.index)) throw new Error('index must be an integer');
return v;
}
if (typeof v === 'number') return { index: v };
throw new Error(`unsupported select option value: ${JSON.stringify(v)}`);
});
} Type guard
function isSelectOptionValue(v) {
if (typeof v === 'string') return true;
if (v == null || typeof v !== 'object' || Array.isArray(v)) return false;
const { value, label, index } = v;
return (value === undefined || typeof value === 'string') &&
(label === undefined || typeof label === 'string') &&
(index === undefined || Number.isInteger(index));
} Try / catch
try {
await frame.selectOption(sel, values, opts);
} catch (e) {
if (String(e).includes('parsing select options values')) {
console.error('values must be string | {value?,label?,index?} | ElementHandle, or an array of these');
throw e;
}
throw e;
} Prevention
- Wrap bare numbers as { index: n } — plain numbers in the array are rejected
- value and label must be strings; index must be an integer (no floats)
- Sanitize data-driven option lists before the call
When it happens
Trigger: `frame.selectOption('#s', [1, 2])` (numeric indexes must be objects: [{index: 1}]); `frame.selectOption('#s', [{ value: 42 }])`; `frame.selectOption('#s', true)`; float index `{ index: 1.5 }`.
Common situations: Porting from Playwright where numbers in arrays are also rejected — but developers commonly build option arrays dynamically from JSON data where numbers sneak in; passing booleans or null from loose data parsing.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- parsing select option options
- parsing select option values
- an error occurred communicating with k6 Cloud
- " " attribute is only supported for roles: "`).join(", ")}
- " " does not support " " matcher
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/fc225a29c8309c85.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:338
},
"press": func(selector, key string, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFramePressOptions(rt, opts, f.Timeout())
if err != nil {
return nil, fmt.Errorf("parse press options of selector %q on key %q: %w", selector, key, err)
}
return promise(vu, func() (any, error) {
return nil, f.Press(selector, key, popts) //nolint:wrapcheck
}), nil
},
"selectOption": func(selector string, values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameSelectOptionOptions(rt, opts, f.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing select option options: %w", err)
}
convValues, err := ConvertSelectOptionValues(rt, values)
if err != nil {
return nil, fmt.Errorf("parsing select options values: %w", err)
}
return promise(vu, func() (any, error) {
return f.SelectOption(selector, convValues, popts) //nolint:wrapcheck
}), nil
},
"setChecked": func(selector string, checked bool, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameCheckOptions(rt, opts, f.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing frame set check options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, f.SetChecked(selector, checked, popts) //nolint:wrapcheck
}), nil
},
"setContent": func(html string, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameSetContentOptions(rt, opts, f.Page().NavigationTimeout())View on GitHub (pinned to 8d06114777)