Proof of concept for automated visual testing using local vision models with Ollama.
- Python 3.8+
- Ollama installed and running
- Vision model qwen2.5vl:7b downloaded
- Docker (optional, for containerized execution)
- Install Ollama:
curl -fsSL https://ollama.ai/install.sh | sh- Download vision model:
ollama pull qwen2.5vl:7b- Install Python dependencies:
pip install -r requirements.txt
playwright install chromiumsmartVisionQA/
├── smartVisionQA.py # Main script
├── generate_html_report.py # HTML report generator
├── example_url_comparison.py # URL comparison examples
├── demo/ # Example HTML files
│ ├── page_v1.html # Version 1 (original)
│ ├── page_v2.html # Version 2 (major changes)
│ ├── page_v3.html # Version 3 (minor changes)
│ └── simple_test.html # Simple test page
├── results/ # Screenshots and reports (auto-generated)
│ ├── comparison_*.json # JSON reports per comparison
│ ├── visual_report_*.html # Visual HTML reports
│ └── *_screenshot.png # Screenshots
└── requirements.txt # Dependencies
Run all comparisons:
python smartVisionQA.pyThe script automatically executes:
- page_v1.html vs page_v2.html
- page_v1.html vs page_v3.html
- page_v2.html vs page_v3.html
For each comparison:
- Renders HTMLs to images
- Uses Ollama to analyze visual differences
- Generates unique JSON and HTML reports
Build and run with Docker:
docker build -t smartvisionqa .
docker run --rm -v $(pwd)/results:/app/results smartvisionqaThe repository includes a GitHub Actions workflow for automated visual testing.
- Enable GitHub Pages in repository settings
- Set Pages source to "GitHub Actions"
- Ensure Actions have write permissions for Pages
- Go to repository Actions tab
- Select SmartVisionQA Analysis workflow
- Click Run workflow
- Choose whether to publish results to GitHub Pages
- Containerized execution: Runs analysis in isolated Docker environment
- Artifact storage: Results saved for 30 days as downloadable artifacts
- GitHub Pages publishing: Optional web dashboard with visual reports
- Automatic cleanup: Docker resources cleaned after execution
Via Artifacts:
- Go to workflow run page
- Download
visual-qa-resultsartifact - Contains all JSON reports, HTML dashboards, and screenshots
Via GitHub Pages (if enabled):
- Automatic deployment to
https://username.github.io/repository-name - Interactive dashboard with all comparison results
- Direct links to HTML reports and screenshots
Modify in smartVisionQA.py at line 300 - test cases list:
test_cases = [
("your_file1.html", "your_file2.html"),
]Modify in smartVisionQA.py at line 59 - model initialization:
def __init__(self, model: str = "qwen2.5vl:7b"): The system automatically generates visual HTML reports:
python smartVisionQA.py # Generates JSON + HTML automaticallyTo generate HTML report from existing JSON:
python generate_simple_report.py results/comparison_page_v1_vs_page_v2.jsonFor comparing live websites:
python example_url_comparison.pyYou can modify URLs in the example_url_comparison.py file.
The workflow provides CI/CD integration:
- Triggered manually or via API
- Results available as artifacts
- Optional web publishing
- No external dependencies required
To integrate with Selenium/Playwright for live websites:
In HTMLRenderer class (line 18), add method:
async def url_to_image(self, url: str) -> bytes:
# Implement real URL capture
pass- Requires ~6GB for qwen2.5vl:7b model
- First execution downloads model (~6GB)
- Screenshots saved in
results/directory - Docker execution recommended for consistent environments