{"record":{"id":"0447d6e70639377e","repo":"grafana/k6","slug":"parsing-press-options-w","errorCode":null,"errorMessage":"parsing press options: %w","messagePattern":"parsing press options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":371,"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 := common.NewFrameSelectOptionOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFramePressOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTypeOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTypeOptions(lo.Timeout())","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L353-L389","documentation":"Thrown when locator.press(key, opts) fails to parse options into FramePressOptions (delay number in ms, plus base keys force/noWaitAfter/timeout; strict). The mapping wraps the cause as 'parsing press options: %w'. Parsing is synchronous and lenient in current k6 (delay/timeout coerced via ToInteger), so this error indicates the opts slot held something that is not a plain options object.","triggerScenarios":"Calling locator.press('Enter', 'fast') or press('Enter', 100) — scalar in the opts slot; passing { delay: '100ms' } under a strict parser; passing key names inside the options object ({ key: 'Enter' }) instead of as the first argument.","commonSituations":"Typing-speed delay passed as a duration string; ported Playwright snippets with slightly different argument order; options objects shared across press and type calls with incompatible keys.","solutions":["Pass options as an object: press('Enter', { delay: 100, timeout: 5000 })","Keep the key name as the first argument, never inside options","Use numeric milliseconds for delay and timeout","Omit options entirely when defaults suffice"],"exampleFix":"// before\nawait page.locator('#search').press('Enter', '100ms');\n\n// after\nawait page.locator('#search').press('Enter', { delay: 100 });","handlingStrategy":"validation","validationCode":"function assertPressOpts(opts) {\n  if (opts === null || opts === undefined) return;\n  if (typeof opts !== 'object' || Array.isArray(opts)) {\n    throw new TypeError('press options must be a plain object');\n  }\n  for (const k of ['delay', 'timeout']) {\n    if (k in opts && typeof opts[k] !== 'number') {\n      throw new TypeError(`press ${k} must be a number (ms)`);\n    }\n  }\n}","typeGuard":"function isPressOptions(v) {\n  if (v === null || v === undefined) return true;\n  if (typeof v !== 'object' || Array.isArray(v)) return false;\n  return (v.delay === undefined || typeof v.delay === 'number') &&\n         (v.timeout === undefined || typeof v.timeout === 'number');\n}","tryCatchPattern":"try {\n  await locator.press('Enter', opts);\n} catch (e) {\n  if (/parsing press options/.test(String(e.message))) {\n    throw new Error(`Bad press options: ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Keep the key name as the first argument, never inside options","Express typing delays as numeric milliseconds","Omit options entirely for a plain keypress"],"tags":["k6","browser","locator","options","press"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}