{"record":{"id":"3343d3446a4145a3","repo":"grafana/k6","slug":"parsing-inner-html-options-w-3343d3","errorCode":null,"errorMessage":"parsing inner HTML options: %w","messagePattern":"parsing inner HTML options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":307,"sourceCode":"\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, lo.GetByTitle(ptitle, popts))\n\t\t\treturn rt.ToValue(ml).ToObject(rt), nil\n\t\t},\n\t\t\"locator\": func(selector string, opts sobek.Value) mapping {\n\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},","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L289-L325","documentation":"Thrown when locator.innerHTML(opts) fails to parse its options into FrameInnerHTMLOptions, which embeds FrameBaseOptions (strict boolean, timeout number in ms). The mapping wraps the cause as 'parsing inner HTML options: %w'. FrameBaseOptions.Parse in current k6 coerces values and ignores unknown keys, so the wrap is defensive and typically only reachable with an opts slot that is not a valid options object (or on stricter k6 versions).","triggerScenarios":"Calling page.locator('div#content').innerHTML('30s') or innerHTML(5000) — a scalar in the options slot; passing { timeout: '1m' } under a strict parser that expects a number; passing a selector or waitUntil string (not supported by innerHTML) from a copied Playwright waitForSelector call.","commonSituations":"Copy-pasting option objects between locator methods that accept different keys; passing a human-readable duration string instead of milliseconds; argument-order slips when scripting quickly.","solutions":["Call innerHTML() with no arguments, or with a plain object: locator.innerHTML({ timeout: 5000 })","Use numeric milliseconds for timeout, never strings like '5s'","Remove keys that innerHTML does not support (only strict and timeout are read)","Set a locator-wide default with locator.setDefaultTimeout(5000) to avoid per-call options"],"exampleFix":"// before\nconst html = await page.locator('#main').innerHTML('5s');\n\n// after\nconst html = await page.locator('#main').innerHTML({ 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('innerHTML', 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 html = await locator.innerHTML(opts);\n} catch (e) {\n  if (/parsing inner HTML options/.test(String(e.message))) {\n    throw new Error(`Bad innerHTML options: ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Call innerHTML() without arguments when defaults suffice","Never pass duration strings; k6 browser timeouts are numbers in milliseconds","Set locator/page default timeouts once instead of per call"],"tags":["k6","browser","locator","options","innerhtml"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}