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

  1. Increase the timeout option for the click
  2. Pass { force: true } to skip actionability and hit-target checks when an overlay is expected and the click must still land
  3. Dismiss intercepting overlays (cookie banners, loaders) before clicking
  4. Re-locate the element immediately before clicking so it is fresh
  5. 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

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


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/410fac160f2d15d1. Report an issue: GitHub.