This project demonstrates automated testing using Selenium WebDriver. It includes test scripts for web applications to ensure functionality, performance, and usability.
- Automated UI testing using Selenium
- Support for multiple browsers (Chrome, Firefox, Edge)
- Integration with pytest for test execution
- Data-driven testing using CSV or JSON files
- Headless browser testing support
- Logging and reporting using Allure
- Python 3.x installed
- Browser drivers installed (ChromeDriver, GeckoDriver, etc.)
- Required Python packages installed
Clone the repository and install dependencies:
# Clone the repository
git clone https://github.com/your-username/testing-with-selenium.git
cd testing-with-selenium
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
# Install dependencies
pip install -r requirements.txt
Ensure that the appropriate web driver is placed in the system PATH or specify its location in the script.
Execute tests using pytest:
pytest tests/
Run tests with detailed output:
pytest -v --html=report.html --self-contained-html
Run tests in headless mode:
pytest --headless
- Create a new test file in the
tests/
folder. - Import
pytest
andselenium
. - Write test functions using
pytest
format. - Use
setup
andteardown
methods for driver initialization.
Example:
import pytest
from selenium import webdriver
def test_google_search():
driver = webdriver.Chrome()
driver.get("https://www.google.com")
assert "Google" in driver.title
driver.quit()
Generate an HTML report:
pytest --html=report.html