grafana/k6 · error

parsing new frame check options

Error message

parsing new frame check options: %w

What it means

Thrown synchronously by page.check(selector, opts) in the k6 browser module when the options object fails to parse. FrameCheckOptions.Parse delegates to ElementHandleBasePointerOptions.Parse, where the only failing branch is 'position': it must export to map[string]float64, i.e. an object whose x and y are numbers (internal/js/modules/k6/browser/common/element_handle_options.go:188-195). The wrapper adds the 'parsing new frame check options' prefix; force, noWaitAfter, timeout and strict are coerced and never fail.

Solutions

  1. Pass position as numeric coordinates: page.check(selector, { position: { x: 10, y: 20 } })
  2. Omit position entirely when clicking the element center is acceptable — it is the default behavior
  3. If coordinates come from data, coerce them: { position: { x: Number(px), y: Number(py) } } and verify they are finite before the call

Example fix

// before
await page.check('#tos', { position: 'center' });
// parsing new frame check options: ...cannot convert position...

// after
await page.check('#tos', { position: { x: 100, y: 150 } });
// or simply omit position:
await page.check('#tos');
Defensive patterns

Strategy: validation

Validate before calling

function validPosition(p) {
  return p === undefined || (typeof p === 'object' && p !== null
    && Number.isFinite(p.x) && Number.isFinite(p.y));
}
if (!validPosition(opts?.position)) throw new Error('position must be { x: number, y: number }');
await page.check(selector, opts);

Type guard

/** @param {unknown} p */
function isPosition(p) {
  return typeof p === 'object' && p !== null
    && Number.isFinite(/** @type {any} */ (p).x)
    && Number.isFinite(/** @type {any} */ (p).y);
}

Try / catch

try {
  await page.check(selector, opts);
} catch (e) {
  if (String(e).includes('parsing new frame check options')) {
    // most likely a bad position object; retry without it
    await page.check(selector);
  } else throw e;
}

Prevention

When it happens

Trigger: page.check('#accept', { position: 'center' }) — position as a string instead of {x, y}; position: { x: '10', y: 10 } with a string coordinate; position: 10 or any non-object value; position object containing nested objects or NaN values.

Common situations: Porting Playwright snippets that use shorthand position names instead of coordinates; coordinates read from JSON fixtures where numbers got quoted; assuming 'position: center' (a CSS-like keyword) is supported — only a coordinate object is.

Related errors


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

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:33

	"go.k6.io/k6/v2/internal/js/modules/k6/browser/k6ext"
	k6common "go.k6.io/k6/v2/js/common"
)

// mapPage to the JS module.
//
//nolint:funlen
func mapPage(vu moduleVU, p *common.Page) mapping { //nolint:gocognit,cyclop
	rt := vu.Runtime()
	maps := mapping{
		"bringToFront": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return nil, p.BringToFront() //nolint:wrapcheck
			})
		},
		"check": func(selector string, opts sobek.Value) (*sobek.Promise, error) {
			popts, err := parseFrameCheckOptions(rt, opts, p.MainFrame().Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing new frame check options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, p.Check(selector, popts) //nolint:wrapcheck
			}), nil
		},
		"click": func(selector string, opts sobek.Value) (*sobek.Promise, error) {
			popts, err := parseFrameClickOptions(rt, opts, p.MainFrame().Timeout())
			if err != nil {
				return nil, err
			}

			return promise(vu, func() (any, error) {
				err := p.Click(selector, popts)
				return nil, err //nolint:wrapcheck
			}), nil
		},
		"close": func(opts sobek.Value) *sobek.Promise {
			// TODO when opts are implemented for this function, parse them here before calling promise()

View on GitHub (pinned to 8d06114777)