{"record":{"id":"8f7ce5fc6e52e43e","repo":"grafana/k6","slug":"pressing-q-on-q-w-8f7ce5","errorCode":null,"errorMessage":"pressing %q on %q: %w","messagePattern":"pressing %q on %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/locator.go","lineNumber":548,"sourceCode":"\t\treturn nil, fmt.Errorf(\"selecting option on %q: %w\", l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn v, nil\n}\n\n// Press the given key on the element found that matches the locator's\n// selector with strict mode on.\nfunc (l *Locator) Press(key string, opts *FramePressOptions) error {\n\tl.log.Debugf(\n\t\t\"Locator:Press\", \"fid:%s furl:%q sel:%q key:%q opts:%+v\",\n\t\tl.frame.ID(), l.frame.URL(), l.selector, key, opts,\n\t)\n\n\topts.Strict = true\n\tif err := l.frame.press(l.selector, key, opts); err != nil {\n\t\treturn fmt.Errorf(\"pressing %q on %q: %w\", key, l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// PressSequentially focuses on the element and sequentially sends a keydown,\n// keypress, and keyup events for each character in the provided string.\n// For handling special keys, use the [Locator.Press] method.\nfunc (l *Locator) PressSequentially(text string, opts *FrameTypeOptions) error {\n\tl.log.Debugf(\n\t\t\"Locator:PressSequentially\", \"fid:%s furl:%q sel:%q text:%q opts:%+v\",\n\t\tl.frame.ID(), l.frame.URL(), l.selector, text, opts,\n\t)\n\t_, span := TraceAPICall(l.ctx, l.frame.page.targetID.String(), \"locator.pressSequentially\")\n\tdefer span.End()\n","sourceCodeStart":530,"sourceCodeEnd":566,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/locator.go#L530-L566","documentation":"Wrapped failure from Frame.press while dispatching the given key to the element matched by the locator's selector (strict mode forced). Fires on zero/multiple matches, when the element cannot receive focus, when the key name is not a recognized key, or when the CDP key events fail.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/locator.go:548 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid key name (e.g. 'Enter', 'ArrowDown', 'a') as accepted by CDP","Ensure the target element is visible and focusable with a unique selector","Use Type for literal text instead of Press for single characters if key naming is the issue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}