This framework is designed for automating UI tests using Selenium WebDriver with Pytest. It supports multiple browsers (Chrome, Firefox, and Edge) and is structured to provide clean, maintainable, and scalable code, following the Page Object Model (POM) pattern.
- Multi-browser support (Chrome, Firefox, Edge).
- Configurable browser options and implicit/explicit waits.
- Integrated logging for debugging.
- Allure reporting for test results.
- Clean code following best practices (POM, utility classes, logger).
- Easy extension to add new pages and tests.
-
Clone the repository:
git clone git@github.com:dgamboa1605/wap-testing.git cd wap-testing
-
Install the required dependencies: Make sure you have Python installed. Then, use pip to install the necessary packages:
pip install -r requirements.txt
-
Allure Report Setup: Install Allure to generate and visualize test reports:
wap-testing
│
├── config/
│ └── config.py # Configuration settings (e.g., browser, URL, waits, logging)
│
├── drivers/
│ ├── browser_factory.py # Browser factory for handling multiple browsers
│ ├── chrome_browser.py # Chrome browser setup
│ ├── firefox_browser.py # Firefox browser setup
│ └── edge_browser.py # Edge browser setup
│
├── pages/
│ ├── base_page.py # Base class for common page actions
│ ├── home_page.py # Page object for the Home Page
│ ├── search_page.py # Page object for the Search Page
│ └── streamer_page.py # Page object for the Streamer Page
│
├── tests/
│ ├── conftest.py # Pytest fixtures
│ └── test_search_page.py # Test cases for search functionality
│
├── utilities/
│ ├── logger.py # Logger utility
│ └── utils.py # Utility functions
│
├── logs/ # Directory to store logs
├── reports/ # Directory for Allure reports
├── pytest.ini # Pytest configuration file
└── requirements.txt # Required Python packages
-
Basic Test Execution: To execute all tests, run the following command:
pytest
-
Running Tests with Allure Reporting: Run the tests and generate Allure reports:
pytest --alluredir=reports
After the test run, serve the report using:
allure serve reports
-
Running Tests in Parallel: Execute tests across multiple cores to reduce execution time:
pytest -n auto
-
Browser-Specific Execution: The browser can be changed via the
config/config.py
file by setting theBROWSER
variable to eitherchrome
,firefox
, oredge
.
To ensure code quality, the framework uses pylint
to analyze Python code. To run pylint, use the following command:
pylint <path_to_your_python_files>
- Create a new test file under the
tests/
directory (e.g.,test_new_feature.py
). - Write your test cases using Pytest.
- Use the page objects to interact with the web elements.
Example:
from pages.home_page import HomePage def test_example(browser): home_page = HomePage(browser) home_page.click_on_search()
In the future, this framework can be integrated into CI/CD pipelines such as Jenkins, GitLab CI, or GitHub Actions by:
- Setting up a job to install dependencies (
pip install -r requirements.txt
). - Running tests using
pytest
with reporting (pytest --alluredir=reports
). - Generating Allure reports post-execution.
Example CI step:
stages:
- lint
- test
lint:
stage: lint
script:
- pylint pages/
test_job:
stage: test
script:
- pip install -r requirements.txt
- pytest --alluredir=reports
artifacts:
when: always
paths:
- reports/
- Integrate with CI/CD pipelines for automated execution.
- Add Docker support to easily manage dependencies and execution environments.
- Extend browser options for running tests on cloud services like Selenium Grid or BrowserStack.