# Playwright Form Automation Toolkit ๐Ÿค– Sistema completo per automatizzare form submission su siti web con debugging intelligente. ## Features โœจ **Page Dumping System** - Estrazione automatica di HTML, screenshot e form selectors ๐Ÿ” **Smart Login** - Auto-login con fallback manuale ๐ŸŽฏ **Error Recovery** - Dump automatico ad ogni errore ๐Ÿ“ธ **Visual Debugging** - Screenshot full-page ad ogni step ๐Ÿ”„ **Iterative Workflow** - Ciclo rapido test โ†’ dump โ†’ fix โ†’ retest ## Quick Start ```bash # 1. Installa dipendenze npm install # 2. Installa browser Chromium npm run install-browsers # 3. Modifica template-automation.js con i tuoi dati # - SITE_URL # - LOGIN_CREDENTIALS # - FORM_DATA # - Selettori specifici per il tuo sito # 4. Esegui npm test ``` ## Structure ``` playwright-form-automation/ โ”œโ”€โ”€ .github/ โ”‚ โ””โ”€โ”€ copilot-instructions.md # Guida completa workflow โ”œโ”€โ”€ package.json # Dipendenze npm โ”œโ”€โ”€ template-automation.js # Template script automation โ”œโ”€โ”€ page-dumps/ # Output debug (auto-creata) โ”‚ โ”œโ”€โ”€ form-initial-*.html โ”‚ โ”œโ”€โ”€ form-initial-*.png โ”‚ โ”œโ”€โ”€ form-initial-*-selectors.txt โ”‚ โ””โ”€โ”€ ... โ””โ”€โ”€ README.md # Questo file ``` ## Core Concepts ### 1. Page Dumping Ad ogni step importante (e ad ogni errore), lo script salva: - **HTML completo** - Per analisi struttura DOM - **Screenshot** - Per vedere visivamente cosa รจ successo - **Form selectors** - JSON con tutti gli elementi form (input, select, textarea, button) ```javascript await dumpPageInfo(page, 'step-name'); // Crea: // - page-dumps/step-name-.html // - page-dumps/step-name-.png // - page-dumps/step-name--selectors.txt ``` ### 2. Iterative Debugging ```bash # Run 1: Script fallisce node template-automation.js # โŒ Error: Timeout waiting for 'input[name="username"]' # Analizza dump cat page-dumps/login-error-*-selectors.txt # Scopri che il campo รจ 'input[name="user"]' non "username" # Fix nello script # Cambia: await page.fill('input[name="username"]', ...) # In: await page.fill('input[name="user"]', ...) # Run 2: Riprova node template-automation.js # โœ… Success! ``` ### 3. Select2 Dropdown Handling Select2 (jQuery plugin usato da molti siti) nasconde i `