grafana/k6 · error
parsing text content options
Error message
parsing text content options: %w
What it means
Thrown synchronously when the options argument to locator.textContent() fails to parse. The mapping (locator_mapping.go:331-335) creates common.FrameTextContentOptions (FrameBaseOptions) and wraps any Parse failure as "parsing text content options: %w". FrameBaseOptions.Parse handles only strict/timeout via coercing accessors and never fails on ordinary mistyped values, so the wrapped error arises from sobek raising during property access on the options object (throwing getter, Proxy trap, or throwing implicit conversion).
Solutions
- Pass a plain literal { timeout: ms } or call locator.textContent() with no options
- Materialize computed values before the call
- Strip Proxy/accessor wrappers from options
- Catch the synchronous throw with try/catch and log which option failed
Example fix
// before
const opts = {}; Object.defineProperty(opts, 'timeout', { get: () => cfg.get('t') }); // throws when unset
await locator.textContent(opts);
// after
await locator.textContent({ timeout: cfg.get('t') ?? 3000 }); Defensive patterns
Strategy: try-catch
Type guard
function isPlainBaseOptions(o) {
return o == null || (typeof o === 'object' &&
(o.timeout === undefined || typeof o.timeout === 'number') &&
(o.strict === undefined || typeof o.strict === 'boolean'));
} Try / catch
try {
const text = await locator.textContent(opts);
} catch (e) {
throw new Error(`textContent failed (options must be plain { timeout, strict }): ${e}`);
} Prevention
- Use plain literals; avoid getters
- Resolve config values before the call
- Prefer no options unless overriding timeout
When it happens
Trigger: A throwing getter defined for timeout or strict; a Proxy around options whose get/ownKeys traps raise; a timeout value whose valueOf/Symbol.toPrimitive throws during ToInteger.
Common situations: Content-assertion helpers with accessor-based option objects; instrumentation Proxies; passing non-plain objects where a literal is expected.
Related errors
- parsing fill options
- parsing focus options
- parsing get attribute options
- parsing hover options
- parsing inner HTML options
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/efc685eac0eb3de1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:334
if err != nil {
return nil, fmt.Errorf("parsing inner text options: %w", err)
}
return promise(vu, func() (any, error) {
return lo.InnerText(copts) //nolint:wrapcheck
}), nil
},
"last": func() *sobek.Object {
ml := mapLocator(vu, lo.Last())
return rt.ToValue(ml).ToObject(rt)
},
"nth": func(nth int) *sobek.Object {
ml := mapLocator(vu, lo.Nth(nth))
return rt.ToValue(ml).ToObject(rt)
},
"textContent": func(opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameTextContentOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing text content options: %w", err)
}
return promise(vu, func() (any, error) {
s, ok, err := lo.TextContent(copts)
if err != nil {
return nil, err //nolint:wrapcheck
}
if !ok {
return nil, nil
}
return s, nil
}), nil
},
"inputValue": func(opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameInputValueOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing input value options: %w", err)
}
return promise(vu, func() (any, error) {View on GitHub (pinned to 8d06114777)