grafana/k6 · error

missing required argument 'placeholder'

Error message

missing required argument 'placeholder'

What it means

FrameLocator.getByPlaceholder(placeholder) in the k6 browser module requires a non-nullish first argument; the mapping layer rejects absent, null, or undefined values before any browser call. The placeholder text (string or RegExp) is the sole selector input for finding inputs by placeholder attribute. Playwright's API has the same mandatory-argument contract.

Source

Thrown at internal/js/modules/k6/browser/browser/frame_locator_mapping.go:35

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

			ml := mapLocator(vu, fl.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, fl.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, fl.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, fl.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: frameLocator.getByPlaceholder('Search products')
  2. Validate or default the value sourced from data or i18n bundles before the call
  3. Fix the undefined variable or missing key feeding the argument
  4. Use a RegExp for language-variant placeholders, e.g. getByPlaceholder(/^Search/)

Example fix

// before
const search = page.frameLocator('#widget').getByPlaceholder(placeholderKey); // placeholderKey is undefined

// after
const placeholderKey = 'Search';
const search = page.frameLocator('#widget').getByPlaceholder(placeholderKey);
Defensive patterns

Strategy: validation

Validate before calling

const ph = t('search.placeholder');
if (!isTextSelector(ph)) throw new Error('search.placeholder missing from i18n bundle');
frameLocator.getByPlaceholder(ph);

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling page.frameLocator('iframe').getByPlaceholder(), passing null/undefined explicitly, or forwarding a placeholder variable that was never assigned (typo, missing i18n key, empty test-data column).

Common situations: Localized test suites where the placeholder string lookup fails for one locale, CSV/JSON-driven scripts with missing placeholder columns, or partially ported Playwright helpers.

Related errors


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