grafana/k6 · error
missing required argument 'title'
Error message
missing required argument 'title'
What it means
Thrown by the Page mapping's getByTitle method (the Page-level twin of Frame.getByTitle). The title argument is mandatory and validated with k6common.IsNullish before p.GetByTitle is called with parsed base options. Nullish first arguments never reach locator construction.
Source
Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:209
return nil, errors.New("missing required argument 'label'")
}
plabel, popts := parseGetByBaseOptions(vu.Context(), label, true, opts)
ml := mapLocator(vu, p.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, p.GetByPlaceholder(pplaceholder, popts))
return rt.ToValue(ml).ToObject(rt), nil
},
"getByTitle": func(title sobek.Value, opts sobek.Value) (*sobek.Object, error) {
if k6common.IsNullish(title) {
return nil, errors.New("missing required argument 'title'")
}
ptitle, popts := parseGetByBaseOptions(vu.Context(), title, false, opts)
ml := mapLocator(vu, p.GetByTitle(ptitle, 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'")
}
ptestID := parseStringOrRegex(testID, false)
ml := mapLocator(vu, p.GetByTestID(ptestID))
return rt.ToValue(ml).ToObject(rt), nil
},
"getByText": func(text sobek.Value, opts sobek.Value) (*sobek.Object, error) {
if k6common.IsNullish(text) {
return nil, errors.New("missing required argument 'text'")View on GitHub (pinned to 93accf6570)
Solutions
- Pass a string or RegExp: page.getByTitle('More info') or page.getByTitle(/info/i)
- Guard dynamic titles: page.getByTitle(title ?? 'More info')
- Keep a lint/review check that every getBy* call has a non-empty first argument
Example fix
// before
page.getByTitle();
// after
page.getByTitle('More info'); Defensive patterns
Strategy: validation
Validate before calling
if (title === undefined || title === null) {
throw new Error(`page.getByTitle: 'title' is required, got ${title}`);
}
const loc = page.getByTitle(title, opts); Type guard
function isTextMatcher(v) {
return typeof v === 'string' || v instanceof RegExp;
} Try / catch
try {
page.getByTitle(title);
} catch (e) {
if (!e.message.includes("missing required argument 'title'")) throw e;
throw new Error(`title attribute value missing`);
} Prevention
- Same guard as other getBy* methods — centralize in one locator helper
When it happens
Trigger: page.getByTitle() with no arguments; page.getByTitle(null); a title variable that is undefined after data-driven refactors.
Common situations: Tooltip/link testing where titles come from fixtures; moving between frame.getByTitle and page.getByTitle and losing the argument; passing an options object in the first position.
Related errors
- missing required argument 'title'
- missing required argument 'role'
- missing required argument 'altText'
- missing required argument 'label'
- missing required argument 'placeholder'
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/c492e40553cfcc4b.
Report an issue: GitHub.