{"record":{"id":"6da476e3713f1e13","repo":"grafana/k6","slug":"parsing-inner-text-options-w-6da476","errorCode":null,"errorMessage":"parsing inner text options: %w","messagePattern":"parsing inner text options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":316,"sourceCode":"\t\t\treturn mapLocator(vu, lo.Locator(selector, parseLocatorOptions(rt, opts)))\n\t\t},\n\t\t\"frameLocator\": func(selector string) *sobek.Object {\n\t\t\tmfl := mapFrameLocator(vu, lo.FrameLocator(selector))\n\t\t\treturn rt.ToValue(mfl).ToObject(rt)\n\t\t},\n\t\t\"innerHTML\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameInnerHTMLOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing inner HTML options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.InnerHTML(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"innerText\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameInnerTextOptions(lo.Timeout())\n\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}","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L298-L334","documentation":"Thrown when locator.innerText(opts) cannot parse its options into FrameInnerTextOptions (embeds FrameBaseOptions: strict boolean, timeout number in ms). The mapping wraps the cause as 'parsing inner text options: %w'. The current parser is lenient — it iterates object keys, coerces values and ignores unknown ones — so in practice this error means the second argument was not a usable options object.","triggerScenarios":"Calling locator.innerText(30000) or innerText('30s') with a scalar in the opts slot; passing a non-plain-object (e.g. a function or array) as options; wrong-typed strict/timeout fields on k6 builds that validate types strictly.","commonSituations":"Scripts migrated from Puppeteer where waitForTimeout-style string durations are common; passing the same options object reused from a click() call into innerText(); typos like { timout: 5000 } that strict parsers reject.","solutions":["Call innerText() bare, or pass { timeout: <number-ms> }","Verify the second parameter is a plain object literal, not a string/number/array","Spell keys exactly: strict, timeout","Re-run with the latest k6 browser module, which ignores/coerces bad keys instead of failing"],"exampleFix":"// before\nconst text = await page.locator('h1').innerText('10s');\n\n// after\nconst text = await page.locator('h1').innerText({ timeout: 10000 });","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('innerText', 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 text = await locator.innerText(opts);\n} catch (e) {\n  if (/parsing inner text options/.test(String(e.message))) {\n    throw new Error(`Bad innerText options: ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Reuse one validated options builder across text-reading calls","Only strict and timeout are meaningful; drop everything else","Prefer numbers over strings for all durations"],"tags":["k6","browser","locator","options","innertext"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}