This repository includes comprehensive test automation frameworks for end-to-end testing using Python, pytest, and Selenium. It includes both API and UI test suites with integrated CI/CD via Jenkins.
- Target: JSONPlaceholder API
- Framework: pytest with requests
- Features:
- JSON Schema validation
- Multiple API endpoints testing
- Custom pytest markers
- HTML and JSON reports
- Target: SauceDemo Application
- Framework: Selenium with pytest
- Features:
- Page Object Model design pattern
- Selenium Grid support
- Cross-browser testing capability
- HTML reports
- Docker & Docker Compose
- Git
- Python 3.8+
# Clone repository
git clone <repo-url>
cd AutoTestLab
# Run setup script
chmod +x setup-jenkins.sh
./setup-jenkins.shThis starts:
- Jenkins on http://localhost:8080
- Selenium Hub on http://localhost:4444
- Chrome browser node
# Start Docker containers (if not already running)
docker compose up -d
# Run all tests
chmod +x run_tests.sh
./run_tests.sh all
# Run specific suite
./run_tests.sh api # Only API tests
./run_tests.sh ui # Only UI tests# API Tests
cd JsonPlaceholder-API-Automation-Suite
pip3 install -r requirements.txt
pytest tests/ -v --html=api_report.html
# UI Tests (with Selenium Grid)
cd SauceDemo-UI-Automation-Suite
export USE_GRID=true
export SELENIUM_HUB_URL=http://localhost:4444
pip3 install -r requirements.txt
pytest tests/ -v --html=ui_report.htmlβββββββββββββββββββββββββββββββββββββββββββββββ
β GitHub Repository (with Webhooks) β
β (PR triggers Jenkins pipeline automatically) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Jenkins Container (Orchestration & Reports) β
β - Runs API Tests β
β - Runs UI Tests (via Selenium Grid) β
β - Publishes results to PR β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
βββββββββββ΄βββββββββββ
βΌ βΌ
ββββββββββββ βββββββββββββ
β API Testsβ βSelenium β
β JSONPlaceHolder β Hub & Chromeβ
ββββββββββββ βββββββββββββ
AutoTestLab/
βββ JsonPlaceholder-API-Automation-Suite/
β βββ tests/
β βββ resource/ (JSON schemas)
β βββ config.py
β βββ requirements.txt
β βββ pytest.ini
β
βββ SauceDemo-UI-Automation-Suite/
β βββ tests/
β βββ pages/ (Page Objects)
β βββ utils/
β β βββ browser.py (WebDriver setup)
β βββ conftest.py
β βββ requirements.txt
β
βββ scripts/
β βββ generate_report.py
β βββ publish_pr_comment.py
β βββ requirements.txt
β
βββ jenkins-init/
β βββ configure.groovy
β
βββ Jenkinsfile (CI/CD Pipeline)
βββ compose.yml (Container setup)
βββ setup-jenkins.sh (Quick start script)
βββ run_tests.sh (Local test runner)
βββ .env.example (Configuration template)
βββ JENKINS_SETUP.md (Detailed setup guide)
βββ README.md (This file)
Copy .env.example to .env and update with your values:
cp .env.example .env
# Edit .env with your configurationKey variables:
GITHUB_TOKEN: GitHub Personal Access Token for PR commentsGITHUB_REPOSITORY: Repository in formatowner/repoSELENIUM_HUB_URL: Selenium Grid URL (default: http://localhost:4444)USE_GRID: Enable Selenium Grid (true/false)
- Access Jenkins: http://localhost:8080
- Create new Pipeline job
- Configure with GitHub repository URL
- Set script path to
Jenkinsfile - Add GitHub webhook for PR triggers
See JENKINS_SETUP.md for detailed instructions.
- API Report:
JsonPlaceholder-API-Automation-Suite/api_report.html - UI Report:
SauceDemo-UI-Automation-Suite/ui_report.html - Combined Report:
combined_report.html - JUnit XML: For CI/CD integration
# Jenkins UI
# http://localhost:8080/job/AutoTestLab-Pipeline/
# Local reports (open in browser)
open combined_report.htmlTest results are automatically posted as PR comments when running via Jenkins with GitHub integration:
## π§ͺ Test Report
**Status:** SUCCESS
**Timestamp:** 2024-01-18 10:30:45 UTC
### API Tests
- **Total:** 15 | **β
Passed:** 15 | **β Failed:** 0
### UI Tests
- **Total:** 6 | **β
Passed:** 6 | **β Failed:** 0
# Start containers
docker compose up -d
# Stop containers
docker compose stop
# View logs
docker compose logs -f
# Check status
docker compose ps
# Restart specific service
docker compose restart jenkins
# Clean up
docker compose down -v- URL: http://localhost:4444/ui/index.html
- View active sessions, nodes, and capabilities
- URL: http://localhost:8080
- View job history, logs, and reports
# Jenkins logs
docker logs -f jenkins
# Selenium Hub logs
docker logs -f selenium-hub
# Chrome node logs
docker logs -f selenium-chrome# Check if hub is running
docker ps | grep selenium-hub
# Test connection
curl http://localhost:4444/wd/hub/status
# Check logs
docker logs selenium-hub# Check logs
docker logs jenkins
# Increase timeout and retry
docker compose restart jenkins
sleep 60# Increase shared memory
# Edit compose.yml: shm_size: 4gb
# Restart containers
docker compose down
docker compose up -dSee JENKINS_SETUP.md for more troubleshooting tips.
- JENKINS_SETUP.md - Complete Jenkins setup guide
- JsonPlaceholder-API-Automation-Suite/README.md - API test suite details
- SauceDemo-UI-Automation-Suite/README.md - UI test suite details
β Automated Testing
- API testing with schema validation
- UI testing with Page Object Model
- Parallel execution support
β CI/CD Integration
- GitHub webhook integration
- Automated PR comments with results
- Build artifact archiving
β Containerization
- Jenkins in Docker
- Selenium Grid with Chrome/Firefox nodes
- Isolated test environment
β Reporting
- HTML reports with trends
- JUnit XML for CI integration
- Combined multi-suite reports
- PR comments with test summary
β Scalability
- Multi-node Selenium Grid
- Parallel test execution
- Configurable browser instances
- Create a new branch:
git checkout -b feature/your-feature - Make changes and commit:
git commit -am 'Add feature' - Push to branch:
git push origin feature/your-feature - Create Pull Request
- Jenkins will automatically run tests and post results
[Add your license information]
For issues, questions, or contributions:
- Check JENKINS_SETUP.md
- Review test logs in Jenkins UI
- Check Docker container logs
- Python 3.8+
- Docker 20.10+
- Docker Compose 1.29+
- Git
To update container images:
# Pull latest images
docker compose pull
# Rebuild and restart
docker compose up -d --buildLast Updated: January 18, 2024