# Issue #011: Downloads Handling **Tipo**: Enhancement **Prioridad**: Media **Estado**: Pendiente ## Descripción Implementar sistema para detectar, gestionar y esperar downloads de archivos. ## Funcionalidad deseada - Detectar cuando inicia un download - Esperar a que download complete - Obtener path del archivo descargado - Configurar directorio de descargas - Cancelar downloads en progreso - Obtener progreso de download - Manejar múltiples downloads simultáneos ## API propuesta ```go type Download struct { ID string URL string Filename string Path string MimeType string Size int64 State DownloadState // "inProgress" | "completed" | "cancelled" } type DownloadState string const ( DownloadStateInProgress DownloadState = "inProgress" DownloadStateCompleted DownloadState = "completed" DownloadStateCancelled DownloadState = "cancelled" ) type DownloadOptions struct { DownloadPath string // Directorio donde guardar Behavior string // "allow" | "deny" | "allowAndName" } func (b *Browser) SetDownloadBehavior(ctx context.Context, opts *DownloadOptions) error func (b *Browser) WaitForDownload(ctx context.Context, action func()) (*Download, error) func (b *Browser) OnDownload(handler func(*Download)) error func (b *Browser) GetDownloads(ctx context.Context) ([]*Download, error) func (b *Browser) CancelDownload(ctx context.Context, downloadID string) error ``` ## Uso ```go // Configurar directorio de descargas b.SetDownloadBehavior(ctx, &browser.DownloadOptions{ DownloadPath: "/tmp/downloads", Behavior: "allow", }) // Esperar download download, _ := b.WaitForDownload(ctx, func() { b.Click(ctx, "#download-button") }) log.Printf("Downloaded: %s to %s", download.Filename, download.Path) // Handler de downloads b.OnDownload(func(d *browser.Download) { log.Printf("Download started: %s", d.Filename) }) ``` ## CDP Methods - `Browser.setDownloadBehavior` - `Page.downloadWillBegin` (evento) - `Page.downloadProgress` (evento) ## Referencias - CDP Browser.setDownloadBehavior: https://chromedevtools.github.io/devtools-protocol/tot/Browser/#method-setDownloadBehavior - Playwright downloads: https://playwright.dev/docs/downloads