Skip to content

pdellibergoli/ai-test-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Test Automation Framework

Framework unificato di test automation powered by AI
Supporto completo per test Mobile (iOS/Android) e Web (Browser)

Python License Appium Browser-Use App-Use


✨ Caratteristiche Principali

🎨 Interfaccia Web Completa

  • Home Dashboard intuitiva
  • Editor Visuale per test case
  • Generatore AI integrato
  • Configurazione LLM centralizzata
  • Esecuzione in tempo reale
  • Report interattivi

πŸš€ Testing Avanzato

  • Test Mobile iOS & Android
  • Test Web multi-browser
  • Cloud Testing con LambdaTest
  • Log in tempo reale
  • Screenshot automatici
  • Multi-LLM Support

πŸ“Έ Screenshots

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🏠 Home  β†’  πŸ“ Editor  β†’  πŸ€– Generator  β†’  βš™οΈ Config β”‚
β”‚            ↓                                         β”‚
β”‚         ▢️ Execute  β†’  πŸ“Š Reports                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Quick Start

1️⃣ Setup Ambiente

# Clona il repository
git clone https://github.com/pdellibergoli/ai-test-automation.git
cd aitestautomation

# Crea e attiva ambiente virtuale
python -m venv .venv

# Windows
.venv\Scripts\activate

# Mac/Linux
source .venv/bin/activate

# Installa dipendenze
pip install -r requirements.txt

2️⃣ Configura API Keys

Metodo 1: Tramite Web UI (Raccomandato)

# Avvia il framework
python web_editor.py

# Nel browser:
# 1. Vai su http://127.0.0.1:5000
# 2. Clicca su "Configurazione"
# 3. Seleziona il provider LLM (Gemini, OpenAI, Ollama)
# 4. Inserisci la tua API key
# 5. Salva

Metodo 2: Manualmente via .env

Crea un file .env nella root del progetto:

# Gemini (Raccomandato - Free Tier disponibile)
GOOGLE_API_KEY=your_google_api_key_here
GEMINI_MODEL=gemini-2.5-flash

# Opzionale: Altri provider
# OpenAI
OPENAI_API_KEY=your_openai_key
OPENAI_MODEL=gpt-4.1-mini

# Ollama (Locale)
USE_LOCAL_LLM=false
LOCAL_LLM=llava:13b
OLLAMA_BASE_URL=http://localhost:11434

# Provider attivo
WEB_LLM_PROVIDER=gemini  # Opzioni: gemini, openai, ollama

3️⃣ Installa Driver (per test mobile/web)

# Browser automation
playwright install chromium --with-deps

# Mobile automation (se necessario)
npm install -g appium
appium driver install uiautomator2  # Android
appium driver install xcuitest      # iOS (solo su Mac)

4️⃣ Avvia il Framework! πŸŽ‰

python web_editor.py

Il browser si aprirΓ  automaticamente su http://127.0.0.1:5000


🎨 Interfaccia Web

🏠 Home Dashboard

Punto di partenza per tutte le operazioni:

  • Editor Test Case: Gestisci i tuoi test
  • Genera Test Case: Crea test con l'AI
  • Configurazione: Imposta provider LLM e API keys
  • Vedi Report: Analizza le esecuzioni

πŸ“ Editor Test Case (/editor)

Feature Descrizione
Gestione File Carica, crea, e seleziona file Excel
Modifica Live Click su cella per editing immediato
Toggle Active Checkbox per abilitare/disabilitare test
Aggiungi/Rimuovi Icone intuitive per gestire righe
Esecuzione Avvia test con log in tempo reale
Stop Immediato Interrompi esecuzione in qualsiasi momento

πŸ€– Generatore AI (/generate)

1. Carica file requisiti   β†’  2. Seleziona prompt
                ↓
3. Clicca "Genera"  β†’  4. Monitora progresso
                ↓
5. Scarica CSV      β†’  6. Importa nell'editor

Features:

  • Log in tempo reale della generazione
  • Interruzione sicura del processo
  • Export diretto in formato CSV
  • Memorizzazione ultimo prompt usato
  • Configurazione LLM dinamica

βš™οΈ Configurazione LLM (/config) NUOVO!

Gestione centralizzata dei provider LLM:

Supported Providers:

  • Google Gemini (Free tier disponibile, raccomandato per iniziare)
  • OpenAI (GPT-4, GPT-4.1-mini, etc.)
  • Ollama (LLM locali, privacy totale)

Features:

  • πŸ”„ Cambio provider senza riavvio
  • πŸ”‘ Gestione sicura delle API keys
  • πŸ“ Configurazione modelli specifici
  • πŸ’Ύ Salvataggio automatico in .env
  • βœ… Validazione real-time delle impostazioni

Guida Rapida:

  1. Seleziona il provider dal menu dropdown
  2. Inserisci l'API key (recuperala dai link forniti)
  3. (Opzionale) Personalizza il nome del modello
  4. Clicca "Salva Configurazione"
  5. La nuova configurazione Γ¨ immediatamente attiva

