Skip to content

sohansarode/Python-Selenium-Demo

Repository files navigation

Selenium Python TDD Project

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.

Project Structure

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

Requirements

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

How to Run Tests

1. Set up the environment

  • Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows use .venv\Scripts�ctivate

2. Install dependencies

pip install -r requirements.txt

3. Run the tests

Use pytest to execute the tests:

pytest --maxfail=5 --disable-warnings -q

4. View the reports

After 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/

Project Modules

1. Api/

Contains modules that interact with the application's API (if applicable).

2. Pages/

Contains classes representing the pages of the application, following the Page Object Model design pattern.

3. Locators/

Contains the locators (CSS selectors, XPaths, etc.) for elements on the pages.

4. Tests/

Contains the actual test scripts that implement the test cases using the Page Object Model and locators.

5. Utils/

Contains utility functions that assist in the execution of tests (e.g., for logging, data manipulation, etc.).

6. Configfile/

Contains configuration files needed for the project or the environment setup.

Logging and Reports

  • 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.

Troubleshooting

Virtual Environment Issues

  • 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.

Running Tests on Different Browsers

  • To change the browser for your Selenium tests, modify the browser setup in the conftest.py file where the browser driver is instantiated.

Test Failures

  • If a test fails, check the logs and screenshots in the Allogs/ and screenshots/ directories for debugging information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published