grafana/k6 · error

parsing locator press sequentially options

Error message

parsing locator press sequentially options: %w

What it means

Thrown synchronously when the options argument to locator.pressSequentially(text, opts) fails to parse. The mapping (locator_mapping.go:379-383) builds common.FrameTypeOptions and wraps Parse failures as "parsing locator press sequentially options: %w". Parse (via ElementHandleTypeOptions, element_handle_options.go:542-558) reads delay, noWaitAfter and timeout via coercing accessors that tolerate ordinary type mistakes, so the wrapped error comes from sobek raising during property access on the options object — a throwing getter, Proxy trap, or throwing implicit numeric conversion.

Solutions

  1. Pass a plain literal: locator.pressSequentially('hello', { delay: 50, timeout: 5000 })
  2. Precompute dynamic option values; avoid accessors and Proxies
  3. Keep to recognized keys (delay ms, noWaitAfter boolean, timeout ms, strict boolean)
  4. try/catch the call to surface a clean error

Example fix

// before
await locator.pressSequentially(code, optsProxy); // Proxy throws in get

// after
const { delay, timeout } = optsProxy;
await locator.pressSequentially(code, { delay, timeout });
Defensive patterns

Strategy: try-catch

Type guard

function isPlainTypeOptions(o) {
  return o == null || (typeof o === 'object' &&
    (o.delay === undefined || Number.isFinite(o.delay)) &&
    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
    (o.timeout === undefined || Number.isFinite(o.timeout)));
}

Try / catch

try {
  await locator.pressSequentially(text, opts);
} catch (e) {
  throw new Error(`pressSequentially failed (check delay/timeout are plain numbers): ${e}`);
}

Prevention

When it happens

Trigger: A getter on delay/timeout that raises; a Proxy around options with throwing get/ownKeys traps; a delay value whose valueOf/Symbol.toPrimitive throws during ToInteger.

Common situations: Typing-simulation helpers that pull delay from accessor-based config; argument-tracing Proxies; ported Playwright type() code paths reused for pressSequentially with decorated option objects.

Related errors


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

Appendix: source

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

			}
			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
		},

		"pressSequentially": func(text string, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing locator press sequentially options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.PressSequentially(text, copts) //nolint:wrapcheck
			}), nil
		},

		"type": func(text string, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing type options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.Type(text, copts) //nolint:wrapcheck
			}), nil
		},
		"hover": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameHoverOptions(rt, opts, lo.Timeout())
			if err != nil {

View on GitHub (pinned to 8d06114777)