πŸ“Š Report Viewer (/reports)

  • Lista cronologica di tutte le esecuzioni
  • Apertura diretta dei report HTML
  • Eliminazione report obsoleti
  • Filtri e ricerca integrati

πŸ“ Struttura Progetto

aitestautomation/
β”‚
β”œβ”€β”€ πŸš€ CORE
β”‚   β”œβ”€β”€ web_editor.py           # ⭐ Entry point principale
β”‚   β”œβ”€β”€ main_runner.py          # Test execution engine
β”‚   β”œβ”€β”€ config_manager.py       # Gestione configurazione dinamica
β”‚   β”œβ”€β”€ dati_test.xlsx          # Template file Excel
β”‚   β”œβ”€β”€ llm_models.json         # Definizione provider LLM
β”‚   β”œβ”€β”€ .env                    # Configurazione (gitignored)
β”‚   └── requirements.txt        # Dipendenze Python
β”‚
β”œβ”€β”€ 🎨 FRONTEND
β”‚   └── templates/
β”‚       β”œβ”€β”€ home.html           # Dashboard principale
β”‚       β”œβ”€β”€ index.html          # Editor test case
β”‚       β”œβ”€β”€ generate_tests.html # Generatore AI
β”‚       β”œβ”€β”€ config.html         # ⭐ Configurazione LLM (NUOVO)
β”‚       └── reports.html        # Viewer report
β”‚
β”œβ”€β”€ πŸ§ͺ TEST ENGINE
β”‚   └── tests/
β”‚       β”œβ”€β”€ test_generator.py       # AI test generation
β”‚       β”œβ”€β”€ mobile_test_executor.py # Mobile automation
β”‚       └── web_test_executor.py    # Web automation
β”‚
β”œβ”€β”€ πŸ› οΈ UTILITIES
β”‚   └── utilities/
β”‚       β”œβ”€β”€ excel_utils.py      # Excel I/O operations
β”‚       β”œβ”€β”€ report_utils.py     # HTML report generation
β”‚       └── ...                 # Altri helper
β”‚
β”œβ”€β”€ πŸ“Š OUTPUT
β”‚   β”œβ”€β”€ reports/unified/        # Report HTML generati
β”‚   └── screen/                 # Screenshot test failures
β”‚
└── πŸ“š DOCS
    └── docs/                   # Documentazione aggiuntiva

πŸ“‹ Requisiti Sistema

Software Necessario

Component Versione Scopo
Python 3.11+ Runtime principale
Node.js Latest LTS Appium Server
Chromium Latest Web testing
Appium 2.0+ Mobile testing

File Excel - Struttura Colonne

TestID | Descrizione | Task | Active | Device | Execution | Platform
DeviceName | UDID | AppID | AppPackage | AppActivity

πŸ’‘ Tip: L'editor web crea automaticamente la struttura corretta!


πŸŽ“ Guida d'Uso

Esempio: Creare un Test da Zero

  1. Configura il tuo LLM (prima volta):

    • Vai su "Configurazione"
    • Seleziona il provider (es. Gemini)
    • Inserisci l'API key
    • Salva
  2. Genera con AI:

    • Vai su "Genera Test Case"
    • Carica requisiti.txt
    • Seleziona prompt_costruisci_test.txt
    • Click "Genera" e attendi
  3. Modifica nell'Editor:

    • Apri il CSV generato
    • Affina le descrizioni
    • Imposta Active=TRUE
  4. Esegui:

    • Click "Avvia Test"
    • Monitora log in tempo reale
    • Controlla screenshot in caso di errori
  5. Analizza Report:

    • Vai su "Vedi Report"
    • Apri il report HTML
    • Analizza metriche e failures

πŸ€– Configurazione Multi-LLM

Provider Supportati

🌟 Google Gemini (Raccomandato)

Pro:

  • βœ… Free tier generoso
  • βœ… Ottima qualitΓ /prezzo
  • βœ… Veloce e affidabile
  • βœ… Modelli vision inclusi

Setup:

GOOGLE_API_KEY=your_key_here
GEMINI_MODEL=gemini-2.5-flash  # o gemini-2.0-pro
WEB_LLM_PROVIDER=gemini

Ottieni la key: Google AI Studio

πŸ”΅ OpenAI

Pro:

  • βœ… Modelli piΓΉ avanzati (GPT-4)
  • βœ… Documentazione eccellente
  • βœ… Supporto enterprise

Setup:

OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-4.1-mini  # o gpt-4
WEB_LLM_PROVIDER=openai

Ottieni la key: OpenAI Platform

🏠 Ollama (Locale)

Pro:

  • βœ… Gratuito al 100%
  • βœ… Privacy totale
  • βœ… Nessun rate limit
  • βœ… Offline

