Python Selenium regression tests for Google.com search, using pytest and the Page Object Model.
TestingGoogle/
├── config/
│ ├── __init__.py
│ ├── settings.py # BASE_URL, timeouts, logging
│ └── logging_config.py # Logging setup
├── pages/
│ ├── __init__.py
│ └── google_search_page.py # Page Object for Google search
├── tests/
│ ├── __init__.py
│ └── test_google_search.py # Regression tests
├── conftest.py # Pytest fixtures (driver)
├── requirements.txt
└── README.md
-
Create a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Install Chrome and ensure ChromeDriver is on your PATH, or use
webdriver-manager(add torequirements.txtand use inconftest.py) for automatic driver management.
From the project root:
pytest tests/ -vHeadless Chrome is used by default. To run with a visible browser, remove or comment out the --headless option in conftest.py.
Tests are instrumented for Allure. To view reports you need the Allure CLI (separate from the Python package).
Install Allure CLI (required once)
- macOS (Homebrew):
brew install allure - Other: See Install Allure CLI
1. Run tests and collect Allure results
pytest tests/ -v --alluredir=allure-results2. View the report
-
Quick (opens in browser):
allure serve allure-results -
Or generate static HTML then open:
allure generate allure-results -o allure-report --clean
Then run:open allure-report/index.html(macOS) or open the file in your browser. -
Helper script:
./scripts/allure-report.sh— generates the report and opens it (checks for Allure CLI).
The report includes steps (from the page object), epic/feature/story, and a screenshot attachment when a test fails.
Logging is configured at session start and writes to:
- Console – same format as file (pytest may capture it; use
pytest -sto see live). - File –
logs/test_run.log(created automatically).
Format: timestamp | level | logger_name | message. Loggers used: conftest, pages.google_search_page, tests.test_google_search.
- Level: set
TEST_LOG_LEVEL(e.g.DEBUG,INFO,WARNING). Default isDEBUG. - Example:
TEST_LOG_LEVEL=INFO pytest tests/ -v -s