This project uses Selenium with Docker to manage automated testing on a web app. The project includes several test cases demo, all written in Python using the Pytest framework.
Selenium-in-Docker/
├── Dockerfile # Docker configuration file
├── requirements.txt # Python dependencies
├── tests/ # Directory containing test cases
│ ├── test_web.py # Test cases for login, registration, password change
├── run_tests.py # Script to run the tests
└── README.md # Project documentation
- Docker
- Python 3.8
- Chrome WebDriver or Edge WebDriver
-
Clone the repository:
git clone https://github.com/Caryio/Selenium-in-Docker.git cd Selenium-in-Docker
-
Build the Docker image:
docker build -t selenium-docker-test .
-
Install Python dependencies:
If you prefer to run the tests outside of Docker, you can install the dependencies locally:
pip install -r requirements.txt
-
Run all tests:
docker run --rm selenium-docker-test
-
Run specific test groups:
Uncomment the relevant function call in
run_tests.py
to execute specific test groups (login, registration, or change password).docker run --rm selenium-docker-test pytest -m login --html=report_login.html docker run --rm selenium-docker-test pytest -m register --html=report_register.html docker run --rm selenium-docker-test pytest -m change_password --html=report_change_password.html docker run --rm selenium-docker-test pytest -m search --html=report_search.html docker run --rm selenium-docker-test pytest -m navigation --html=report_navigation.html docker run --rm selenium-docker-test pytest -m form_submission --html=report_form_submission.html
-
Run all tests:
python run_tests.py
-
Run specific test groups:
Uncomment the relevant function call in
run_tests.py
to execute specific test groups (login, registration, or change password).
The test cases are organized in the tests/test_web.py
file. Each test case uses Selenium to interact with the web application and Pytest markers to organize the tests into different groups.
-
Login Test:
- Opens the login page
- Enters username and password
- Clicks the login button
- Asserts successful login by checking the page title
-
Registration Test:
- Opens the registration page
- Enters user details (username, email, password)
- Clicks the register button
- Asserts successful registration by checking the page content
-
Change Password Test:
- Opens the change password page
- Enters current and new passwords
- Clicks the change password button
- Asserts successful password change by checking the page content
-
Search Test:
- Opens the home page
- Enters a search query
- Submits the search form
- Asserts that the search results page is displayed
-
Navigation Test:
- Opens the home page
- Clicks on a link
- Asserts that the expected page is displayed
-
Form Submission Test:
- Opens the form page
- Enters text into a text field
- Selects an option from a dropdown
- Checks a checkbox
- Submits the form
- Asserts that the form submission was successful
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.