grafana/k6 · error

parsing select option options

Error message

parsing select option options: %w

What it means

Thrown synchronously when the options (second) argument to locator.selectOption(values, opts) fails to parse. The mapping (locator_mapping.go:356-360) builds common.FrameSelectOptionOptions and wraps Parse failures as "parsing select option options: %w". Parse delegates to ElementHandleBaseOptions.Parse (force/noWaitAfter/timeout coercions) plus parseStrict, none of which fail on ordinary mistyped values — so a real occurrence means sobek raised reading the object: a throwing getter, a Proxy trap, or a throwing implicit conversion.

Solutions

  1. Pass a plain literal: locator.selectOption('blue', { timeout: 5000 })
  2. Compute option values before the call; avoid getters/Proxies
  3. Distinguish this error from "parsing select option values" — the first is opts, the second is the values argument
  4. try/catch the call and report the failing argument

Example fix

// before
await locator.selectOption(values, optsProxy); // optsProxy get trap throws

// after
const { timeout, force } = optsProxy;
await locator.selectOption(values, { timeout, force });
Defensive patterns

Strategy: try-catch

Type guard

function isPlainSelectOptions(o) {
  return o == null || (typeof o === 'object' &&
    (o.timeout === undefined || typeof o.timeout === 'number') &&
    (o.force === undefined || typeof o.force === 'boolean') &&
    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
    (o.strict === undefined || typeof o.strict === 'boolean'));
}

Try / catch

try {
  await locator.selectOption(values, opts);
} catch (e) {
  if (String(e).includes('parsing select option options'))
    throw new Error(`bad selectOption opts (2nd arg): ${JSON.stringify(opts)}`);
  if (String(e).includes('parsing select option values'))
    throw new Error(`bad selectOption values (1st arg): ${JSON.stringify(values)}`);
  throw e;
}

Prevention

When it happens

Trigger: An options getter for timeout/force that raises; Proxy options with throwing get/ownKeys traps; a timeout whose valueOf throws during ToInteger. Note this is the options object, not the values argument (values errors surface as "parsing select option values").

Common situations: Porting Playwright selectOption calls and building the options object from instrumented config; tracing harnesses that proxy arguments; accessor-rich page-object options.

Related errors


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

Appendix: source

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

				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) {
				return lo.InputValue(copts) //nolint:wrapcheck
			}), nil
		},
		"selectOption": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameSelectOptionOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing select option options: %w", err)
			}
			convValues, err := ConvertSelectOptionValues(vu.Runtime(), values)
			if err != nil {
				return nil, fmt.Errorf("parsing select option values: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.SelectOption(convValues, copts) //nolint:wrapcheck
			}), nil
		},
		"press": func(key string, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFramePressOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing press options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.Press(key, copts) //nolint:wrapcheck
			}), nil
		},

View on GitHub (pinned to 8d06114777)