grafana/k6 · error
parsing selectText options: %w
Error message
parsing selectText options: %w
What it means
Thrown synchronously by ElementHandle.selectText() when its options fail to parse. selectText() parses common.ElementHandleBaseOptions (force, noWaitAfter, timeout), whose Parse in common/element_handle_options.go only leniently coerces and always returns nil, so this wrap is defensive and effectively unreachable in current k6.
Source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:215
}), nil
},
"selectOption": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
convValues, err := ConvertSelectOptionValues(vu.Runtime(), values)
if err != nil {
return nil, fmt.Errorf("parsing select options values: %w", err)
}
popts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
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)View on GitHub (pinned to 93accf6570)
Solutions
- Use only { force, noWaitAfter, timeout } with a millisecond number
- Confirm the target is a text input or textarea before calling selectText
- Upgrade k6 if this message appears, as current Parse cannot fail
- Read the wrapped cause after the colon to identify the failing field
Example fix
// before
await el.selectText({ timeout: '10s' });
// after
await el.selectText({ timeout: 10000 }); Defensive patterns
Strategy: try-catch
Validate before calling
const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);
const bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));
if (bad.length) console.warn(`selectText(): unsupported options ignored: ${bad.join(', ')}`);
if (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {
throw new Error('selectText(): timeout must be ms number');
} Type guard
function isSelectTextOpts(o) {
if (o == null) return true;
return (o.force === undefined || typeof o.force === 'boolean') &&
(o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
(o.timeout === undefined || Number.isFinite(o.timeout));
} Try / catch
try {
await el.selectText(opts);
} catch (e) {
if (/parsing selectText options/.test(String(e.message))) {
console.log(`fix selectText options: ${e.message}`);
} else throw e;
} Prevention
- selectText only needs { force, noWaitAfter, timeout }; extra keys are ignored
- Confirm the element is an input/textarea before calling; the real failures happen inside the promise
- Current k6 cannot raise this parse error; occurrence signals a version mismatch
When it happens
Trigger: In current code none: force/noWaitAfter/timeout accept any JS value via coercion; unknown option keys are ignored.
Common situations: Scripts ported from Playwright passing extra keys; timeouts given as strings; attributing a selectText failure to options when the real error (element not an input/textarea, or a timeout inside the promise) happens later.
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/b537c982ee50dc44.
Report an issue: GitHub.