This directory contains various test suites for the DOM Parser project.
playground/ - Integration tests for real websites (Google, Amazon, YouTube, etc.)replay_tests/ - Golden value tests for regression testingtest_*.py - Unit tests for individual componentssource venv/bin/activate
export PYTHONPATH=/Users/rachitapradeep/dom-parser:$PYTHONPATH
# Run all unit tests
pytest dom_parser/tests/test_*.py -v
# Run specific unit test
pytest dom_parser/tests/test_idle_watcher.py -v
# Run all playground tests
pytest dom_parser/tests/playground/test_*.py -v
# Run specific integration test
pytest dom_parser/tests/playground/test_page_analyzer_integration_google.py -v
# Run golden value tests
PYTHONPATH=. pytest dom_parser/tests/replay_tests/test_golden_replay.py -v
You can also run tests directly with Python:
# Run specific integration test
python dom_parser/tests/playground/test_page_analyzer_integration_google.py
# Run golden value generation
python dom_parser/tests/replay_tests/golden_values/generate_golden_example_com.py
# Run test and save all output to file
pytest dom_parser/tests/playground/test_page_analyzer_integration_google.py -v -s > /tmp/test_output.txt 2>&1
# Run with more verbose output
pytest dom_parser/tests/playground/test_page_analyzer_integration_google.py -v -s --tb=long > /tmp/detailed_output.txt 2>&1
# Run Python test and save output
python dom_parser/tests/playground/test_page_analyzer_integration_google.py > /tmp/python_test_output.txt 2>&1
# Run with timestamp
python dom_parser/tests/playground/test_page_analyzer_integration_google.py | tee /tmp/test_$(date +%Y%m%d_%H%M%S).txt
# Run with pytest logging
pytest dom_parser/tests/playground/test_page_analyzer_integration_google.py -v -s --log-file=/tmp/pytest.log --log-level=DEBUG
These tests interact with real websites:
test_page_analyzer_integration_google.py - Google search functionalitytest_page_analyzer_integration_amazon.py - Amazon product searchtest_page_analyzer_integration_youtube.py - YouTube navigationtest_page_analyzer_integration_pinterest.py - Pinterest browsingtest_page_analyzer_integration_airbnb.py - Airbnb searchtest_page_analyzer_integration_google_flights.py - Google Flights searchtest_page_analyzer_integration_google_forms.py - Google Forms interactiontest_page_analyzer_integration_new_balance.py - New Balance websitetest_page_analyzer_integration_ny_times.py - New York Times websitetest_page_analyzer_integration_screenshot.py - Screenshot functionalityThese tests compare against golden values:
test_golden_replay.py - Compares parsed output against saved golden filesgenerate_golden_example_com.py - Generates new golden files for comparisonThese test individual components:
test_action_executor.py - Action execution functionalitytest_action_executor_config.py - Action executor configurationtest_dom_parser_args.py - DOM parser argument handlingtest_forms.py - Form detection and handlingtest_idle_watcher.py - Page idle detectiontest_integration.py - Basic integration teststest_parser.py - Core parsing functionality# Verbose output
-v
# Show print statements
-s
# Show local variables in tracebacks
-l
# Stop on first failure
-x
# Run tests in parallel (requires pytest-xdist)
-n auto
# Generate coverage report
--cov=dom_parser
# Show slowest tests
--durations=10
# Set debug environment variable
export DEBUG=pw:api
# Run test with debug output
pytest dom_parser/tests/playground/test_page_analyzer_integration_google.py -v -s
Integration tests save screenshots to /tmp/:
# List screenshots
ls -la /tmp/*.png
# Open latest screenshot
open /tmp/01_after_navigation.png
# View test output
cat /tmp/test_output.txt
# Search for errors
grep -i error /tmp/test_output.txt
# Search for warnings
grep -i warning /tmp/test_output.txt
/tmp/ directory# Clear temporary files
rm -f /tmp/*.png /tmp/test_*.txt
# Clear pytest cache
pytest --cache-clear
When adding new tests:
test_*.py