This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Test Automation Framework Generator for creating comprehensive website testing frameworks. The generator creates Python-based test frameworks using pytest and Playwright with support for:
- Basic smoke tests
- Accessibility testing (WCAG compliance)
- Performance testing (Lighthouse/Core Web Vitals)
- Broken link validation
- SEO testing
# Interactive mode with user prompts
python main.py
# Demo with sample configurations
python demo.py
# Test the refactored generator
python test_refactored_generator.py
# Legacy test (for old monolithic version)
python test_generator.py# Run Python linting (if available)
python -m pylint src/framework_generator/
# Run type checking (if mypy is installed)
python -m mypy src/framework_generator/
# Run the test script to verify generator works
python test_refactored_generator.pyOnce a framework is generated, typical commands for the generated project:
cd <generated_project_name>
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txt
playwright install
pytest # Run all tests
pytest -m smoke # Run smoke tests onlyRefactored Modular Structure:
-
main.py- New main entry point for interactive CLI -
src/framework_generator/- Core generator packageframework_generator.py- Main orchestrator classconfig/models.py- Configuration data classes with validationcli/interface.py- CLI interaction and user inputgenerators/- Specialized generators for different componentstemplates/- Template content for generated files
-
test_refactored_generator.py- Test script for new modular structure -
demo.py- Demo script showing basic and full framework generation
Legacy Files:
generator.py- Original monolithic implementation (kept for reference)test_generator.py- Test script for legacy generator
The generator creates projects with this structure:
<project_name>/
├── tests/ # Test files by type
│ ├── test_basic.py # Always generated
│ ├── accessibility/ # Optional
│ ├── lighthouse/ # Optional
│ ├── broken_links/ # Optional
│ └── seo/ # Optional
├── pages/ # Page Object Model
│ ├── base_page.py # Base page class
│ └── home_page.py # Sample page object
├── utils/ # Test utilities
├── config/ # Configuration files
├── .github/workflows/ # Optional CI/CD
├── conftest.py # Pytest configuration
├── pytest.ini # Pytest settings
├── requirements.txt # Dependencies
└── README.md # Comprehensive documentation
- Page Object Model: Separates page interactions from test logic
- Template Generation: Uses f-strings and multiline templates for code generation
- Modular Test Types: Each test type (accessibility, performance, etc.) in separate modules
- Configuration-Driven: User choices determine which components are generated
-
✅ Modular Architecture:
- Separated concerns into focused modules
config/for configuration management and validationcli/for user interactiongenerators/for specialized generation logictemplates/for template content
-
✅ Configuration Validation:
GeneratorConfigdataclass with validation- Type hints and proper error handling
- Serialization/deserialization support
-
✅ Improved Testing:
test_refactored_generator.pytests both functionality and validation- Demo script for showcasing capabilities
- Better test coverage of the generation process
-
✅ Fixed Unicode Issues:
- Proper UTF-8 encoding for all file operations
- Cross-platform compatibility
- Unit Tests: Individual unit tests for each generator class
- Enhanced Features:
- Support for different test frameworks (not just pytest)
- Multiple browser configuration options
- Custom test template support
- Configuration file input (JSON/YAML)
- Template Extraction: Some templates still embedded in generator code
- Documentation Generator: Extract README/docs generation to separate module
- Follow PEP 8 Python style guidelines
- Use type hints where possible
- Add docstrings to all public methods
- Keep functions focused and small
- Use consistent indentation in generated code
- Include comprehensive docstrings in generated files
- Ensure generated code follows best practices
- Test generated code actually works
- Validate user inputs before processing
- Provide clear error messages
- Handle file system errors gracefully
- Test edge cases (empty inputs, invalid URLs, etc.)
test_generator.pyprovides basic end-to-end testing- Verifies all expected files are generated
- Checks basic content validation
- Unit tests for individual generator methods
- Template validation tests
- Configuration validation tests
- Integration tests with actual generated frameworks
- Cross-platform testing (Windows/Mac/Linux)
- Python 3.8+: Core language
- pathlib: File system operations
- json: Configuration handling (future)
- pytest: Test framework
- playwright: Browser automation
- pytest-playwright: Playwright pytest integration
- axe-playwright: Accessibility testing (optional)
- requests: HTTP requests for link validation
- beautifulsoup4: HTML parsing
- Web UI: Add optional web interface for generator
- Plugin System: Allow custom test type plugins
- Template Customization: User-provided templates
- CI/CD Templates: Support for other CI systems (GitLab, Jenkins, etc.)
- Advanced Configuration: YAML/JSON config file support
- Framework Variants: Support for other languages/frameworks
When working on this codebase:
- Refactoring Priority: The monolithic
generator.pyneeds to be broken into smaller, focused modules - Test Coverage: Add unit tests before making significant changes
- Generated Code Quality: Ensure generated frameworks follow best practices
- Documentation: Update this file when making architectural changes
- Backwards Compatibility: Maintain compatibility with existing generated frameworks