{"record":{"id":"0447d6e70639377e","repo":"grafana/k6","slug":"parsing-press-options-w","errorCode":null,"errorMessage":"parsing press options: %w","messagePattern":"parsing press options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":372,"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\tcopts, err := parseFrameSelectOptionOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select option options: %w\", err)\n\t\t\t}\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 option values: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.SelectOption(convValues, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"press\": func(key string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFramePressOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing press options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Press(key, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\n\t\t\"pressSequentially\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator press sequentially options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.PressSequentially(text, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\n\t\t\"type\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L354-L390","documentation":"Thrown synchronously when the options argument to locator.press(key, opts) fails to parse. The mapping (locator_mapping.go:368-372) builds common.FramePressOptions and wraps Parse failures as \"parsing press options: %w\". Parse (via ElementHandlePressOptions, element_handle_options.go:406-422) reads delay, noWaitAfter and timeout with coercing accessors and returns nil for ordinary values, so a real failure means sobek raised reading the object — a throwing getter, a Proxy trap, or a value whose numeric coercion throws.","triggerScenarios":"A getter on delay/timeout that raises; Proxy-wrapped options with throwing traps; a delay/timeout value whose toPrimitive/valueOf throws during ToInteger coercion.","commonSituations":"Keyboard helpers building options from lazily-validated config; instrumentation Proxies over arguments; passing class instances with accessors where a literal is expected.","solutions":["Pass a plain literal: locator.press('Enter', { delay: 100, timeout: 5000 })","Compute dynamic values before the call; no getters/Proxies on options","Note the key argument itself is not validated here — a bad options object is","try/catch the call for controlled failure handling"],"exampleFix":"// before\nawait locator.press('Enter', { get delay() { return cfg.delayMs; } }); // cfg undefined -> getter throws\n\n// after\nawait locator.press('Enter', { delay: cfg?.delayMs ?? 0 });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isPlainPressOptions(o) {\n  return o == null || (typeof o === 'object' &&\n    (o.delay === undefined || Number.isFinite(o.delay)) &&\n    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n    (o.timeout === undefined || Number.isFinite(o.timeout)));\n}","tryCatchPattern":"try {\n  await locator.press('Enter', opts);\n} catch (e) {\n  throw new Error(`press failed (options must be plain delay/noWaitAfter/timeout numbers-booleans): ${e}`);\n}","preventionTips":["Pass delay/timeout as numbers in milliseconds","Compute config values before building options","Avoid getters/Proxies on press options"],"tags":["k6","browser","locator","press","options"],"backgroundTag":"invalid-options-object","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}