grafana/k6 · error

missing required argument 'placeholder'

Error message

missing required argument 'placeholder'

What it means

Frame.getByPlaceholder(placeholder) on a k6 browser Frame requires a non-nullish first argument; the mapping layer throws before any browser interaction. The placeholder text (string or RegExp) is the sole criterion for locating inputs by placeholder attribute. Playwright's equivalent method is equally strict.

Source

Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:158

				return nil, errors.New("missing required argument 'altText'")
			}
			palt, popts := parseGetByBaseOptions(vu.Context(), alt, false, opts)

			ml := mapLocator(vu, f.GetByAltText(palt, popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByLabel": func(label sobek.Value, opts sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(label) {
				return nil, errors.New("missing required argument 'label'")
			}
			plabel, popts := parseGetByBaseOptions(vu.Context(), label, true, opts)

			ml := mapLocator(vu, f.GetByLabel(plabel, popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByPlaceholder": func(placeholder sobek.Value, opts sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(placeholder) {
				return nil, errors.New("missing required argument 'placeholder'")
			}
			pplaceholder, popts := parseGetByBaseOptions(vu.Context(), placeholder, false, opts)

			ml := mapLocator(vu, f.GetByPlaceholder(pplaceholder, popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByRole": func(role sobek.Value, opts sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(role) {
				return nil, errors.New("missing required argument 'role'")
			}
			popts := parseGetByRoleOptions(vu.Context(), opts)

			ml := mapLocator(vu, f.GetByRole(role.String(), popts))
			return rt.ToValue(ml).ToObject(rt), nil
		},
		"getByTestId": func(testID sobek.Value) (*sobek.Object, error) {
			if k6common.IsNullish(testID) {
				return nil, errors.New("missing required argument 'testId'")

View on GitHub (pinned to 93accf6570)

Solutions

  1. Pass the placeholder string or RegExp: frame.getByPlaceholder('Enter search term')
  2. Validate/default locale- or data-sourced placeholder values before the call
  3. Fix the missing key or typo feeding the argument
  4. Use a RegExp to cover language variants, e.g. getByPlaceholder(/search/i)

Example fix

// before
const q = page.frame('#app').getByPlaceholder(t('search.hint')); // t() returned undefined

// after
const hint = t('search.hint') ?? 'Search';
const q = page.frame('#app').getByPlaceholder(hint);
Defensive patterns

Strategy: validation

Validate before calling

const ph = i18n[field.name]?.placeholder;
if (!isTextSelector(ph)) throw new Error(`placeholder missing for ${field.name} (${locale})`);
frame.getByPlaceholder(ph);

Type guard

function isTextSelector(v) {
  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;
}

Try / catch

try {
  loc = frame.getByPlaceholder(maybePh);
} catch (e) {
  if (/missing required argument 'placeholder'/.test(String(e.message))) {
    throw new Error(`placeholder missing for locale ${locale}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling frame.getByPlaceholder() with no argument, passing null/undefined, or forwarding an undefined i18n/data value intended as the placeholder string.

Common situations: Locale-dependent placeholder strings, CSV-driven form tests with empty cells, or partially copied selectors from recorded sessions.

Related errors


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