grafana/k6 · error
missing required argument 'title'
Error message
missing required argument 'title'
What it means
FrameLocator.getByTitle(title) in the k6 browser module 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. This mirrors Playwright's mandatory-argument contract.
Source
Thrown at internal/js/modules/k6/browser/browser/frame_locator_mapping.go:71
return nil, errors.New("missing required argument 'testId'")
}
ptestID := parseStringOrRegex(testID, false)
ml := mapLocator(vu, fl.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, fl.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, fl.GetByTitle(ptitle, popts))
return rt.ToValue(ml).ToObject(rt), nil
},
"locator": func(selector string, opts sobek.Value) mapping {
return mapLocator(vu, fl.Locator(selector, parseLocatorOptions(rt, opts)))
},
"frameLocator": func(selector string) *sobek.Object {
mfl := mapFrameLocator(vu, fl.FrameLocator(selector))
return rt.ToValue(mfl).ToObject(rt)
},
}
}
View on GitHub (pinned to 93accf6570)
Solutions
- Pass the title string or RegExp: frameLocator.getByTitle('Close dialog')
- Validate or default the data-sourced title before the call
- Fix the property name or export supplying the value
- Use a RegExp for dynamic titles, e.g. getByTitle(/^Error \(\d+\)$/)
Example fix
// before
const closeBtn = page.frameLocator('#modal-frame').getByTitle(tooltipVar); // tooltipVar is undefined
// after
const tooltipVar = 'Close this dialog';
const closeBtn = page.frameLocator('#modal-frame').getByTitle(tooltipVar); Defensive patterns
Strategy: validation
Validate before calling
const title = tips.close;
if (!isTextSelector(title)) throw new Error('tips.close is required for getByTitle');
frameLocator.getByTitle(title); Type guard
function isTextSelector(v) {
return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;
} Try / catch
try {
loc = frameLocator.getByTitle(maybeTitle);
} catch (e) {
if (/missing required argument 'title'/.test(String(e.message))) {
throw new Error(`title missing; check tooltip data for key='${key}'`);
}
throw e;
} Prevention
- Keep tooltip/title expectations beside other selectors in the page object and validate them together
- Default optional tooltip strings at the data boundary with ??
- Use RegExp for titles containing counters or dynamic segments
- Smoke-test help/icon overlays once per UI change
When it happens
Trigger: Calling page.frameLocator('iframe').getByTitle() with no argument, passing null/undefined, or forwarding a tooltip-text variable that resolved to undefined from test data.
Common situations: Tooltip/aria-title assertions where the expected string lives in external data, refactors renaming title variables, or helper functions with optional parameters passed through directly.
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/261a8eb571bfdb2b.
Report an issue: GitHub.