{"record":{"id":"7378a34220264818","repo":"grafana/k6","slug":"missing-required-argument-label-7378a3","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/frame_mapping.go","lineNumber":149,"sourceCode":"\t\t\t\t}\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, nil //nolint:nilnil\n\t\t\t\t}\n\t\t\t\treturn s, nil\n\t\t\t}), 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, f.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, 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'\")","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/frame_mapping.go#L131-L167","documentation":"Frame.getByLabel(label) on a k6 browser Frame requires a non-nullish first argument; the mapping in frame_mapping.go rejects it before contacting the browser. The label text (string or RegExp) is the only way this locator resolves form controls via their label association. Playwright's getByLabel carries the same requirement.","triggerScenarios":"Calling frame.getByLabel() with no argument, passing null/undefined, or passing a field-label variable that is undefined because the fixture lacks that key.","commonSituations":"Form-filling helpers driven by field-definition arrays with optional labels, i18n label lookups that miss, or renamed variables during refactors.","solutions":["Pass the label string or RegExp: frame.getByLabel('Password')","Default or validate the label value before the call (const label = field.label ?? field.ariaLabel)","Fix the undefined property or import","Use a RegExp for labels with required-field markers, e.g. getByLabel(/^Email/)"],"exampleFix":"// before\nconst pw = page.frame('#login').getByLabel(labelFor); // labelFor is undefined\n\n// after\nconst labelFor = 'Password';\nconst pw = page.frame('#login').getByLabel(labelFor);","handlingStrategy":"validation","validationCode":"const label = field.label ?? field.name;\nif (!isTextSelector(label)) throw new Error(`label required for ${field.id}`);\nframe.getByLabel(label);","typeGuard":"function isTextSelector(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  loc = frame.getByLabel(maybeLabel);\n} catch (e) {\n  if (/missing required argument 'label'/.test(String(e.message))) {\n    throw new Error(`label missing for field ${field.id} in frame`);\n  }\n  throw e;\n}","preventionTips":["Validate form-definition arrays once at script start: every field needs a label or explicit fallback","Make form-helper parameters required (no implicit undefined) in JSdoc or via early checks","Lint for getBy*() call sites with zero arguments","Cross-check ported Playwright form helpers kept their label argument"],"tags":["browser","frame","argument-validation","get-by","forms"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}