- About the Project
- Technologies Used
- Project Structure
- Installation
- Running the Tests
- Test Scenarios
- Environment Variables
- Browser Support
- Key Files
- Contributing
- License
This Selenium Automation Framework is designed to automate end-to-end testing for web applications. It follows the Page Object Model (POM) design pattern, ensuring maintainable, reusable, and scalable test code.
The framework supports multi-browser execution (Chrome, Firefox, Edge) and offers flexibility for running tests locally or via CI/CD pipelines like GitHub Actions, Jenkins, or Azure DevOps.
- Programming Language: Python
- Testing Framework: Pytest
- Browser Drivers: ChromeDriver, EdgeDriver, GeckoDriver
- Selenium WebDriver: Browser automation
- Reporting: HTML report generation using pytest-html
- Logging: Custom logging for test execution tracking
├── tests
│ └── test_login.py # Test cases for login page
├── pages
│ ├── base_page.py # Base Page with generic methods
│ └── login_page.py # Login page-specific methods and locators
├── utils
│ ├── config.py # Configuration file
│ └── logger.py # Logger for tracking actions and errors
├── conftest.py # Pytest fixtures for driver setup/teardown
├── requirements.txt # Python dependencies
├── README.md # Documentation
├── .gitignore # Git ignore file
To get a local copy up and running, follow these steps:
git clone https://github.com/RahulKesyar/Python_Selenium_Automation.git
cd Python_Selenium_Automationpython -m venv venv
source venv/bin/activate # On Windows use venv\Scripts\activatepip install -r requirements.txt- Download ChromeDriver for your Chrome version here.
- Download EdgeDriver for Edge browser here.
- Download GeckoDriver for Firefox here.
Run tests using pytest. Example for login functionality:
pytest --html=report.html --self-contained-htmlpytest tests/test_login.py::TestLogin::test_valid_login_without_remember_mepytest --html=report.html| Test Case | Description | Test Method |
|---|---|---|
| Valid Login | Test login with valid credentials | test_valid_login_with_remember_me() |
| Invalid Login | Test login with invalid credentials | test_invalid_login() |
| Empty Username | Test login with empty username | test_login_with_empty_username() |
| Empty Password | Test login with empty password | test_login_with_empty_password() |
| SQL Injection | Verify SQL Injection on login | test_sql_injection_login() |
| XSS Attack | Verify XSS attack handling | test_xss_attack_login() |
| Variable | Description | Default Value |
|---|---|---|
BASE_URL |
Base URL of the application | https://example.com |
BROWSER |
Browser (chrome/firefox/edge) | chrome |
Note: The
BROWSERvalue can be changed inutils/config.py:
BROWSER = "edge" # Options: chrome, firefox, edgeThis framework supports:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
To switch the browser, change the BROWSER variable in utils/config.py.
| File | Description |
|---|---|
| base_page.py | Reusable methods for all pages |
| login_page.py | Locators and methods for login |
| test_login.py | Test cases for login features |
| conftest.py | Setup and teardown of the driver |
| config.py | Global settings and environment variables |
| logger.py | Custom logging implementation |
1️⃣ Page Object Model (POM)
- Pages as classes in
pages/ - Each page contains locators and page-specific methods
- Example:
login_page.pywith methods likelogin,open_login_page,get_error_message
2️⃣ Test Cases
- Located in
tests/folder - Using page objects to perform actions
- Example:
TestLogincallsLoginPage.login(username, password)
3️⃣ Driver Setup
- Driver setup is in
conftest.pyusingpytest.fixture - Multi-browser support
- Kills orphan chromedriver, msedgedriver, geckodriver processes
- Fork the Repository
- Clone your Fork
- Create a New Branch
- Make your Changes
- Test the Changes
- Push the Changes
- Submit a Pull Request (PR)
Please follow the PEP-8 guidelines for Python coding.
This project is licensed under the MIT License.
Raise a GitHub issue or contact the maintainers.