{"record":{"id":"692ed2b0c90fae00","repo":"grafana/k6","slug":"missing-required-argument-testid","errorCode":null,"errorMessage":"missing required argument 'testId'","messagePattern":"missing required argument 'testId'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_locator_mapping.go","lineNumber":53,"sourceCode":"\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, fl.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, fl.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, fl.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'\")\n\t\t\t}\n\t\t\tptext, popts := parseGetByBaseOptions(vu.Context(), text, true, opts)\n\n\t\t\tml := mapLocator(vu, fl.GetByText(ptext, 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":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/frame_locator_mapping.go#L35-L71","documentation":"FrameLocator.getByTestId(testId) in the k6 browser module requires a non-nullish argument; the mapping rejects absent, null, or undefined values before calling parseStringOrRegex. The test id (string or RegExp) is matched against the data-testid attribute (configurable) and is the only input to this locator. Playwright has the same contract.","triggerScenarios":"Calling page.frameLocator('iframe').getByTestId() with no argument, passing null/undefined, or forwarding a test-id constant that is undefined because it was renamed or never exported.","commonSituations":"Shared selector-constant modules where an id was renamed, codegen output pasted incompletely, or data-driven assertions missing the id column.","solutions":["Pass the test id string or RegExp: frameLocator.getByTestId('submit-button')","Import/define the test-id constant and verify it is not undefined before use","Fix renamed constants or missing exports in the selector module","Use a RegExp for ids with generated suffixes, e.g. getByTestId(/^row-\\d+$/)"],"exampleFix":"// before\nimport { IDs } from './ids.js';\nconst el = page.frameLocator('#f').getByTestId(IDs.submit); // IDs.submit is undefined\n\n// after\nimport { IDs } from './ids.js';\nconst el = page.frameLocator('#f').getByTestId('submit-button');","handlingStrategy":"validation","validationCode":"const id = TID.submit;\nif (!isTextSelector(id)) throw new Error(`TID.submit is not a valid testId`);\nframeLocator.getByTestId(id);","typeGuard":"function isTextSelector(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  loc = frameLocator.getByTestId(maybeId);\n} catch (e) {\n  if (/missing required argument 'testId'/.test(String(e.message))) {\n    throw new Error(`testId missing; selectors module may be stale after rename`);\n  }\n  throw e;\n}","preventionTips":["Export a frozen selectors object and add a unit check that every used key is a non-empty string","Avoid dynamic property access (TID[name]) without a fallback; check the key exists first","Use RegExp test ids for generated attributes instead of building strings that can become undefined","Re-run the page-object smoke test after renaming any selector constant"],"tags":["browser","frame-locator","argument-validation","get-by","test-id"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}