{"record":{"id":"efc685eac0eb3de1","repo":"grafana/k6","slug":"parsing-text-content-options-w-efc685","errorCode":null,"errorMessage":"parsing text content options: %w","messagePattern":"parsing text content options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":333,"sourceCode":"\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing inner text options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.InnerText(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"last\": func() *sobek.Object {\n\t\t\tml := mapLocator(vu, lo.Last())\n\t\t\treturn rt.ToValue(ml).ToObject(rt)\n\t\t},\n\t\t\"nth\": func(nth int) *sobek.Object {\n\t\t\tml := mapLocator(vu, lo.Nth(nth))\n\t\t\treturn rt.ToValue(ml).ToObject(rt)\n\t\t},\n\t\t\"textContent\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameTextContentOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing text content options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := lo.TextContent(copts)\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\n\t\t\t\t}\n\t\t\t\treturn s, nil\n\t\t\t}), nil\n\t\t},\n\t\t\"inputValue\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameInputValueOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing input value options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L315-L351","documentation":"Thrown when locator.textContent(opts) fails to parse options into FrameTextContentOptions (embeds FrameBaseOptions: strict boolean, timeout number in ms). The mapping wraps the failure as 'parsing text content options: %w'. On success the promise resolves to the text, or null when the node has no text content; this error happens before any browser round-trip, purely from an unparseable opts argument.","triggerScenarios":"Calling locator.textContent('visible') or textContent(5000) — scalar in the opts slot; passing { state: 'visible' } (a waitFor option, not valid here) under strict parsing; non-object values such as arrays or functions.","commonSituations":"Confusing textContent options with waitFor options when adapting examples; reusing an options object built for a different locator method; passing millisecond numbers positionally out of habit from older APIs.","solutions":["Call textContent() with no options, or pass { timeout: <number-ms> } only","Remove state/strict-unrelated keys copied from waitFor(selector, { state }) examples","Ensure the argument is a plain object literal","Prefer locator.setDefaultTimeout() for site-wide timeouts"],"exampleFix":"// before\nconst t = await page.locator('.msg').textContent({ state: 'visible', timeout: '5s' });\n\n// after\nconst t = await page.locator('.msg').textContent({ timeout: 5000 });","handlingStrategy":"validation","validationCode":"function assertBaseOpts(method, opts) {\n  if (opts === null || opts === undefined) return;\n  if (typeof opts !== 'object' || Array.isArray(opts)) {\n    throw new TypeError(`${method} options must be a plain object, got ${typeof opts}`);\n  }\n  if ('timeout' in opts && typeof opts.timeout !== 'number') {\n    throw new TypeError(`${method} timeout must be a number (ms)`);\n  }\n}\nassertBaseOpts('textContent', opts);","typeGuard":"function isLocatorBaseOptions(v) {\n  if (v === null || v === undefined) return true;\n  if (typeof v !== 'object' || Array.isArray(v)) return false;\n  return (v.timeout === undefined || typeof v.timeout === 'number') &&\n         (v.strict === undefined || typeof v.strict === 'boolean');\n}","tryCatchPattern":"try {\n  const t = await locator.textContent(opts);\n} catch (e) {\n  if (/parsing text content options/.test(String(e.message))) {\n    throw new Error(`Bad textContent options: ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Do not copy waitFor({ state }) shapes into textContent","Keep per-method options objects minimal and literal","Remember the resolved value may legitimately be null; that is not this error"],"tags":["k6","browser","locator","options","textcontent"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}