grafana/k6 · error

parsing check options

Error message

parsing check options: %w

What it means

Thrown while parsing the options object of locator.check(options) (browser/locator_mapping.go:121). Like setChecked it wraps FrameCheckOptions.Parse, and the only failing branch is position (must export to a numeric x/y map via ElementHandleBasePointerOptions.Parse). strict, force, noWaitAfter, trial and timeout are coerced.

Solutions

  1. Use position: { x: 5, y: 5 } with numeric fields
  2. Drop position to click the element center
  3. Normalize config values with Number()
  4. Keep check/uncheck option builders in one place so the shape stays correct

Example fix

// before
locator.check({ position: [5, 5] });
// after
locator.check({ position: { x: 5, y: 5 } });
Defensive patterns

Strategy: validation

Validate before calling

if (opts?.position != null &&
    !(typeof opts.position === 'object' && typeof opts.position.x === 'number' && typeof opts.position.y === 'number')) {
  throw new Error('position must be { x: number, y: number }');
}

Type guard

function isCheckOptions(o) {
  if (o == null) return true;
  if (typeof o !== 'object' || Array.isArray(o)) return false;
  const p = o.position;
  return p == null || (typeof p === 'object' && typeof p.x === 'number' && typeof p.y === 'number');
}

Try / catch

try { await locator.check(opts); } catch (e) { if (!String(e.message).includes('parsing check options')) throw e; }

Prevention

When it happens

Trigger: locator.check({ position: [5, 5] }); locator.check({ position: 'center' }); string x/y values from config objects.

Common situations: Terms-of-service/consent checkbox flows; ported Playwright scripts with array positions; shared option objects reused across check() and click() where shapes drifted.

Related errors


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

Appendix: source

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

				if err != nil {
					return nil, err //nolint:wrapcheck
				}
				return mapJSHandle(vu, jsh), nil
			}), nil
		},
		"setChecked": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameCheckOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing set checked options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.SetChecked(checked, copts) //nolint:wrapcheck
			}), nil
		},
		"check": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameCheckOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing check options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.Check(copts) //nolint:wrapcheck
			}), nil
		},
		"uncheck": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameUncheckOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing uncheck options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.Uncheck(copts) //nolint:wrapcheck
			}), nil
		},
		"isChecked": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameIsCheckedOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing is checked options: %w", err)

View on GitHub (pinned to 8d06114777)