--- name: cdp_screenshot kind: function lang: go domain: browser version: "1.0.0" purity: impure signature: "func CdpScreenshot(c *CDPConn, outputPath string, opts CdpScreenshotOpts) error" description: "Captura un screenshot de la pagina actual via Page.captureScreenshot y lo guarda en el archivo indicado. Soporta PNG y JPEG, viewport o pagina completa. Crea el directorio destino si no existe." tags: [chrome, cdp, browser, automation, screenshot, devtools, png] uses_functions: [cdp_connect_go_browser, cdp_evaluate_go_browser] uses_types: [] returns: [] returns_optional: false error_type: "error_go_core" imports: [encoding/base64, fmt, os, path/filepath] params: - name: c desc: "conexión CDP activa" - name: outputPath desc: "ruta del archivo PNG/JPEG de salida" - name: opts desc: "opciones de captura (FullPage, Quality, Format)" output: "error si falla la captura o la escritura del archivo" tested: true tests: ["TestCdpScreenshot"] test_file_path: "functions/browser/chrome_launch_test.go" file_path: "functions/browser/cdp_screenshot.go" --- ## Ejemplo ```go conn, _ := CdpConnect(9222) CdpNavigate(conn, "https://example.com") err := CdpScreenshot(conn, "/tmp/page.png", CdpScreenshotOpts{ FullPage: true, Format: "png", }) ``` ## Notas El struct `CdpScreenshotOpts` tiene campos: `FullPage bool`, `Quality int` (JPEG), `Format string` ("png" o "jpeg"). Chrome retorna la imagen como base64 que se decodifica y escribe al disco.