{"record":{"id":"3fcb9799a8ebf82f","repo":"grafana/k6","slug":"missing-required-argument-label-3fcb97","errorCode":null,"errorMessage":"missing required argument 'label'","messagePattern":"missing required argument 'label'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":191,"sourceCode":"\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, p.GetByRole(role.String(), popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByAltText\": func(alt sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(alt) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'altText'\")\n\t\t\t}\n\t\t\tpalt, popts := parseGetByBaseOptions(vu.Context(), alt, false, opts)\n\n\t\t\tml := mapLocator(vu, p.GetByAltText(palt, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByLabel\": func(label sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(label) {\n\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, p.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, p.GetByPlaceholder(pplaceholder, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"getByTitle\": func(title sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(title) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'title'\")","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/page_mapping.go#L173-L209","documentation":"Thrown by the Page mapping's getByLabel method. The label text is the mandatory first argument; the mapping checks it with k6common.IsNullish before calling p.GetByLabel with parsed base options (string or RegExp plus exact/substring options). Nullish input is rejected up front.","triggerScenarios":"page.getByLabel() with no arguments; page.getByLabel(null); label variables that resolve to undefined (missing form definitions in fixtures).","commonSituations":"Form-testing scripts where the label comes from a data file with gaps; converting page.$('label:has-text(...)') selectors to getByLabel without carrying the text over; optional chaining upstream that silently yields undefined.","solutions":["Pass a string or RegExp: page.getByLabel('Email') or page.getByLabel(/email/i)","Guard data-driven labels: page.getByLabel(label ?? 'Email')","Add a quick assertion on the data source so missing labels fail with your own message"],"exampleFix":"// before\npage.getByLabel();\n\n// after\npage.getByLabel('Email');","handlingStrategy":"validation","validationCode":"if (label === undefined || label === null) {\n  throw new Error(`page.getByLabel: 'label' is required, got ${label}`);\n}\nconst loc = page.getByLabel(label, opts);","typeGuard":"function isTextMatcher(v) {\n  return typeof v === 'string' || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  page.getByLabel(label);\n} catch (e) {\n  if (!e.message.includes(\"missing required argument 'label'\")) throw e;\n  throw new Error(`form label missing from data file`);\n}","preventionTips":["Keep form labels in one constants module with a completeness test so gaps fail early"],"tags":["browser","page","getbylabel","locator","form","argument-validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}