{"record":{"id":"fcdf4561542f638d","repo":"grafana/k6","slug":"clicking-on-q-w","errorCode":null,"errorMessage":"clicking on %q: %w","messagePattern":"clicking on %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":609,"sourceCode":"\n// ChildFrames returns a list of child frames.\nfunc (f *Frame) ChildFrames() []*Frame {\n\tf.childFramesMu.RLock()\n\tdefer f.childFramesMu.RUnlock()\n\n\tl := make([]*Frame, 0, len(f.childFrames))\n\tfor child := range f.childFrames {\n\t\tl = append(l, child)\n\t}\n\treturn l\n}\n\n// Click clicks the first element found that matches selector.\nfunc (f *Frame) Click(selector string, opts *FrameClickOptions) error {\n\tf.log.Debugf(\"Frame:Click\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tif err := f.click(selector, opts); err != nil {\n\t\treturn fmt.Errorf(\"clicking on %q: %w\", selector, err)\n\t}\n\n\tapplySlowMo(f.ctx)\n\n\treturn nil\n}\n\nfunc (f *Frame) click(selector string, opts *FrameClickOptions) error {\n\tclick := func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.click(p, opts.ToMouseClickOptions())\n\t}\n\tact := f.newPointerAction(\n\t\tselector, DOMElementStateAttached, opts.Strict, click, &opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(f.ctx, act, opts.Timeout); err != nil {\n\t\treturn errorFromDOMError(err)\n\t}\n","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame.go#L591-L627","documentation":"Frame.Click() runs a pointer action that first waits for an element matching the selector to be attached, visible, stable and enabled (per injected_script.js checks) within opts.Timeout, then dispatches mouse events. This error wraps any failure of that pipeline — most commonly a wait timeout ('timed out after Nms' from the injected script) or a DOM error surfaced by errorFromDOMError.","triggerScenarios":"Selector matches nothing, matches multiple elements with strict:true, or the element stays hidden/covered by an overlay (cookie banner, spinner) so actionability checks time out; opts.Timeout set lower than render time; navigation destroys the execution context mid-action.","commonSituations":"SPA renders the target late (client-side hydration); a modal or toast overlays the button; default action timeout lowered via options (timeout in browser options); strict-mode selectors that match a list (e.g. '.btn' with several buttons); iframe content while the caller used the main frame.","solutions":["Wait first: await page.waitForSelector(sel, { state: 'visible', timeout: 30000 }) then click, or pass a larger { timeout: ... } to click itself.","Make the selector unique (data-testid) to avoid strict-mode ambiguity.","Handle overlays: close/dismiss the overlay, or scroll the element into view before clicking.","If the element is intentionally non-actionable in tests, assert with try-catch instead of letting the iteration abort."],"exampleFix":"// before\npage.click('#submit'); // fails: button under cookie banner\n\n// after\nawait page.waitForSelector('#submit', { state: 'visible', timeout: 30000 });\npage.click('#submit', { timeout: 30000 });","handlingStrategy":"validation","validationCode":"await page.waitForSelector(sel, { state: 'visible', timeout: 30000 });\n// optionally verify uniqueness for strict mode:\nconst n = page.evaluate('(s) => document.querySelectorAll(s).length', sel);","typeGuard":null,"tryCatchPattern":"try {\n  page.click(sel, { timeout: 30000 });\n} catch (e) {\n  if (/timed out/.test(e.message)) { /* retry or mark element-not-ready */ }\n  throw e;\n}","preventionTips":["Prefer data-testid selectors for uniqueness.","Pass an explicit timeout larger than worst-case render time.","Dismiss known overlays (cookie banners) as a setup step."],"tags":["browser","click","selector","timeout","actionability","overlay"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}