{"record":{"id":"bb75fae544172db2","repo":"grafana/k6","slug":"missing-required-argument-alttext-bb75fa","errorCode":null,"errorMessage":"missing required argument 'altText'","messagePattern":"missing required argument 'altText'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":140,"sourceCode":"\t\t\"getAttribute\": func(selector, name string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewFrameBaseOptions(f.Timeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing getAttribute options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := f.GetAttribute(selector, name, popts)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck\n\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'\")","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/frame_mapping.go#L122-L158","documentation":"Frame.getByAltText(altText) on a k6 browser Frame requires a non-nullish first argument; the mapping layer in frame_mapping.go throws before any CDP call. 'Nullish' covers a missing argument, null, and undefined (sobek passes Undefined for omitted JS arguments). The alt text (string or RegExp) is the locator's only input, matching Playwright's contract.","triggerScenarios":"Calling frame.getByAltText() where frame came from page.frame() or page.frames(), passing null/undefined, or forwarding an undefined variable from a test-data row.","commonSituations":"Multi-frame SPA tests where selectors live in data files, ported Playwright specs with helper indirection, or destructuring mistakes that leave the alt variable undefined.","solutions":["Pass a string or RegExp: frame.getByAltText('main-logo')","Validate/default data-sourced values before the call","Fix the typo or missing field producing undefined","Use a RegExp for versioned image alt text, e.g. getByAltText(/^logo-v\\d+$/)"],"exampleFix":"// before\nconst frame = page.frame(page.url());\nconst img = frame.getByAltText(altVar); // altVar is undefined\n\n// after\nconst altVar = 'hero image';\nconst img = frame.getByAltText(altVar);","handlingStrategy":"validation","validationCode":"if (!isTextSelector(altVar)) throw new Error('alt text is required before frame.getByAltText');\nframe.getByAltText(altVar);","typeGuard":"function isTextSelector(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}","tryCatchPattern":"try {\n  loc = frame.getByAltText(maybeAlt);\n} catch (e) {\n  if (/missing required argument 'altText'/.test(String(e.message))) {\n    throw new Error(`altText missing on frame ${frame.url()}`);\n  }\n  throw e;\n}","preventionTips":["Confirm the frame variable actually holds a Frame (not undefined) before chaining getBy* calls","Validate image-alt test data before the iteration loop","Keep per-frame selectors grouped with their frame lookup so omissions are visible","Add a one-off console.log of selector inputs when building new frame flows"],"tags":["browser","frame","argument-validation","get-by"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}