grafana/k6 · error

parsing inner text options

Error message

parsing inner text options: %w

What it means

Thrown synchronously when the options argument to locator.innerText() fails to parse. The mapping (locator_mapping.go:314-318) builds common.FrameInnerTextOptions (FrameBaseOptions) and wraps Parse errors as "parsing inner text options: %w". Parse only reads strict/timeout with coercing accessors, so a genuine failure means sobek raised reading the object — throwing getter, Proxy trap, or a value whose numeric coercion throws.

Solutions

  1. Use a plain literal: locator.innerText({ timeout: 5000 }) or omit options
  2. Precompute dynamic values into plain properties
  3. Do not pass Proxy/accessor objects to the browser module
  4. try/catch the call to capture the failure with context

Example fix

// before
await locator.innerText(lazyOpts); // getter throws

// after
await locator.innerText({ timeout: lazyOpts.timeout }); // property read happens safely first
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.innerText(opts);
} catch (e) {
  throw new Error(`innerText failed (ensure options are plain data): ${e}`);
}

Prevention

When it happens

Trigger: opts with a getter for timeout/strict that raises; Proxy options with throwing traps; a non-number timeout with a throwing toPrimitive/valueOf.

Common situations: Text-extraction helpers that build options from lazily-validated config; debugging Proxies over arguments; ported Playwright utilities that decorate options.

Related errors


AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14). Data as JSON: /api/errors/6da476e3713f1e13. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:317

			return mapLocator(vu, lo.Locator(selector, parseLocatorOptions(rt, opts)))
		},
		"frameLocator": func(selector string) *sobek.Object {
			mfl := mapFrameLocator(vu, lo.FrameLocator(selector))
			return rt.ToValue(mfl).ToObject(rt)
		},
		"innerHTML": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameInnerHTMLOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing inner HTML options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.InnerHTML(copts) //nolint:wrapcheck
			}), nil
		},
		"innerText": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameInnerTextOptions(rt, opts, lo.Timeout())
			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)
			}

View on GitHub (pinned to 8d06114777)