To set up all prerequisites and check your environment, simply run:
bash setup.shThis script will:
- Check for Python 3 and pip
- Install all Python dependencies from requirements.txt
- Check for Java (JRE) and attempt to auto-install it if missing
- Check for the Allure commandline and attempt to auto-install it if missing
- Auto-install Homebrew (macOS) or Scoop (Windows) if needed for dependency installation
- Provide clear output and fallback/manual instructions if automation is not possible
- Ensure your environment is ready for running tests and generating reports
We recommend all users run this script before using the project for the first time or after cloning/updating the repository.
This project contains automated tests for the Hudl login functionality using Python, Selenium, and Pytest.
- Page Object Model (POM)
- Valid and invalid login tests
- Pytest fixtures for driver management
- Headless mode by default (faster execution, CI/CD friendly)
- Parallel test execution across browsers
- Automatic rerun of failed tests
- Cross-browser support (Chrome, Firefox, Edge)
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pytest.
├── .gitignore
├── pages/
│ └── login_page.py
├── pytest.ini
├── README.md
├── requirements.txt
├── tests/
│ └── test_login.py
├── utils/
│ ├── config.py
│ └── webdriver_manager.py
This project supports running tests in parallel and across multiple browsers using pytest-xdist and a browser selection fixture.
- chrome
- firefox
- edge
You can configure the list of supported browsers in utils/config.py.
By default, tests run in headless mode (no browser window visible). This is ideal for:
- CI/CD pipelines
- Faster test execution
- Running tests in environments without display
- Reduced resource usage
- Consistent behavior across environments
To disable headless mode (show browser window):
HEADLESS=false pytestTo explicitly enable headless mode:
HEADLESS=true pytestHeadless mode with different browsers:
# Chrome in headless mode (default)
pytest --browser=chrome
# Firefox in headless mode (default)
pytest --browser=firefox
# Edge in headless mode (default)
pytest --browser=edge
# Show browser window for debugging
HEADLESS=false pytest --browser=chromeNote:
- Headless mode works with all supported browsers (Chrome, Firefox, Edge)
- For debugging test failures, consider running with
HEADLESS=falseto see the browser interactions
To run tests in parallel (e.g., 4 workers) on a single browser (e.g., Chrome):
pytest -n 4 --browser=chrome-n 4runs 4 tests in parallel.--browser=chromeselects the browser (usefirefoxoredgeas needed).
Run all tests in parallel for each browser, one after another:
for browser in chrome firefox edge; do
pytest -n 4 --browser=$browser
doneTo run each test on all browsers in parallel, parametrize the driver fixture in tests/conftest.py:
import pytest
from utils.config import SUPPORTED_BROWSERS
from utils.webdriver_manager import get_webdriver
@pytest.fixture(params=SUPPORTED_BROWSERS)
def driver(request):
driver = get_webdriver(request.param)
yield driver
driver.quit()Now, simply run:
pytest -n 4Each test will run in parallel on all supported browsers.
This project uses pytest-rerunfailures and a pytest.ini config to automatically rerun failed tests up to 2 times with a 1-second delay:
[pytest]
addopts = --reruns 2 --reruns-delay 1
If you need more advanced parallelization or browser grid support, consider using Selenium Grid or cloud services like BrowserStack or Sauce Labs.
This project supports generating HTML reports for your test runs using pytest-html.
To run tests and generate an HTML report:
pytest --html=report.html --self-contained-html- The report will be saved as
report.htmlin your project directory. - Open
report.htmlin your browser to view the results.
This project uses pdoc3 to generate API documentation from Python docstrings.
To generate HTML documentation for the codebase:
pdoc --html pages utils tests --output-dir docs- The documentation will be generated in the
docs/directory. - Open the generated HTML files in your browser to view the documentation.
- Ensure all classes and methods are well-commented with docstrings for best results.
- You can customize the output directory or modules as needed.
Below is an overview of the project architecture and how the main components interact:
flowchart TD
A["tests/\nTest cases\n(pytest)"] -->|"Uses"| B["pages/\nPage Objects\n(LoginPage)"]
A -->|"Uses"| C["utils/webdriver_manager.py\nWebDriver & Fixtures"]
B -->|"Imports"| D["selenium.webdriver\nSelenium API"]
C -->|"Imports"| D
A -->|"Imports config"| E["utils/config.py\nConfig (URL, Browsers)"]
A -->|"Generates"| F["report.html\nHTML Test Report"]
A -->|"Generates"| G["docs/\nAPI Documentation\n(pdoc3)"]
H -->|"Runs"| A
H -->|"Runs"| F
H -->|"Runs"| G
style H fill:#f9f,stroke:#333,stroke-width:2
style A fill:#bbf,stroke:#333,stroke-width:2
style B fill:#bfb,stroke:#333,stroke-width:2
style C fill:#ffb,stroke:#333,stroke-width:2
style D fill:#fff,stroke:#333,stroke-width:1
style E fill:#fcc,stroke:#333,stroke-width:2
style F fill:#fcf,stroke:#333,stroke-width:2
style G fill:#cff,stroke:#333,stroke-width:2
- tests/: Contains all test cases, which use page objects and utilities.
- pages/: Contains Page Object Model classes (e.g.,
LoginPage) for UI abstraction. - utils/webdriver_manager.py: Provides WebDriver management and pytest fixtures for browser setup.
- utils/config.py: Central configuration for URLs and supported browsers.
- selenium.webdriver: The Selenium API used by both page objects and WebDriver manager.
- report.html: HTML test report generated by pytest-html.
- docs/: Auto-generated API documentation from code comments using pdoc3.
This project supports generating Allure reports for advanced, interactive test reporting.
-
Python Dependencies
- Ensure you have installed all Python dependencies:
pip install -r requirements.txt
- This includes
allure-pytestfor Allure integration with pytest.
- Ensure you have installed all Python dependencies:
-
Allure Commandline Tool
- The Allure commandline tool is required to generate and view reports. It is not a Python package and must be installed separately.
- See platform-specific installation steps below.
-
Java Runtime
- Allure requires Java (JRE) to be installed and available in your system PATH. You can check with:
java -version
- If not installed, download from Adoptium or use your OS package manager.
- Allure requires Java (JRE) to be installed and available in your system PATH. You can check with:
You need the Allure commandline tool to view reports. Install it as follows:
brew install allure- With Scoop:
scoop install allure
- Or download and unzip from the Allure releases page, then add the
binfolder to your PATH.
- Download and unzip from the Allure releases page:
wget https://github.com/allure-framework/allure2/releases/download/2.27.0/allure-2.27.0.tgz tar -zxvf allure-2.27.0.tgz sudo mv allure-2.27.0 /opt/ sudo ln -s /opt/allure-2.27.0/bin/allure /usr/bin/allure
- Or use your package manager if available.
For more details, see the official Allure installation guide.
To run tests and generate Allure result files:
pytest --alluredir=allure-resultsAfter running tests, generate and open the report:
allure serve allure-results- This will start a local server and open the interactive report in your browser.
- The
allure-resultsdirectory will contain the raw results after test execution. - You can also generate static HTML with
allure generate allure-results -o allure-reportand open the HTML files manually. - For more options, see the Allure documentation.
This project uses a .env file to securely store your Hudl credentials. Do not commit your real credentials to version control.
- Copy the provided
.env.examplefile to.env:cp .env.example .env
- Open
.envand fill in your Hudl username and password:HUDL_USERNAME=your_username_here HUDL_PASSWORD=your_password_here
- Your credentials will now be loaded automatically when running tests.
Note: The
.env.examplefile is a template and safe to commit. Never commit your real.envfile.
- Developed and assisted using the Cursor platform for AI-powered coding.
- Project editing and management with IntelliJ IDEA.