{"record":{"id":"2274846ec664de53","repo":"grafana/k6","slug":"missing-required-argument-role-227484","errorCode":null,"errorMessage":"missing required argument 'role'","messagePattern":"missing required argument 'role'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":167,"sourceCode":"\t\t\t\treturn nil, errors.New(\"missing required argument 'label'\")\n\t\t\t}\n\t\t\tplabel, popts := parseGetByBaseOptions(vu.Context(), label, true, opts)\n\n\t\t\tml := mapLocator(vu, f.GetByLabel(plabel, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByPlaceholder\": func(placeholder sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(placeholder) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'placeholder'\")\n\t\t\t}\n\t\t\tpplaceholder, popts := parseGetByBaseOptions(vu.Context(), placeholder, false, opts)\n\n\t\t\tml := mapLocator(vu, f.GetByPlaceholder(pplaceholder, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByRole\": func(role sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(role) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'role'\")\n\t\t\t}\n\t\t\tpopts := parseGetByRoleOptions(vu.Context(), opts)\n\n\t\t\tml := mapLocator(vu, f.GetByRole(role.String(), popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByTestId\": func(testID sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(testID) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'testId'\")\n\t\t\t}\n\t\t\tptestID := parseStringOrRegex(testID, false)\n\n\t\t\tml := mapLocator(vu, f.GetByTestID(ptestID))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByText\": func(text sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(text) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'text'\")","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/frame_mapping.go#L149-L185","documentation":"Frame.getByRole(role, options) on a k6 browser Frame requires a non-nullish first argument naming an ARIA role; the mapping in frame_mapping.go throws before options are parsed or CDP is touched. The role string (e.g. 'button', 'heading') is the primary locator input; options such as name or level refine but never replace it. This matches Playwright's mandatory role contract.","triggerScenarios":"Calling frame.getByRole() with no role, passing null/undefined, or intending to select by accessible name only and passing undefined while putting the name in options.","commonSituations":"Role/name confusion when porting from getByRole('button', { name }) examples, data-driven role lists with gaps, optional role parameters in shared helpers.","solutions":["Pass an ARIA role string first: frame.getByRole('heading', { name: 'Dashboard' })","Keep the accessible name in options rather than dropping the role argument","Validate/default the role variable from test data before the call","Check for typos in the constant or property supplying the role"],"exampleFix":"// before\nconst h = page.frame('#content').getByRole(roleVar, { name: 'Overview' }); // roleVar is undefined\n\n// after\nconst h = page.frame('#content').getByRole('heading', { name: 'Overview' });","handlingStrategy":"validation","validationCode":"if (!isAriaRole(roleVar)) throw new Error(`valid ARIA role required, got: ${roleVar}`);\nframe.getByRole(roleVar, opts);","typeGuard":"const ARIA_ROLES = new Set(['button','link','textbox','checkbox','radio','heading','img','list','listitem','navigation','main','banner','contentinfo','form','table','row','cell','dialog','alert','search','tab','tablist','option','combobox','menuitem','progressbar','slider','switch']);\nfunction isAriaRole(v) {\n  return typeof v === 'string' && ARIA_ROLES.has(v);\n}","tryCatchPattern":"try {\n  loc = frame.getByRole(maybeRole, opts);\n} catch (e) {\n  if (/missing required argument 'role'/.test(String(e.message))) {\n    throw new Error('role argument missing; accessible name belongs in options');\n  }\n  throw e;\n}","preventionTips":["Memorize the signature getByRole(role, options) — name/level live in options","Validate role columns in data-driven suites against a known role list","Require the role parameter in shared frame helpers","Review Playwright ports for dropped first arguments during manual copy"],"tags":["browser","frame","argument-validation","get-by","aria"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}