grafana/k6 · error
missing required argument 'title'
Error message
missing required argument 'title'
What it means
Frame.getByTitle(title) on a k6 browser Frame requires a non-nullish first argument; the mapping layer rejects absent, null, or undefined values up front. The title (string or RegExp) matches elements' title attribute and is the method's only selector input, mirroring Playwright.
Source
Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:194
return nil, errors.New("missing required argument 'testId'")
}
ptestID := parseStringOrRegex(testID, false)
ml := mapLocator(vu, f.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'")
}
ptext, popts := parseGetByBaseOptions(vu.Context(), text, true, opts)
ml := mapLocator(vu, f.GetByText(ptext, 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, f.GetByTitle(ptitle, popts))
return rt.ToValue(ml).ToObject(rt), nil
},
"goto": func(url string, opts sobek.Value) (*sobek.Promise, error) {
gopts := common.NewFrameGotoOptions(
f.Referrer(),
f.NavigationTimeout(),
)
if err := gopts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing frame navigation options to %q: %w", url, err)
}
return promise(vu, func() (any, error) {
resp, err := f.Goto(url, gopts)
if err != nil {
return nil, err //nolint:wrapcheckView on GitHub (pinned to 93accf6570)
Solutions
- Pass the title string or RegExp: frame.getByTitle('Dismiss')
- Validate or default the data-sourced title before the call
- Fix the property name or import supplying the value
- Use a RegExp for dynamic titles, e.g. frame.getByTitle(/\(\d+\)$/), rather than dropping the argument
Example fix
// before
const btn = page.frame('#frame').getByTitle(titleVar); // titleVar is undefined
// after
const titleVar = 'Close notification';
const btn = page.frame('#frame').getByTitle(titleVar); Defensive patterns
Strategy: validation
Validate before calling
const title = tips[name];
if (!isTextSelector(title)) throw new Error(`tips.${name} is required for getByTitle`);
frame.getByTitle(title); Type guard
function isTextSelector(v) {
return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;
} Try / catch
try {
loc = frame.getByTitle(maybeTitle);
} catch (e) {
if (/missing required argument 'title'/.test(String(e.message))) {
throw new Error(`title missing for '${name}' in frame`);
}
throw e;
} Prevention
- Store title/tooltip expectations with other page data and validate them in the same pass
- Use ?? defaults at the data boundary for optional tooltip strings
- Use RegExp titles when counters or dynamic segments are present
- Re-verify accessibility titles after UI library upgrades
When it happens
Trigger: Calling frame.getByTitle() with no argument, passing null/undefined, or forwarding a tooltip string variable that resolved to undefined from external data.
Common situations: Tooltip/accessibility-title assertions with data-sourced expectations, refactors renaming title variables, helpers with optional title parameters.
Related errors
- missing required argument 'altText'
- missing required argument 'label'
- missing required argument 'placeholder'
- missing required argument 'role'
- missing required argument 'testId'
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/4cc3c3571046d305.
Report an issue: GitHub.