This project is a Test-Driven Development (TDD) setup for automating web application testing using Selenium and Python. The tests are written using the pytest framework and follow a modular structure, adhering to the Page Object Model (POM) design pattern.
The project is structured as follows:
Selenium_Python_TDD/
├── Api/ # API interaction modules
├── Pages/ # Page Object Model classes
├── Locators/ # Element locators for pages
├── Tests/ # Test scripts
├── Utils/ # Utility functions and helpers
├── .git/ # Git version control
├── .gitignore # Git ignore file
├── .idea/ # IDE configuration (e.g., PyCharm)
├── .pytest_cache/ # Pytest cache (improves test execution speed)
├── .venv/ # Virtual environment directory
├── .vscode/ # VSCode workspace settings
├── Allogs/ # Logs for debugging
├── allure-results/ # Allure test results
├── Configfile/ # Configuration files for tests
├── conftest.py # Pytest fixtures
├── Excelfile/ # Excel files for test data
├── reports/ # Test execution reports
├── requirements.txt # Project dependencies
├── screenshots/ # Screenshots of test failures
├── pytest.ini # Pytest configuration file
└── __pycache__/ # Python bytecode cache
Ensure the following dependencies are installed:
- Python 3.x
- Selenium
- pytest
- Allure (for test reporting)
You can install the necessary dependencies using the provided requirements.txt file:
pip install -r requirements.txt- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows use .venv\Scripts�ctivatepip install -r requirements.txtUse pytest to execute the tests:
pytest --maxfail=5 --disable-warnings -qAfter test execution, reports are stored in the reports/ and allure-results/ directories. You can generate an Allure report with the following commands:
allure serve allure-results/Contains modules that interact with the application's API (if applicable).
Contains classes representing the pages of the application, following the Page Object Model design pattern.
Contains the locators (CSS selectors, XPaths, etc.) for elements on the pages.
Contains the actual test scripts that implement the test cases using the Page Object Model and locators.
Contains utility functions that assist in the execution of tests (e.g., for logging, data manipulation, etc.).
Contains configuration files needed for the project or the environment setup.
- Logs: Logs for debugging failed tests can be found in the
Allogs/folder. - Screenshots: Screenshots for failed tests are stored in the
screenshots/folder for easy inspection. - Allure Reports: Test execution reports generated by Allure can be found in the
allure-results/folder.
- If you face issues with dependencies, make sure that you are working in a clean virtual environment by reinstalling the dependencies with
pip install -r requirements.txt.
- To change the browser for your Selenium tests, modify the browser setup in the
conftest.pyfile where the browser driver is instantiated.
- If a test fails, check the logs and screenshots in the
Allogs/andscreenshots/directories for debugging information.