{"record":{"id":"fdcccff5a53dc454","repo":"grafana/k6","slug":"double-clicking-on-element-w","errorCode":null,"errorMessage":"double clicking on element: %w","messagePattern":"double clicking on element: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":880,"sourceCode":"\t\treturn nil, fmt.Errorf(\"element is not an iframe\")\n\t}\n\n\tframe, ok := h.frame.manager.getFrameByID(node.FrameID)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"frame not found for id %s\", node.FrameID)\n\t}\n\n\treturn frame, nil\n}\n\n// Dblclick scrolls element into view and double clicks on the element.\nfunc (h *ElementHandle) Dblclick(opts *ElementHandleDblclickOptions) error {\n\tdblclick := func(_ context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.dblclick(p, opts.ToMouseClickOptions())\n\t}\n\tdblclickAction := h.newPointerAction(dblclick, &opts.ElementHandleBasePointerOptions)\n\tif _, err := call(h.ctx, dblclickAction, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"double clicking on element: %w\", err)\n\t}\n\n\tapplySlowMo(h.ctx)\n\n\treturn nil\n}\n\n// DispatchEvent dispatches a DOM event to the element.\nfunc (h *ElementHandle) DispatchEvent(typ string, eventInit any) error {\n\tdispatchEvent := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.dispatchEvent(apiCtx, typ, eventInit)\n\t}\n\topts := NewElementHandleBaseOptions(h.DefaultTimeout())\n\tdispatchEventAction := h.newAction(\n\t\t[]string{}, dispatchEvent, opts.Force, withRetry, opts.NoWaitAfter, opts.Timeout,\n\t)\n\tif _, err := call(h.ctx, dispatchEventAction, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"dispatching element event %q: %w\", typ, err)","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/element_handle.go#L862-L898","documentation":"ElementHandle.dblClick() wraps the failure of the underlying pointer action. Before dispatching the two clicks through the CDP Input domain, the action scrolls the element into view and waits for it to be visible, enabled, stable, and able to receive the events; any of those waits timing out, or a CDP/session failure, is wrapped with the 'double clicking on element' prefix.","triggerScenarios":"Element is hidden, zero-sized, or display:none; an overlay covers it so the hit test fails ('other element would receive the event'); the element animates so it never reaches a stable position; the handle was detached by a re-render or navigation before the click landed; the timeout option or default (30s, K6_BROWSER_TIMEOUT) expires; the page or browser was closed mid-action.","commonSituations":"Cookie banners or modals covering the target button; CSS transitions keeping elements 'unstable'; React re-renders replacing the DOM node between query and click; slow CI machines where the default 30s timeout expires; headless-mode layout differences hiding elements.","solutions":["Wait for the element first: await el.waitFor({ state: 'visible' }) and check await el.isEnabled() before dblClick","Pass a larger timeout: await el.dblClick({ timeout: '60s' })","Skip actionability checks if the click is safe: await el.dblClick({ force: true })","Dismiss blocking overlays (cookie banners, spinners) before the action","Re-query the element handle right before clicking if the page re-renders frequently"],"exampleFix":"// before\nconst el = await page.$('#save');\nawait el.dblClick(); // times out: overlay covers the button\n\n// after\nconst el = await page.$('#save');\nawait el.waitFor({ state: 'visible', timeout: '10s' });\nawait page.$('#cookie-ok').then(b => b && b.click()).catch(() => {});\nawait el.dblClick({ timeout: '30s' });","handlingStrategy":"try-catch","validationCode":"// Make the element actionable before double clicking\nawait el.waitFor({ state: 'visible', timeout: '10s' });\nif (!(await el.isEnabled())) {\n  throw new Error('element not enabled; cannot dblclick');\n}\nawait el.dblClick({ timeout: '30s' });","typeGuard":null,"tryCatchPattern":"try {\n  await el.dblClick({ timeout: '30s' });\n} catch (e) {\n  const msg = String(e.message);\n  if (/timed out|timeout/i.test(msg)) {\n    await el.dblClick({ force: true }); // skip actionability on retry\n  } else if (/not attached|Could not find object/i.test(msg)) {\n    const fresh = await page.$(sel); // re-query and retry once\n    await fresh.dblClick({ timeout: '30s' });\n  } else throw e;\n}","preventionTips":["Always waitFor({ state: 'visible' }) before pointer actions","Dismiss known overlays (cookie banners, spinners) before clicking","Set an explicit timeout per action instead of relying on the 30s default","Use force:true only when you have already verified the element state yourself"],"tags":["browser","mouse","dblclick","action-timeout","actionability","k6"],"backgroundTag":"element-not-actionable","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}