{"record":{"id":"0bf0ab3ed3b98324","repo":"grafana/k6","slug":"missing-required-argument-text-0bf0ab","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/page_mapping.go","lineNumber":227,"sourceCode":"\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, p.GetByTitle(ptitle, 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, p.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, p.GetByText(ptext, 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\tp.Referrer(),\n\t\t\t\tp.NavigationTimeout(),\n\t\t\t)\n\t\t\tif err := gopts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing page navigation options to %q: %w\", url, err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tresp, err := p.Goto(url, gopts)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/page_mapping.go#L209-L245","documentation":"Thrown by the Page mapping's getByText method. The text to match is mandatory; the mapping validates it with k6common.IsNullish, then parses string/RegExp plus options (exact/substring) via parseGetByBaseOptions before calling p.GetByText. Nullish input never becomes a locator.","triggerScenarios":"page.getByText() with no arguments; page.getByText(undefined) from unset data; passing only an options object as the first parameter.","commonSituations":"Assertion helpers that wrap getByText and forward optional parameters verbatim; empty fields in CSV-driven tests; Playwright example code trimmed during porting.","solutions":["Pass a string or RegExp: page.getByText('Welcome') or page.getByText(/welcome/i)","Guard dynamic text: page.getByText(text ?? 'Welcome')","In wrapper helpers, throw a specific error when the forwarded text is nullish so the failure points at your data, not the API"],"exampleFix":"// before\npage.getByText();\n\n// after\npage.getByText('Welcome');","handlingStrategy":"validation","validationCode":"if (text === undefined || text === null) {\n  throw new Error(`page.getByText: 'text' is required, got ${text}`);\n}\nconst loc = page.getByText(text, opts);","typeGuard":"function isTextMatcher(v) {\n  return typeof v === 'string' || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  page.getByText(text);\n} catch (e) {\n  if (!e.message.includes(\"missing required argument 'text'\")) throw e;\n  throw new Error(`expected text value missing from data`);\n}","preventionTips":["In wrapper helpers, make the text parameter required (TS) or assert it before forwarding"],"tags":["browser","page","getbytext","locator","argument-validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}