grafana/k6 · error

parsing locator press sequentially options: %w

Error message

parsing locator press sequentially options: %w

What it means

Thrown when locator.pressSequentially(text, opts) fails to parse options into FrameTypeOptions (delay number in ms between keystrokes, timeout number in ms; strict). The mapping wraps the cause as 'parsing locator press sequentially options: %w'. pressSequentially is the current name for the deprecated type(); its options parser is lenient in current k6, so failures come from a non-object opts argument or wrong-typed fields under strict parsing.

Source

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

			}
			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 := common.NewFramePressOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTypeOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTypeOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameHoverOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); err != nil {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Pass options as a plain object: pressSequentially('hello', { delay: 50 })
  2. Use numeric milliseconds for delay and timeout
  3. Keep the text as the first argument
  4. Omit options when the default no-delay behavior is acceptable

Example fix

// before
await page.locator('input').pressSequentially('k6', '50ms');

// after
await page.locator('input').pressSequentially('k6', { delay: 50 });
Defensive patterns

Strategy: validation

Validate before calling

function assertTypeOpts(method, opts) {
  if (opts === null || opts === undefined) return;
  if (typeof opts !== 'object' || Array.isArray(opts)) {
    throw new TypeError(`${method} options must be a plain object`);
  }
  for (const k of ['delay', 'timeout']) {
    if (k in opts && typeof opts[k] !== 'number') {
      throw new TypeError(`${method} ${k} must be a number (ms)`);
    }
  }
}
assertTypeOpts('pressSequentially', opts);

Type guard

function isTypeOptions(v) {
  if (v === null || v === undefined) return true;
  if (typeof v !== 'object' || Array.isArray(v)) return false;
  return (v.delay === undefined || typeof v.delay === 'number') &&
         (v.timeout === undefined || typeof v.timeout === 'number');
}

Try / catch

try {
  await locator.pressSequentially(text, opts);
} catch (e) {
  if (/parsing locator press sequentially options/.test(String(e.message))) {
    throw new Error(`Bad pressSequentially options: ${JSON.stringify(opts)}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling pressSequentially('hello', '50ms') or pressSequentially('hello', 50) — scalar in the opts slot; { delay: '50ms' } string instead of number; passing the text into the options object instead of the first argument.

Common situations: Renaming type() to pressSequentially() during Playwright-alignment migrations and leaving old string-typed arguments; simulating human typing with per-key delays expressed as strings; copy-pasting fill() options which accepts different keys.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/17b9b8efabaaaa3b. Report an issue: GitHub.