grafana/k6 · error
parsing clear options
Error message
parsing clear options: %w
What it means
Thrown while parsing the options object of locator.clear(options) (browser/locator_mapping.go:51). It wraps FrameFillOptions.Parse, which (via ElementHandleBaseOptions.Parse and parseStrict) reads force, noWaitAfter, strict and timeout coercively and has no failing branch in current k6 — the wrap is defensive. clear() reuses the fill-options shape because it fills an empty string.
Solutions
- Pass a plain object { timeout: <number>, force: <bool>, noWaitAfter: <bool>, strict: <bool> } or omit it
- Coerce dynamic values (Number/Boolean) before the call
- Do not expect clear() to accept pointer options like position
- Upgrade k6 if an ordinary object triggers this error
Example fix
// before
locator.clear({ timeout: __ENV.T });
// after
locator.clear({ timeout: Number(__ENV.T) }); Defensive patterns
Strategy: validation
Validate before calling
const o = (opts == null) ? undefined : {
...(opts.timeout !== undefined && { timeout: Number(opts.timeout) }),
...(opts.force !== undefined && { force: Boolean(opts.force) }),
...(opts.noWaitAfter !== undefined && { noWaitAfter: Boolean(opts.noWaitAfter) }),
...(opts.strict !== undefined && { strict: Boolean(opts.strict) }),
}; Type guard
function isClearOptions(o) {
if (o == null) return true;
if (typeof o !== 'object' || Array.isArray(o)) return false;
return (o.timeout === undefined || typeof o.timeout === 'number');
} Try / catch
try { await locator.clear(o); } catch (e) { if (!String(e.message).includes('parsing clear options')) throw e; } Prevention
- clear() accepts fill-style options only; pointer options like position are not honored
- Use force: true for covered inputs instead of inventing unsupported keys
- Normalize options from config before passing
When it happens
Trigger: Exotic options values (Symbol, throwing getters) that break sobek traversal; older k6 versions with strict exportTo parsing of these fields.
Common situations: Passing fill-specific options like position or modifiers to clear() (they are ignored rather than rejected, which confuses debugging); options from JSON with string timeouts on older builds.
Related errors
- parsing check options
- parsing double click options
- parsing locator bounding box options
- parsing set checked options
- evaluate requires a page function
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/b3384ffa11d9378c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:52
"boundingBox": func(opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewFrameBaseOptions(lo.Timeout())
if err := parseFrameBaseOptions(popts, rt, opts); err != nil {
return nil, fmt.Errorf("parsing locator bounding box options: %w", err)
}
return promise(vu, func() (any, error) {
box, err := lo.BoundingBox(popts)
// We want to avoid errors when an element is not visible or detached and instead
// opt to return a nil rectangle -- this matches Playwright's behaviour.
if errors.Is(err, common.ErrElementNotVisible) || errors.Is(err, common.ErrElementNotAttachedToDOM) {
return nil, nil
}
return box, err
}), nil
},
"clear": func(opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameFillOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing clear options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.Clear(copts) //nolint:wrapcheck
}), nil
},
"click": func(opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameClickOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, err
}
return promise(vu, func() (any, error) {
return nil, lo.Click(popts) //nolint:wrapcheck
}), nil
},
"contentFrame": func() *sobek.Object {
ml := mapFrameLocator(vu, lo.ContentFrame())
return rt.ToValue(ml).ToObject(rt)View on GitHub (pinned to 8d06114777)