{"record":{"id":"be3e21a32a9994c8","repo":"grafana/k6","slug":"missing-required-argument-text-be3e21","errorCode":null,"errorMessage":"missing required argument 'text'","messagePattern":"missing required argument 'text'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":185,"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, 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'\")\n\t\t\t}\n\t\t\tptext, popts := parseGetByBaseOptions(vu.Context(), text, true, opts)\n\n\t\t\tml := mapLocator(vu, f.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'\")\n\t\t\t}\n\t\t\tptitle, popts := parseGetByBaseOptions(vu.Context(), title, false, opts)\n\n\t\t\tml := mapLocator(vu, f.GetByTitle(ptitle, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"goto\": func(url string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tgopts := common.NewFrameGotoOptions(\n\t\t\t\tf.Referrer(),","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/frame_mapping.go#L167-L203","documentation":"Frame.getByText(text) on a k6 browser Frame requires a non-nullish first argument; the mapping in frame_mapping.go throws before any browser call. The text (string or RegExp) is the locator's only matching criterion for element text content; options only adjust matching semantics. Playwright's getByText is equally strict.","triggerScenarios":"Calling frame.getByText() with no argument, passing null/undefined, or passing an expected-message variable that is undefined because the fixture or i18n bundle missed it.","commonSituations":"Content-verification helpers with optional message parameters, localized assertion strings, template literals referencing the wrong variable.","solutions":["Pass the text string or RegExp: frame.getByText('Order confirmed')","Default or validate content/i18n values before the call (const text = msg ?? 'Order confirmed')","Fix the undefined variable or missing message key","Use a RegExp for partial matching, e.g. frame.getByText(/confirmed/i), instead of omitting text"],"exampleFix":"// before\nconst ok = page.frame('#result').getByText(messageKey); // messageKey is undefined\n\n// after\nconst messageKey = 'Order confirmed';\nconst ok = page.frame('#result').getByText(messageKey);","handlingStrategy":"validation","validationCode":"const text = expected[key];\nif (!isTextSelector(text)) throw new Error(`expected[${key}] is required for getByText`);\nframe.getByText(text);","typeGuard":"function isTextSelector(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  loc = frame.getByText(maybeText);\n} catch (e) {\n  if (/missing required argument 'text'/.test(String(e.message))) {\n    throw new Error(`text missing for expectation '${key}'`);\n  }\n  throw e;\n}","preventionTips":["Validate expectation objects fully at script start; fail before any VU work","Default i18n lookups with ?? so text is never undefined at call time","Prefer RegExp partial matches over omitting text when wording varies","Log resolved expected texts once to surface data gaps early"],"tags":["browser","frame","argument-validation","get-by","text-matching"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}