This repository contains automated tests for the TestArena application using Selenium WebDriver and Python.
- Python 3.8 or higher
- Docker and Docker Compose
- Git
- Chrome browser
-
Download TestArenaApp and extract it to your project directory:
# Your project structure should look like this: selenium_python/ ├── TestArenaApp/ │ ├── docker-compose.yml │ └── ... (other TestArena files) ├── tests/ ├── pages/ └── ... (other project files) -
Start Docker containers:
cd TestArenaApp docker-compose up -d -
Verify containers are running:
docker ps
You should see three containers:
- docker-app
- docker-phpmyadmin
- docker-db
-
Create and activate virtual environment:
python -m venv venv .\venv\Scripts\activate # Windows source venv/bin/activate # Linux/Mac
-
Install dependencies:
pip install -r requirements.txt
-
Copy and configure environment variables:
cp .env.example .env
Edit
.envfile with your settings:BASE_URL=http://localhost BROWSER=chrome HEADLESS=False IMPLICIT_WAIT=10 EXPLICIT_WAIT=20 # Database configuration DB_HOST=localhost DB_PORT=3306 DB_USER=root DB_PASSWORD=root DB_NAME=testarena # Test user credentials TEST_USER_EMAIL=administrator@testarena.pl TEST_USER_PASSWORD=12qwAS⚠️ SECURITY WARNINGThe values shown above are just examples. Always:
- Set your own environment variables
- Never commit
.envfile to git repository - Never share your credentials publicly
- Add
.envto your.gitignorefile
Exposing sensitive credentials can lead to security breaches!
selenium_python/
├── pages/ # Page Object Models
│ ├── base_page.py
│ ├── login_page.py
│ ├── dashboard_page.py
│ └── ...
├── tests/ # Test files
│ ├── test_login.py
│ └── test_add_task.py
├── utils/ # Helper utilities
│ └── webdriver_helper.py
└── conftest.py # Pytest configuration and fixtures
pytest tests/ -vpytest tests/test_login.py -vpytest tests/test_login.py -v -k "test_login_with_valid_credentials"- With print statements:
pytest -v -s - With detailed output:
pytest -v --verbose - Generate HTML report:
pytest --html=report.html
-
Login Tests (
test_login.py):- Valid credentials
- Invalid credentials
- Empty fields
- Invalid email format
-
Task Management Tests (
test_add_task.py):- Create new task
- Task details verification
The project uses several tools to maintain code quality:
flake8: Basic PEP-8 style checkingflake8-docstrings: Docstring style checkingflake8-import-order: Import order checkingflake8-quotes: Quotation style checkingflake8-bugbear: Additional bug checks
black: Automatic code formattingisort: Import sorting
# Run flake8 checks
flake8 --exclude=venv,TestArenaApp,docker
# Format code with black
black .
# Sort imports with isort
isort .
# Check specific file or directory
flake8 pages/login_page.py
black pages/login_page.py
isort pages/login_page.py
# Show statistics
flake8 --statistics
# Show source code for each error
flake8 --show-sourceAdd these settings to your .vscode/settings.json for real-time linting and formatting:
{
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--config=.flake8"
],
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}