grafana/k6 · error
missing required argument 'placeholder'
Error message
missing required argument 'placeholder'
What it means
Locator.getByPlaceholder(placeholder) in the k6 browser module requires a non-nullish first argument; the mapping throws before any browser call. The placeholder (string or RegExp) is the locator's only input for finding inputs by placeholder attribute within the locator scope. Playwright enforces the same contract.
Source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:254
return nil, errors.New("missing required argument 'altText'")
}
palt, popts := parseGetByBaseOptions(vu.Context(), alt, false, opts)
ml := mapLocator(vu, lo.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, lo.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, lo.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, lo.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
- Pass the placeholder string or RegExp: page.locator('.search').getByPlaceholder('Search docs')
- Validate/default locale-sourced placeholder values before the call
- Fix the undefined constant, key, or import
- Use a RegExp across locales, e.g. getByPlaceholder(/suchen|search/i)
Example fix
// before
const input = page.locator('.search-bar').getByPlaceholder(i18n.searchHint); // undefined
// after
const hint = i18n.searchHint ?? 'Search';
const input = page.locator('.search-bar').getByPlaceholder(hint); Defensive patterns
Strategy: validation
Validate before calling
const ph = localeData.searchHint;
if (!isTextSelector(ph)) throw new Error(`searchHint missing for locale ${locale}`);
locator.getByPlaceholder(ph); Type guard
function isTextSelector(v) {
return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;
} Try / catch
try {
sub = locator.getByPlaceholder(maybePh);
} catch (e) {
if (/missing required argument 'placeholder'/.test(String(e.message))) {
throw new Error(`placeholder missing; locale=${locale}`);
}
throw e;
} Prevention
- Add locale-bundle completeness checks for selector-visible strings
- Default locale lookups with ?? before passing into chained locators
- Prefer RegExp placeholders across near-identical locales
- Keep widget page objects and their locale keys in one review unit
When it happens
Trigger: Calling page.locator('.search-bar').getByPlaceholder() with no argument, passing null/undefined, or forwarding an undefined placeholder from locale data or a selectors module.
Common situations: Localized search widgets, sparse CSV-driven test data, or constants renamed after a page-object refactor.
Related errors
- missing required argument 'label'
- missing required argument 'label'
- missing required argument 'placeholder'
- missing required argument 'label'
- missing required argument 'placeholder'
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/7063050901ff3795.
Report an issue: GitHub.