grafana/k6 · error
clicking on element: %w
Error message
clicking on element: %w
What it means
Top-level wrapper for ElementHandle.Click. The click runs a pipeline — scroll into view, visible/stable/enabled actionability waits, hit-target check, mouse down/up, optional navigation wait — under opts.Timeout. Any pipeline failure surfaces as 'clicking on element: <cause>', most often a timeout waiting for actionability or 'another element is intercepting with pointer action'.
Source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:844
}
if err != nil {
return nil, fmt.Errorf("getting bounding box: %w", err)
}
return bbox, nil
}
// Click scrolls element into view and clicks in the center of the element
// TODO: look into making more robust using retries
// (see: https://github.com/microsoft/playwright/blob/master/src/server/dom.ts#L298)
func (h *ElementHandle) Click(opts *ElementHandleClickOptions) error {
click := h.newPointerAction(
func(apiCtx context.Context, handle *ElementHandle, p *Position) (any, error) {
return nil, handle.click(p, opts.ToMouseClickOptions())
},
&opts.ElementHandleBasePointerOptions,
)
if _, err := call(h.ctx, click, opts.Timeout); err != nil {
return fmt.Errorf("clicking on element: %w", err)
}
applySlowMo(h.ctx)
return nil
}
// ContentFrame returns the frame that contains this element.
func (h *ElementHandle) ContentFrame() (*Frame, error) {
var (
node *cdp.Node
err error
)
action := dom.DescribeNode().WithObjectID(h.remoteObject.ObjectID)
if node, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {
return nil, fmt.Errorf("getting remote node %q: %w", h.remoteObject.ObjectID, err)
}
if node == nil || node.FrameID == "" {
return nil, fmt.Errorf("element is not an iframe")View on GitHub (pinned to 93accf6570)
Solutions
- Increase the timeout option for the click
- Pass { force: true } to skip actionability and hit-target checks when an overlay is expected and the click must still land
- Dismiss intercepting overlays (cookie banners, loaders) before clicking
- Re-locate the element immediately before clicking so it is fresh
- Pass { noWaitAfter: true } if the post-click navigation wait is what times out
Example fix
// before
await handle.click({ timeout: 5000 }); // clicking on element: timeout
// after
await page.$('#cookie-accept')?.click?.(); // clear overlay
await handle.click({ timeout: 30000 });
// or, when the overlay is benign:
await handle.click({ force: true }); Defensive patterns
Strategy: retry
Validate before calling
// Cheap pre-flight: the actionability checks click will run
const visible = await handle.isVisible();
const enabled = await handle.isEnabled();
if (!visible || !enabled) throw new Error('element not actionable'); Try / catch
try {
await handle.click({ timeout: 30000 });
} catch (e) {
const msg = String(e);
if (msg.includes('intercepting')) {
await (await page.$('#cookie-accept')).click(); // clear overlay, retry
await handle.click({ timeout: 30000 });
} else if (msg.includes('timed out')) {
await handle.click({ force: true }); // last resort: skip checks
} else { throw e; }
} Prevention
- Default to generous timeouts in CI
- Handle cookie/banner overlays before main flows
- Force-click only when interception is understood
- Re-locate elements immediately before clicking
When it happens
Trigger: handle.click() on an element that never becomes visible/stable/enabled within the timeout, an overlay intercepting the hit target (error:intercept), the element detaching mid-action, or the post-click navigation wait timing out.
Common situations: Cookie banners and modals covering the target; endlessly animating SPAs that never reach 'stable'; disabled buttons; default 30s timeout exceeded on slow environments; handles reused across re-renders.
Related errors
- double clicking on element: %w
- clicking on %q: %w
- filling element: %w
- pressing %q on element: %w
- selecting text: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/410fac160f2d15d1.
Report an issue: GitHub.