layoutlens 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- layoutlens-1.0.0/.github/workflows/release.yml +114 -0
- layoutlens-1.0.0/.github/workflows/test.yml +125 -0
- layoutlens-1.0.0/CHANGELOG.md +105 -0
- layoutlens-1.0.0/CLAUDE.md +164 -0
- layoutlens-1.0.0/LICENSE +21 -0
- layoutlens-1.0.0/MANIFEST.in +41 -0
- layoutlens-1.0.0/Makefile +184 -0
- layoutlens-1.0.0/PKG-INFO +347 -0
- layoutlens-1.0.0/README.md +289 -0
- layoutlens-1.0.0/docs/README.md +67 -0
- layoutlens-1.0.0/docs/api/cli.md +773 -0
- layoutlens-1.0.0/docs/api/config.md +784 -0
- layoutlens-1.0.0/docs/api/core.md +576 -0
- layoutlens-1.0.0/docs/api/test-runner.md +678 -0
- layoutlens-1.0.0/docs/developer-guide/architecture.md +293 -0
- layoutlens-1.0.0/docs/developer-guide/development.md +753 -0
- layoutlens-1.0.0/docs/testing.md +446 -0
- layoutlens-1.0.0/docs/user-guide/cli-reference.md +566 -0
- layoutlens-1.0.0/docs/user-guide/configuration.md +595 -0
- layoutlens-1.0.0/docs/user-guide/examples.md +726 -0
- layoutlens-1.0.0/docs/user-guide/faq.md +547 -0
- layoutlens-1.0.0/docs/user-guide/installation.md +376 -0
- layoutlens-1.0.0/docs/user-guide/quickstart.md +148 -0
- layoutlens-1.0.0/examples/advanced_usage.py +385 -0
- layoutlens-1.0.0/examples/basic_usage.py +142 -0
- layoutlens-1.0.0/examples/ci_cd_integration.py +254 -0
- layoutlens-1.0.0/examples/layoutlens_config.yaml +145 -0
- layoutlens-1.0.0/examples/sample_test_suite.yaml +90 -0
- layoutlens-1.0.0/layoutlens/__init__.py +13 -0
- layoutlens-1.0.0/layoutlens/cli.py +311 -0
- layoutlens-1.0.0/layoutlens/config.py +400 -0
- layoutlens-1.0.0/layoutlens/core.py +570 -0
- layoutlens-1.0.0/layoutlens/test_runner.py +658 -0
- layoutlens-1.0.0/layoutlens.egg-info/PKG-INFO +347 -0
- layoutlens-1.0.0/layoutlens.egg-info/SOURCES.txt +74 -0
- layoutlens-1.0.0/layoutlens.egg-info/dependency_links.txt +1 -0
- layoutlens-1.0.0/layoutlens.egg-info/entry_points.txt +2 -0
- layoutlens-1.0.0/layoutlens.egg-info/requires.txt +27 -0
- layoutlens-1.0.0/layoutlens.egg-info/top_level.txt +2 -0
- layoutlens-1.0.0/pyproject.toml +202 -0
- layoutlens-1.0.0/pytest.ini +26 -0
- layoutlens-1.0.0/requirements-test.txt +46 -0
- layoutlens-1.0.0/scripts/__init__.py +3 -0
- layoutlens-1.0.0/scripts/benchmark/__init__.py +6 -0
- layoutlens-1.0.0/scripts/benchmark/benchmark_generator.py +414 -0
- layoutlens-1.0.0/scripts/benchmark/template_engine.py +891 -0
- layoutlens-1.0.0/scripts/testing/__init__.py +13 -0
- layoutlens-1.0.0/scripts/testing/ground_truth_evaluator.py +567 -0
- layoutlens-1.0.0/scripts/testing/page_tester.py +593 -0
- layoutlens-1.0.0/scripts/testing/query_generator.py +604 -0
- layoutlens-1.0.0/scripts/testing/screenshot_manager.py +534 -0
- layoutlens-1.0.0/setup.cfg +4 -0
- layoutlens-1.0.0/setup.py +71 -0
- layoutlens-1.0.0/tests/__init__.py +1 -0
- layoutlens-1.0.0/tests/conftest.py +218 -0
- layoutlens-1.0.0/tests/fixtures/expected_outputs/simple_page_queries.json +62 -0
- layoutlens-1.0.0/tests/fixtures/mock_responses/openai_responses.json +109 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/bold_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/center_box.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/color_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/columns_layout.html +18 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/columns_layout_shifted.html +18 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/italic_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/justified_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/left_aligned_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/left_box.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/right_aligned_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/right_box.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/legacy_samples/underlined_text.html +14 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/responsive_page.html +364 -0
- layoutlens-1.0.0/tests/fixtures/sample_pages/simple_page.html +104 -0
- layoutlens-1.0.0/tests/integration/test_page_testing.py +431 -0
- layoutlens-1.0.0/tests/unit/test_config.py +329 -0
- layoutlens-1.0.0/tests/unit/test_core.py +380 -0
- layoutlens-1.0.0/tests/unit/test_query_generator.py +431 -0
- layoutlens-1.0.0/tox.ini +55 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v4
|
|
16
|
+
with:
|
|
17
|
+
python-version: '3.10'
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
python -m pip install --upgrade pip
|
|
22
|
+
pip install -e .
|
|
23
|
+
pip install pytest pytest-cov playwright beautifulsoup4 pyyaml
|
|
24
|
+
playwright install chromium
|
|
25
|
+
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: |
|
|
28
|
+
pytest tests/ -v --cov=layoutlens --cov-report=term-missing
|
|
29
|
+
env:
|
|
30
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_TEST }}
|
|
31
|
+
|
|
32
|
+
build:
|
|
33
|
+
needs: test
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Set up Python
|
|
39
|
+
uses: actions/setup-python@v4
|
|
40
|
+
with:
|
|
41
|
+
python-version: '3.10'
|
|
42
|
+
|
|
43
|
+
- name: Install build dependencies
|
|
44
|
+
run: |
|
|
45
|
+
python -m pip install --upgrade pip build twine
|
|
46
|
+
|
|
47
|
+
- name: Build package
|
|
48
|
+
run: |
|
|
49
|
+
python -m build
|
|
50
|
+
|
|
51
|
+
- name: Check package
|
|
52
|
+
run: |
|
|
53
|
+
twine check dist/*
|
|
54
|
+
|
|
55
|
+
- name: Upload artifacts
|
|
56
|
+
uses: actions/upload-artifact@v3
|
|
57
|
+
with:
|
|
58
|
+
name: dist
|
|
59
|
+
path: dist/
|
|
60
|
+
|
|
61
|
+
publish:
|
|
62
|
+
needs: build
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
65
|
+
environment:
|
|
66
|
+
name: pypi
|
|
67
|
+
url: https://pypi.org/project/layoutlens/
|
|
68
|
+
permissions:
|
|
69
|
+
id-token: write
|
|
70
|
+
steps:
|
|
71
|
+
- name: Download artifacts
|
|
72
|
+
uses: actions/download-artifact@v3
|
|
73
|
+
with:
|
|
74
|
+
name: dist
|
|
75
|
+
path: dist/
|
|
76
|
+
|
|
77
|
+
- name: Publish to PyPI
|
|
78
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
79
|
+
|
|
80
|
+
create-release:
|
|
81
|
+
needs: publish
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/checkout@v4
|
|
85
|
+
|
|
86
|
+
- name: Create Release
|
|
87
|
+
uses: actions/create-release@v1
|
|
88
|
+
env:
|
|
89
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
90
|
+
with:
|
|
91
|
+
tag_name: ${{ github.ref_name }}
|
|
92
|
+
release_name: Release ${{ github.ref_name }}
|
|
93
|
+
body: |
|
|
94
|
+
## Changes in this Release
|
|
95
|
+
|
|
96
|
+
This release includes updates to the LayoutLens AI-enabled UI testing framework.
|
|
97
|
+
|
|
98
|
+
### Installation
|
|
99
|
+
```bash
|
|
100
|
+
pip install layoutlens==${{ github.ref_name }}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Quick Start
|
|
104
|
+
```python
|
|
105
|
+
from layoutlens import LayoutLens
|
|
106
|
+
|
|
107
|
+
tester = LayoutLens()
|
|
108
|
+
result = tester.test_page("page.html", queries=["Is the layout responsive?"])
|
|
109
|
+
print(f"Success rate: {result.success_rate:.2%}")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
See the [documentation](https://github.com/layoutlens/layoutlens) for more details.
|
|
113
|
+
draft: false
|
|
114
|
+
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
name: Test Suite
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ['3.10', '3.11', '3.12']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v4
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Cache pip dependencies
|
|
25
|
+
uses: actions/cache@v3
|
|
26
|
+
with:
|
|
27
|
+
path: ~/.cache/pip
|
|
28
|
+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', '**/setup.py') }}
|
|
29
|
+
restore-keys: |
|
|
30
|
+
${{ runner.os }}-pip-
|
|
31
|
+
|
|
32
|
+
- name: Install system dependencies
|
|
33
|
+
run: |
|
|
34
|
+
sudo apt-get update
|
|
35
|
+
sudo apt-get install -y xvfb
|
|
36
|
+
|
|
37
|
+
- name: Install Python dependencies
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
pip install -e .
|
|
41
|
+
pip install pytest pytest-cov pytest-mock pytest-xdist
|
|
42
|
+
pip install playwright beautifulsoup4 pyyaml
|
|
43
|
+
|
|
44
|
+
- name: Install Playwright browsers
|
|
45
|
+
run: |
|
|
46
|
+
playwright install chromium
|
|
47
|
+
|
|
48
|
+
- name: Run unit tests
|
|
49
|
+
run: |
|
|
50
|
+
xvfb-run -a pytest tests/unit/ -v --cov=layoutlens --cov=framework --cov=screenshot --cov=scripts --cov-report=xml --cov-report=term-missing
|
|
51
|
+
env:
|
|
52
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_TEST }}
|
|
53
|
+
|
|
54
|
+
- name: Run integration tests
|
|
55
|
+
run: |
|
|
56
|
+
xvfb-run -a pytest tests/integration/ -v -m "not slow" --maxfail=5
|
|
57
|
+
env:
|
|
58
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_TEST }}
|
|
59
|
+
|
|
60
|
+
- name: Upload coverage reports to Codecov
|
|
61
|
+
uses: codecov/codecov-action@v3
|
|
62
|
+
with:
|
|
63
|
+
file: ./coverage.xml
|
|
64
|
+
fail_ci_if_error: false
|
|
65
|
+
|
|
66
|
+
test-package:
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v4
|
|
70
|
+
|
|
71
|
+
- name: Set up Python
|
|
72
|
+
uses: actions/setup-python@v4
|
|
73
|
+
with:
|
|
74
|
+
python-version: '3.10'
|
|
75
|
+
|
|
76
|
+
- name: Test package installation
|
|
77
|
+
run: |
|
|
78
|
+
python -m pip install --upgrade pip build twine
|
|
79
|
+
python -m build
|
|
80
|
+
pip install dist/*.whl
|
|
81
|
+
python -c "import layoutlens; print('Package installed successfully')"
|
|
82
|
+
|
|
83
|
+
- name: Test CLI
|
|
84
|
+
run: |
|
|
85
|
+
layoutlens --help
|
|
86
|
+
layoutlens generate config --output test_config.yaml
|
|
87
|
+
layoutlens validate --config test_config.yaml
|
|
88
|
+
|
|
89
|
+
test-examples:
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
if: github.event_name == 'pull_request'
|
|
92
|
+
steps:
|
|
93
|
+
- uses: actions/checkout@v4
|
|
94
|
+
|
|
95
|
+
- name: Set up Python
|
|
96
|
+
uses: actions/setup-python@v4
|
|
97
|
+
with:
|
|
98
|
+
python-version: '3.10'
|
|
99
|
+
|
|
100
|
+
- name: Install dependencies
|
|
101
|
+
run: |
|
|
102
|
+
python -m pip install --upgrade pip
|
|
103
|
+
pip install -e .
|
|
104
|
+
pip install playwright beautifulsoup4 pyyaml
|
|
105
|
+
playwright install chromium
|
|
106
|
+
|
|
107
|
+
- name: Test example configurations
|
|
108
|
+
run: |
|
|
109
|
+
python -c "
|
|
110
|
+
import yaml
|
|
111
|
+
with open('examples/layoutlens_config.yaml', 'r') as f:
|
|
112
|
+
config = yaml.safe_load(f)
|
|
113
|
+
print('Config validation: OK')
|
|
114
|
+
|
|
115
|
+
with open('examples/sample_test_suite.yaml', 'r') as f:
|
|
116
|
+
suite = yaml.safe_load(f)
|
|
117
|
+
print('Test suite validation: OK')
|
|
118
|
+
"
|
|
119
|
+
|
|
120
|
+
- name: Validate example code syntax
|
|
121
|
+
run: |
|
|
122
|
+
python -m py_compile examples/basic_usage.py
|
|
123
|
+
python -m py_compile examples/advanced_usage.py
|
|
124
|
+
python -m py_compile examples/ci_cd_integration.py
|
|
125
|
+
echo "All example files compile successfully"
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the LayoutLens project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Enhanced LayoutLens framework with modern Python API
|
|
12
|
+
- CLI interface with comprehensive commands (`layoutlens`)
|
|
13
|
+
- Multi-viewport screenshot testing across desktop, tablet, and mobile
|
|
14
|
+
- Intelligent test query generation from HTML DOM analysis
|
|
15
|
+
- Comprehensive test suite orchestration with YAML configuration
|
|
16
|
+
- Benchmark generation system with systematic HTML templates
|
|
17
|
+
- Advanced screenshot management with context managers
|
|
18
|
+
- Configuration management with hierarchical settings (files, env vars, params)
|
|
19
|
+
- Package distribution setup with proper entry points
|
|
20
|
+
- Comprehensive testing framework with mocked dependencies
|
|
21
|
+
- CI/CD pipelines for automated testing and release
|
|
22
|
+
- Complete documentation structure with user guides and API references
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- **BREAKING**: Reorganized project structure with clear separation
|
|
26
|
+
- Moved original components to `legacy/` directory
|
|
27
|
+
- Moved benchmark data to `benchmarks/` directory
|
|
28
|
+
- Moved HTML samples to `tests/fixtures/sample_pages/legacy_samples/`
|
|
29
|
+
- Enhanced framework now in `layoutlens/` package
|
|
30
|
+
- Testing engine in `scripts/testing/`
|
|
31
|
+
- Benchmark tools in `scripts/benchmark/`
|
|
32
|
+
- Updated all import paths and references to new structure
|
|
33
|
+
- Enhanced error handling with graceful degradation
|
|
34
|
+
- Improved API design with backward compatibility maintained
|
|
35
|
+
|
|
36
|
+
### Enhanced
|
|
37
|
+
- Original `LayoutLens.ask()` and `compare_layouts()` methods preserved for compatibility
|
|
38
|
+
- Extended API with new methods:
|
|
39
|
+
- `test_page()` - Comprehensive page testing with auto-generated queries
|
|
40
|
+
- `compare_pages()` - Visual comparison with structured results
|
|
41
|
+
- `run_test_suite()` - Execute organized test suites
|
|
42
|
+
- `generate_benchmark_data()` - Create systematic test datasets
|
|
43
|
+
|
|
44
|
+
### Infrastructure
|
|
45
|
+
- GitHub Actions workflows for testing across Python 3.8-3.12
|
|
46
|
+
- Automated package building and PyPI publishing
|
|
47
|
+
- Code coverage reporting with Codecov integration
|
|
48
|
+
- Example validation in CI/CD pipeline
|
|
49
|
+
- Comprehensive test fixtures and mock strategies
|
|
50
|
+
|
|
51
|
+
## [0.1.0] - Initial Release
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
- Basic LayoutLens framework for AI-powered UI testing
|
|
55
|
+
- Screenshot capture using Playwright
|
|
56
|
+
- OpenAI vision model integration for natural language queries
|
|
57
|
+
- CSV-based benchmark system
|
|
58
|
+
- HTML test samples for various UI patterns
|
|
59
|
+
- Simple benchmark runner for automated testing
|
|
60
|
+
|
|
61
|
+
### Core Features
|
|
62
|
+
- `framework.py` - Original LayoutLens class
|
|
63
|
+
- `screenshot.py` - HTML to image conversion
|
|
64
|
+
- `benchmark_runner.py` - CSV-driven test execution
|
|
65
|
+
- Support for single image tests and pairwise comparisons
|
|
66
|
+
- Natural language query interface for UI validation
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Migration Guide
|
|
71
|
+
|
|
72
|
+
### From v0.1.0 to v1.0.0
|
|
73
|
+
|
|
74
|
+
**File Locations:**
|
|
75
|
+
- `framework.py` → `legacy/framework.py`
|
|
76
|
+
- `screenshot.py` → `legacy/screenshot.py`
|
|
77
|
+
- `benchmark_runner.py` → `legacy/benchmark_runner.py`
|
|
78
|
+
- `benchmark.csv` → `benchmarks/benchmark.csv`
|
|
79
|
+
- `html/` samples → `tests/fixtures/sample_pages/legacy_samples/`
|
|
80
|
+
|
|
81
|
+
**Usage Changes:**
|
|
82
|
+
```python
|
|
83
|
+
# Old usage (still supported)
|
|
84
|
+
from legacy.framework import LayoutLens
|
|
85
|
+
lens = LayoutLens(api_key="key")
|
|
86
|
+
result = lens.ask(["image.png"], "Question?")
|
|
87
|
+
|
|
88
|
+
# New recommended usage
|
|
89
|
+
from layoutlens import LayoutLens
|
|
90
|
+
tester = LayoutLens(api_key="key")
|
|
91
|
+
result = tester.test_page("page.html", queries=["Question?"])
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Command Line:**
|
|
95
|
+
```bash
|
|
96
|
+
# Old
|
|
97
|
+
python benchmark_runner.py
|
|
98
|
+
|
|
99
|
+
# New
|
|
100
|
+
python legacy/benchmark_runner.py
|
|
101
|
+
# Or use enhanced CLI
|
|
102
|
+
layoutlens test --page page.html
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
All legacy interfaces remain functional for backward compatibility.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# CLAUDE.md - LayoutLens v1.0.0
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with the LayoutLens codebase.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
LayoutLens is a production-ready AI-powered UI testing framework that enables natural language visual testing. It captures screenshots using Playwright and analyzes them with OpenAI's GPT-4o Vision API to validate layouts, accessibility, responsive design, and visual consistency.
|
|
8
|
+
|
|
9
|
+
**Key Achievement:** 95.2% accuracy on professional ground truth benchmark suite.
|
|
10
|
+
|
|
11
|
+
## Quick Start Commands
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
```bash
|
|
15
|
+
pip install -e .
|
|
16
|
+
playwright install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
```bash
|
|
21
|
+
# Set API key
|
|
22
|
+
export OPENAI_API_KEY="your_key_here"
|
|
23
|
+
|
|
24
|
+
# Test a single page
|
|
25
|
+
python -c "
|
|
26
|
+
from layoutlens import LayoutLens
|
|
27
|
+
tester = LayoutLens()
|
|
28
|
+
result = tester.test_page('benchmarks/ecommerce_product.html',
|
|
29
|
+
queries=['Is the navigation properly aligned?'])
|
|
30
|
+
print(f'Success rate: {result.success_rate:.1%}')
|
|
31
|
+
"
|
|
32
|
+
|
|
33
|
+
# Run ground truth benchmark evaluation
|
|
34
|
+
python scripts/testing/ground_truth_evaluator.py --output-report results.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### CLI Usage
|
|
38
|
+
```bash
|
|
39
|
+
layoutlens --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Release v1.0.0 Architecture
|
|
43
|
+
|
|
44
|
+
### Core Package Structure
|
|
45
|
+
- **`layoutlens/core.py`**: Main LayoutLens class with user-friendly API
|
|
46
|
+
- **`layoutlens/config.py`**: Configuration management (YAML + env vars)
|
|
47
|
+
- **`layoutlens/cli.py`**: Command-line interface
|
|
48
|
+
- **`scripts/testing/`**: Testing infrastructure (PageTester, ScreenshotManager, QueryGenerator)
|
|
49
|
+
- **`scripts/benchmark/`**: Benchmark generation tools
|
|
50
|
+
|
|
51
|
+
### Key Features Implemented
|
|
52
|
+
- ✅ **Multi-viewport screenshot capture** (desktop, mobile, tablet)
|
|
53
|
+
- ✅ **OpenAI GPT-4o Vision integration** for visual analysis
|
|
54
|
+
- ✅ **Ground truth benchmark suite** with objective test cases
|
|
55
|
+
- ✅ **Natural language query processing**
|
|
56
|
+
- ✅ **Configuration system** with YAML and environment variables
|
|
57
|
+
- ✅ **CLI interface** for automation and CI/CD
|
|
58
|
+
- ✅ **Professional documentation** and examples
|
|
59
|
+
|
|
60
|
+
## Ground Truth Benchmark Suite
|
|
61
|
+
|
|
62
|
+
The package includes a comprehensive benchmark with objectively measurable test cases:
|
|
63
|
+
|
|
64
|
+
### Test Categories (95.2% Overall Accuracy)
|
|
65
|
+
- **Layout Alignment Issues**: 100.0% accuracy (6/6 tests)
|
|
66
|
+
- Navigation centering (2% offset detection)
|
|
67
|
+
- Logo positioning (wrong side detection)
|
|
68
|
+
- Button alignment (margin inconsistencies)
|
|
69
|
+
|
|
70
|
+
- **Responsive Design Problems**: 100.0% accuracy (4/4 tests)
|
|
71
|
+
- Mobile viewport overflow
|
|
72
|
+
- Touch target sizing (below 44px minimum)
|
|
73
|
+
- Text readability (below 14px mobile standard)
|
|
74
|
+
|
|
75
|
+
- **Accessibility (WCAG) Violations**: 100.0% accuracy (6/6 tests)
|
|
76
|
+
- Missing alt text
|
|
77
|
+
- Form label associations
|
|
78
|
+
- Keyboard navigation
|
|
79
|
+
- Heading hierarchy
|
|
80
|
+
- Table structure
|
|
81
|
+
- Color-only information
|
|
82
|
+
|
|
83
|
+
- **Color Contrast Violations**: 80.0% accuracy (4/5 tests)
|
|
84
|
+
- WCAG AA compliance (4.5:1 ratio requirements)
|
|
85
|
+
- Calculated contrast ratios (1.07:1, 1.61:1, 1.92:1, etc.)
|
|
86
|
+
|
|
87
|
+
### Benchmark Files Location
|
|
88
|
+
- **`benchmarks/ground_truth_tests/`**: Test cases with embedded ground truth metadata
|
|
89
|
+
- **`benchmarks/ground_truth_tests/GROUND_TRUTH_ANSWERS.md`**: Expected answers documentation
|
|
90
|
+
|
|
91
|
+
## Testing and Development
|
|
92
|
+
|
|
93
|
+
### Running Tests
|
|
94
|
+
```bash
|
|
95
|
+
# Install test dependencies
|
|
96
|
+
pip install pytest
|
|
97
|
+
|
|
98
|
+
# Run core functionality tests
|
|
99
|
+
pytest tests/unit/test_config.py tests/unit/test_core.py -v
|
|
100
|
+
|
|
101
|
+
# Run ground truth evaluation
|
|
102
|
+
python scripts/testing/ground_truth_evaluator.py
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Example Test Cases
|
|
106
|
+
```python
|
|
107
|
+
from layoutlens import LayoutLens
|
|
108
|
+
|
|
109
|
+
# Initialize with API key
|
|
110
|
+
tester = LayoutLens(api_key="your_key")
|
|
111
|
+
|
|
112
|
+
# Test single page
|
|
113
|
+
result = tester.test_page("page.html", queries=[
|
|
114
|
+
"Is the navigation menu properly aligned?",
|
|
115
|
+
"Are the button sizes appropriate for mobile?"
|
|
116
|
+
])
|
|
117
|
+
|
|
118
|
+
# Compare two pages
|
|
119
|
+
comparison = tester.compare_pages("before.html", "after.html")
|
|
120
|
+
print(comparison['answer'])
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Package Structure (Post-Cleanup)
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
layoutlens/
|
|
127
|
+
├── layoutlens/ # Core package
|
|
128
|
+
│ ├── core.py # Main LayoutLens class
|
|
129
|
+
│ ├── config.py # Configuration system
|
|
130
|
+
│ └── cli.py # Command line interface
|
|
131
|
+
├── scripts/ # Testing utilities
|
|
132
|
+
│ ├── testing/ # Page testing infrastructure
|
|
133
|
+
│ └── benchmark/ # Benchmark generation
|
|
134
|
+
├── benchmarks/ # HTML test files + ground truth
|
|
135
|
+
├── docs/ # Documentation
|
|
136
|
+
├── examples/ # Usage examples
|
|
137
|
+
└── tests/ # Test suite
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Performance Characteristics
|
|
141
|
+
|
|
142
|
+
- **Processing Time**: ~23 seconds average per test
|
|
143
|
+
- **Accuracy**: 95.2% on objective ground truth benchmark
|
|
144
|
+
- **Package Size**: ~50MB (cleaned from 300MB+ development version)
|
|
145
|
+
- **Dependencies**: OpenAI, Playwright, BeautifulSoup4, PyYAML, Pillow
|
|
146
|
+
- **Python Compatibility**: 3.8+
|
|
147
|
+
|
|
148
|
+
## Development Notes
|
|
149
|
+
|
|
150
|
+
### What Was Removed for v1.0.0 Release
|
|
151
|
+
- ❌ Legacy framework files (moved to clean v1.0 API)
|
|
152
|
+
- ❌ Development virtual environments (~200MB)
|
|
153
|
+
- ❌ Test output files and screenshots (~50MB)
|
|
154
|
+
- ❌ Build artifacts and caches (~5MB)
|
|
155
|
+
- ❌ Development-specific .md files
|
|
156
|
+
|
|
157
|
+
### What Was Fixed
|
|
158
|
+
- ✅ OpenAI Vision API integration in PageTester
|
|
159
|
+
- ✅ Screenshot capture using Playwright
|
|
160
|
+
- ✅ Ground truth evaluation system
|
|
161
|
+
- ✅ Package dependencies and structure
|
|
162
|
+
- ✅ Configuration and CLI systems
|
|
163
|
+
|
|
164
|
+
This codebase is release-ready with professional-grade accuracy measurement and comprehensive documentation.
|
layoutlens-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Gaurav Sood
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Include important documentation files
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include CLAUDE.md
|
|
5
|
+
include CHANGELOG.md
|
|
6
|
+
|
|
7
|
+
# Include configuration files
|
|
8
|
+
include *.toml
|
|
9
|
+
include *.ini
|
|
10
|
+
include *.cfg
|
|
11
|
+
include requirements*.txt
|
|
12
|
+
include Makefile
|
|
13
|
+
|
|
14
|
+
# Include test files and fixtures
|
|
15
|
+
recursive-include tests *.py
|
|
16
|
+
recursive-include tests/fixtures *.html *.json *.yaml *.yml
|
|
17
|
+
|
|
18
|
+
# Include example files
|
|
19
|
+
recursive-include examples *.py *.yaml *.yml *.html *.md
|
|
20
|
+
|
|
21
|
+
# Include documentation
|
|
22
|
+
recursive-include docs *.md *.rst *.txt
|
|
23
|
+
|
|
24
|
+
# Include template files
|
|
25
|
+
recursive-include scripts/benchmark/templates *.html *.css *.js
|
|
26
|
+
|
|
27
|
+
# Include GitHub workflows
|
|
28
|
+
recursive-include .github/workflows *.yml *.yaml
|
|
29
|
+
|
|
30
|
+
# Exclude unnecessary files
|
|
31
|
+
global-exclude *.pyc
|
|
32
|
+
global-exclude *.pyo
|
|
33
|
+
global-exclude *.pyd
|
|
34
|
+
global-exclude __pycache__
|
|
35
|
+
global-exclude .DS_Store
|
|
36
|
+
global-exclude .coverage
|
|
37
|
+
global-exclude htmlcov
|
|
38
|
+
global-exclude .pytest_cache
|
|
39
|
+
global-exclude *.egg-info
|
|
40
|
+
global-exclude build
|
|
41
|
+
global-exclude dist
|