# Issue #017: Actions API - Acciones Complejas **Tipo**: Enhancement **Prioridad**: Alta **Estado**: En progreso ## Descripción Implementar API para acciones complejas de mouse y teclado: hover, drag & drop, double click, right click, scroll, etc. ## Funcionalidad deseada ### Acciones de Mouse - Hover sobre elemento - Double click - Right click (menú contextual) - Drag and drop - Scroll a posición específica - Scroll a elemento - Move mouse a coordenadas - Mouse down/up separados ### Acciones de Teclado - Press key (con modificadores) - Hold key - Shortcuts (Ctrl+C, Ctrl+V, etc.) - Combinaciones complejas ### Cadenas de acciones - Encadenar múltiples acciones - ActionChain pattern (como Selenium) ## API propuesta ```go // Mouse actions func (b *Browser) Hover(ctx context.Context, selector string) error func (b *Browser) DoubleClick(ctx context.Context, selector string) error func (b *Browser) RightClick(ctx context.Context, selector string) error func (b *Browser) DragAndDrop(ctx context.Context, sourceSelector, targetSelector string) error func (b *Browser) ScrollTo(ctx context.Context, x, y int) error func (b *Browser) ScrollToElement(ctx context.Context, selector string) error func (b *Browser) ScrollBy(ctx context.Context, x, y int) error func (b *Browser) MoveMouse(ctx context.Context, x, y int) error // Keyboard actions func (b *Browser) PressKey(ctx context.Context, key string) error func (b *Browser) HoldKey(ctx context.Context, key string) error func (b *Browser) ReleaseKey(ctx context.Context, key string) error func (b *Browser) SendKeys(ctx context.Context, keys ...string) error // Action chains type ActionChain struct { browser *Browser actions []action } func (b *Browser) NewActionChain() *ActionChain func (ac *ActionChain) MoveTo(selector string) *ActionChain func (ac *ActionChain) Click() *ActionChain func (ac *ActionChain) DoubleClick() *ActionChain func (ac *ActionChain) ContextClick() *ActionChain func (ac *ActionChain) SendKeys(keys ...string) *ActionChain func (ac *ActionChain) Pause(duration time.Duration) *ActionChain func (ac *ActionChain) Perform(ctx context.Context) error ``` ## Uso ### Hover ```go b.Hover(ctx, "#menu-button") b.Click(ctx, "#dropdown-item") ``` ### Double click ```go b.DoubleClick(ctx, "#file-icon") ``` ### Right click ```go b.RightClick(ctx, "#context-menu-trigger") ``` ### Drag and drop ```go b.DragAndDrop(ctx, "#drag-source", "#drop-target") ``` ### Scroll ```go // Scroll a elemento b.ScrollToElement(ctx, "#footer") // Scroll por pixels b.ScrollBy(ctx, 0, 500) // Scroll a posición absoluta b.ScrollTo(ctx, 0, 1000) ``` ### Shortcuts de teclado ```go // Ctrl+A (Select all) b.PressKey(ctx, "Control+A") // Ctrl+C (Copy) b.PressKey(ctx, "Control+C") // Esc b.PressKey(ctx, "Escape") ``` ### Action chains ```go chain := b.NewActionChain() chain. MoveTo("#drag-handle"). Click(). MoveTo("#drop-zone"). Release(). Perform(ctx) ``` ## CDP Methods - `Input.dispatchMouseEvent` - `Input.dispatchKeyEvent` - `Input.dispatchTouchEvent` - `Runtime.evaluate` para JavaScript ## Referencias - CDP Input: https://chromedevtools.github.io/devtools-protocol/tot/Input/ - Selenium Actions: https://www.selenium.dev/documentation/webdriver/actions_api/ - Playwright actions: https://playwright.dev/docs/input