{"record":{"id":"3b4be4c7c9860efc","repo":"grafana/k6","slug":"pressing-q-on-q-w","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/frame.go","lineNumber":1676,"sourceCode":"\treturn document.QueryAll(selector)\n}\n\n// Page returns page that owns frame.\nfunc (f *Frame) Page() *Page {\n\treturn f.manager.page\n}\n\n// ParentFrame returns the parent frame, if one exists.\nfunc (f *Frame) ParentFrame() *Frame {\n\treturn f.parentFrame\n}\n\n// Press presses the given key for the first element found that matches the selector.\nfunc (f *Frame) Press(selector, key string, opts *FramePressOptions) error {\n\tf.log.Debugf(\"Frame:Press\", \"fid:%s furl:%q sel:%q key:%q\", f.ID(), f.URL(), selector, key)\n\n\tif err := f.press(selector, key, opts); err != nil {\n\t\treturn fmt.Errorf(\"pressing %q on %q: %w\", key, selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) press(selector, key string, opts *FramePressOptions) error {\n\tpress := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn nil, handle.press(apiCtx, key, opts.ToKeyboardOptions())\n\t}\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, press,\n\t\t[]string{}, false, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}","sourceCodeStart":1658,"sourceCodeEnd":1694,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame.go#L1658-L1694","documentation":"Frame.Press() wraps every failure of the internal press action (waiting for the element, checking actionability, dispatching key events) into 'pressing \"<key>\" on \"<selector>\": <cause>'. This is a top-level wrapper, so the real reason is in the appended cause: timeout waiting for the element, element not attached, intercepted input, or a closed frame.","triggerScenarios":"frame.press(selector, key) where the selector matches nothing within opts.timeout (default 30s), the element is not visible/enabled (actionability check fails with force=false), the element is detached mid-press, or the key name is invalid (e.g. 'Return' instead of 'Enter').","commonSituations":"Pressing on overlay-covered buttons (cookie banners, spinners); wrong key naming; default timeout too short on slow CI; element inside an iframe that navigated away; strict mode violation when the selector matches multiple elements.","solutions":["Verify the element exists and is actionable: await frame.waitForSelector(selector, { state: 'visible' }) before press().","Use correct key names ('Enter', 'ArrowDown', 'a', 'Control+A') — single characters or named keys only.","If the element is intentionally covered during the test, pass { force: true } to skip actionability checks, or remove the overlay first.","Increase timeout: frame.press(sel, key, { timeout: 60_000 })."],"exampleFix":"// before\nawait frame.press('#search', 'Return'); // wrong key name + maybe hidden\n\n// after\nawait frame.waitForSelector('#search', { state: 'visible' });\nawait frame.press('#search', 'Enter', { timeout: 60_000 });","handlingStrategy":"validation","validationCode":"await frame.waitForSelector(sel, { state: 'visible' });\n// validate key name against k6's key set before pressing","typeGuard":null,"tryCatchPattern":"try { await frame.press(sel, key); }\ncatch (e) { if (/pressing .* on/.test(e.message)) { /* inspect wrapped cause: timeout vs intercepted */ } throw e; }","preventionTips":["Use named keys exactly as documented (Enter, ArrowDown, Control+A)","Wait for element visibility before pressing","Use force:true only for known overlay-covered elements"],"tags":["browser","keyboard","actionability","timeout","selector"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}