Setup:

# 1. Installa Ollama: https://ollama.ai/
# 2. Scarica un modello: ollama pull llava:13b

# In .env:
USE_LOCAL_LLM=true
LOCAL_LLM=llava:13b
OLLAMA_BASE_URL=http://localhost:11434
WEB_LLM_PROVIDER=ollama

Note: Richiede GPU per prestazioni ottimali.

Cambio Provider al Volo

Non serve riavviare l'applicazione:

  1. Vai su /config
  2. Seleziona nuovo provider
  3. Inserisci credenziali
  4. Salva β†’ Configurazione attiva immediatamente

πŸ”§ Troubleshooting

❌ ModuleNotFoundError: No module named 'pandas'

Causa: Ambiente virtuale non attivo

Soluzione:

# Windows
.venv\Scripts\activate

# Mac/Linux
source .venv/bin/activate

pip install -r requirements.txt
python web_editor.py
❌ TemplateNotFound: config.html

Causa: File template mancante

Soluzione: Verifica che la cartella templates/ esista e contenga:

  • home.html
  • index.html
  • generate_tests.html
  • config.html ← nuovo
  • reports.html
❌ API Key non valida o missing

Soluzione:

  1. Vai su /config nell'interfaccia web
  2. Verifica di aver inserito la key corretta
  3. Clicca "Salva Configurazione"
  4. Prova nuovamente l'esecuzione

Debug manuale .env:

# Verifica .env esiste
ls -la .env              # Mac/Linux
dir .env                 # Windows

# Controlla contenuto
cat .env                 # Mac/Linux
type .env                # Windows
❌ Cache browser non aggiorna l'interfaccia

Soluzione:

1. Hard Refresh: Ctrl+Shift+R (Windows) / Cmd+Shift+R (Mac)
2. Oppure: Apri finestra in incognito
3. Oppure: Svuota cache browser
❌ UnicodeEncodeError su Windows

Soluzione:

# Opzione 1: Avvia con UTF-8
python -X utf8 web_editor.py

# Opzione 2: Rimuovi emoji dai file .py
# (cerca caratteri come βœ… πŸš€ nei file config_manager.py, main_runner.py)
❌ llm_models.json non trovato

Causa: File di configurazione LLM mancante

Soluzione: Crea il file llm_models.json nella root del progetto con questo contenuto:

{
    "gemini": {
        "name": "Google Gemini",
        "fields": [
            { "id": "GOOGLE_API_KEY", "label": "API Key", "type": "password" },
            { "id": "GEMINI_MODEL", "label": "Model Name", "type": "text", "default": "gemini-2.5-flash" }
        ],
        "env_to_set": { "WEB_LLM_PROVIDER": "gemini", "USE_LOCAL_LLM": "false" }
    },
    "openai": {
        "name": "OpenAI",
        "fields": [
            { "id": "OPENAI_API_KEY", "label": "API Key", "type": "password" },
            { "id": "OPENAI_MODEL", "label": "Model Name", "type": "text", "default": "gpt-4.1-mini" }
        ],
        "env_to_set": { "WEB_LLM_PROVIDER": "openai", "USE_LOCAL_LLM": "false" }
    },
    "ollama": {
        "name": "Ollama (Locale)",
        "fields": [
            { "id": "LOCAL_LLM", "label": "Model Name", "type": "text", "default": "llava:13b" },
            { "id": "OLLAMA_BASE_URL", "label": "Base URL", "type": "text", "default": "http://localhost:11434" }
        ],
        "env_to_set": { "WEB_LLM_PROVIDER": "ollama", "USE_LOCAL_LLM": "true" }
    }
}

🀝 Contribuire

Contributi benvenuti! Per contribuire:

  1. Fork del repository
  2. Crea un branch (git checkout -b feature/AmazingFeature)
  3. Commit delle modifiche (git commit -m 'Add AmazingFeature')
  4. Push del branch (git push origin feature/AmazingFeature)
  5. Apri una Pull Request

πŸ“š Risorse

  • πŸ“– Documentazione Completa: Vedi cartella docs/
  • πŸŽ₯ Video Tutorial: [Coming Soon]
  • πŸ› Bug Reports: GitHub Issues

πŸ› οΈ Stack Tecnologico

Categoria Tecnologie
Backend Python, Flask
Testing Appium, Playwright, Browser-Use
AI/ML LangChain, Google Gemini, OpenAI, Ollama
Data Pandas, Excel
Frontend Bootstrap 5, JavaScript
Cloud LambdaTest Integration

πŸ“„ Licenza

Questo progetto Γ¨ rilasciato sotto licenza MIT License - vedi il file LICENSE per dettagli.


πŸ™ Ringraziamenti

Un grazie speciale a:


Made with ❀️ by Pasquale Delli Bergoli

GitHub LinkedIn

⭐ Se ti piace questo progetto, lascia una star!

About

Test automation with AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published