{"record":{"id":"b537c982ee50dc44","repo":"grafana/k6","slug":"parsing-selecttext-options-w","errorCode":null,"errorMessage":"parsing selectText options: %w","messagePattern":"parsing selectText options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":215,"sourceCode":"\t\t\t}), nil\n\t\t},\n\t\t\"selectOption\": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tconvValues, err := ConvertSelectOptionValues(vu.Runtime(), values)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select options values: %w\", err)\n\t\t\t}\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing selectOption options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn eh.SelectOption(convValues, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"selectText\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing selectText options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SelectText(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setChecked\": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setChecked options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SetChecked(checked, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setInputFiles\": func(files sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetInputFilesOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setInputFiles options: %w\", err)","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L197-L233","documentation":"Thrown synchronously by ElementHandle.selectText() when its options fail to parse. selectText() parses common.ElementHandleBaseOptions (force, noWaitAfter, timeout), whose Parse in common/element_handle_options.go only leniently coerces and always returns nil, so this wrap is defensive and effectively unreachable in current k6.","triggerScenarios":"In current code none: force/noWaitAfter/timeout accept any JS value via coercion; unknown option keys are ignored.","commonSituations":"Scripts ported from Playwright passing extra keys; timeouts given as strings; attributing a selectText failure to options when the real error (element not an input/textarea, or a timeout inside the promise) happens later.","solutions":["Use only { force, noWaitAfter, timeout } with a millisecond number","Confirm the target is a text input or textarea before calling selectText","Upgrade k6 if this message appears, as current Parse cannot fail","Read the wrapped cause after the colon to identify the failing field"],"exampleFix":"// before\nawait el.selectText({ timeout: '10s' });\n\n// after\nawait el.selectText({ timeout: 10000 });","handlingStrategy":"try-catch","validationCode":"const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);\nconst bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));\nif (bad.length) console.warn(`selectText(): unsupported options ignored: ${bad.join(', ')}`);\nif (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {\n  throw new Error('selectText(): timeout must be ms number');\n}","typeGuard":"function isSelectTextOpts(o) {\n  if (o == null) return true;\n  return (o.force === undefined || typeof o.force === 'boolean') &&\n         (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n         (o.timeout === undefined || Number.isFinite(o.timeout));\n}","tryCatchPattern":"try {\n  await el.selectText(opts);\n} catch (e) {\n  if (/parsing selectText options/.test(String(e.message))) {\n    console.log(`fix selectText options: ${e.message}`);\n  } else throw e;\n}","preventionTips":["selectText only needs { force, noWaitAfter, timeout }; extra keys are ignored","Confirm the element is an input/textarea before calling; the real failures happen inside the promise","Current k6 cannot raise this parse error; occurrence signals a version mismatch"],"tags":["k6","browser","element-handle","select-text","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}