{"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/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/page_mapping.go#L173-L209","documentation":"Thrown by page.getByLabel() in the k6 browser module (internal/js/modules/k6/browser/browser/page_mapping.go:191). The label argument (string or RegExp matched against associated form-label text) is mandatory; the nullish guard fails the call before parseGetByBaseOptions (which also accepts { exact } options as a second argument) can build the selector.","triggerScenarios":"Calling page.getByLabel() with zero arguments; passing null/undefined explicitly; passing a label from a data object where the key is absent or the accessor returns undefined.","commonSituations":"Form-filling scripts parameterized from CSV/JSON where some rows omit the label column; i18n label bundles with missing keys; label constants object refactored and one lookup silently became undefined.","solutions":["Pass a string or RegExp: page.getByLabel('Email address')","Default the value: const label = row.label ?? 'Email address'","Check the data source spelling (labels vs label vs labelText) before the call","Validate required data fields once at script init so failures are early and obvious"],"exampleFix":"// before\nconst email = page.getByLabel(formFields.emailLabel); // formFields.emailLabel undefined\n\n// after\nconst email = page.getByLabel(formFields.emailLabel ?? 'Email address', { exact: true });","handlingStrategy":"validation","validationCode":"const label = formFields.emailLabel ?? 'Email address';\nif (label === undefined || label === null) throw new Error('label is required');\nconst loc = page.getByLabel(label);","typeGuard":"function isNonEmptyStringOrRegExp(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}\n// usage: if (!isNonEmptyStringOrRegExp(label)) throw new Error('label must be a non-empty string or RegExp');","tryCatchPattern":"try {\n  const loc = page.getByLabel(label);\n} catch (e) {\n  if (/missing required argument 'label'/.test(e.message)) throw new Error(`label missing for field ${field.name}`);\n  throw e;\n}","preventionTips":["Define form labels in one place and assert the key exists before the loop","Default labels with ?? instead of passing possibly-undefined values","Double-check fixture column names (label vs labels vs labelText)","Validate required data fields once at init so failures happen before browser work"],"tags":["browser","page","form","argument-validation","api-misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}