grafana/k6 · error
parse press options of selector
Error message
parse press options of selector %q on key %q: %w
What it means
Thrown when `frame.press(selector, key, opts)` options fail to parse into FramePressOptions (delay ms int, noWaitAfter bool, timeout ms, strict bool). Message includes both selector and key. ElementHandlePressOptions.Parse is fully coercive (ToInteger/ToBoolean), so the branch is currently defensive.
Solutions
- Pass delay/noWaitAfter/timeout/strict as proper number/boolean/number/boolean
- Remember the second argument is a single key name like 'Enter' or 'a', not a string of characters
- For typing text use frame.type or frame.fill, not press
Example fix
// before
await frame.press('#i', 'Enter', { delay: '100ms' }); // delay becomes 0
// after
await frame.press('#i', 'Enter', { delay: 100 }); // milliseconds, number Defensive patterns
Strategy: try-catch
Validate before calling
const opts = { delay: 100, timeout: 5000 };
if (opts.delay != null && typeof opts.delay !== 'number') throw new Error('delay must be a number in ms');
if (typeof key !== 'string' || key.length === 0) throw new Error('key must be a non-empty key name like "Enter"'); Type guard
function isPressOptions(o) {
return o == null || (typeof o === 'object' &&
(o.delay === undefined || typeof o.delay === 'number') &&
(o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
(o.timeout === undefined || typeof o.timeout === 'number'));
} Try / catch
try {
await frame.press(sel, key, opts);
} catch (e) {
if (String(e).includes('parse press options')) { console.error(`bad press opts for ${sel} key ${key}`); } else { throw e; }
} Prevention
- delay is milliseconds between keydown/keyup as a number — '100ms' coerces to 0
- Second argument is one key name ('Enter', 'ArrowDown', 'a'), not text
- Message includes both selector and key for easy triage
When it happens
Trigger: Not reachable today; `delay: '100'` coerces, `delay: '100ms'` coerces to 0. The key argument itself is not validated here — invalid key names fail later in the CDP layer, not in this parse.
Common situations: String delay values silently becoming 0 (no keystroke delay); Playwright's deprecated `noWaitAfter` being passed as strings; expecting a typo'd key like 'Enter ' (trailing space) to error here — it does not.
Related errors
- parse isEditable options of selector
- parse isEnabled options of selector
- parse isHidden options of selector
- parse isVisible options of selector
- parsing double click options
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/53ef851dec52ceb9.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:324
},
"locator": func(selector string, opts sobek.Value) mapping {
return mapLocator(vu, f.Locator(selector, parseLocatorOptions(rt, opts)))
},
"frameLocator": func(selector string) *sobek.Object {
mfl := mapFrameLocator(vu, f.FrameLocator(selector))
return rt.ToValue(mfl).ToObject(rt)
},
"name": f.Name,
"page": func() mapping {
return mapPage(vu, f.Page())
},
"parentFrame": func() mapping {
return mapFrame(vu, f.ParentFrame())
},
"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:wrapcheckView on GitHub (pinned to 8d06114777)