Files
fn_registry/functions/browser/cdp_hover_ref.go
T
Egutierrez 7d395f39e5 feat(browser): cdp_click_ref/cdp_hover_ref usan cdp_wait_actionable
Antes de calcular el centro y despachar el pointer, ambos esperan a que el
elemento sea accionable (visible + stable + hit-test contra elementFromPoint),
evitando clicks/hover tragados por overlays/banners o por elementos aún
montándose o animándose. Si la comprobación no converge en 2s, se cae al
cálculo de centro previo (sin regresión). Modo 'instant' sigue saltando al
click JS directo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 20:57:44 +02:00

24 lines
962 B
Go

package browser
import "fmt"
// CdpHoverRef mueve el ratón con trayectoria humanizada (Bézier) sobre el
// elemento del #ref. Útil para activar menús y tooltips que reaccionan a hover.
// El #ref es un backendDOMNodeId extraído del AX outline por page_perceive.
func CdpHoverRef(c *CDPConn, backendNodeID int, opts MouseHumanOpts) error {
if c == nil {
return fmt.Errorf("cdp hover ref: conexión nil")
}
// Preferir el punto validado por actionability; si no converge, caer al centro.
if x, y, err := CdpWaitActionable(c, backendNodeID, false, refActionableTimeout); err == nil {
return CdpMoveMouseHuman(c, x, y, opts)
}
// scroll al elemento si no está visible; ignorar error (no fatal)
_, _ = c.sendCDP("DOM.scrollIntoViewIfNeeded", map[string]any{"backendNodeId": backendNodeID})
cx, cy, err := refBoxCenter(c, backendNodeID)
if err != nil {
return fmt.Errorf("cdp hover ref: %w", err)
}
return CdpMoveMouseHuman(c, cx, cy, opts)
}