Automation Testing Framework
A comprehensive and modular Python-based testing framework for automating API, UI, database, and AWS integration tests, with robust reporting capabilities.
🧰 Overview
This automation framework provides a unified approach to testing various components of your application stack, including:
- API testing with request validation and response assertions
- UI testing using Playwright for browser automation
- Database testing with PostgreSQL and ClickHouse support
- AWS services integration testing
- Comprehensive reporting using Allure
🌟 Features
- Modular Design: Easily extendable for various testing needs
- Cross-platform: Works on any OS that supports Python
- Reliable Reporting: Detailed reports with Allure, including screenshots and logs
- Environment-agnostic: Use configuration files and environment variables for flexible deployment
- Comprehensive Helpers:
- API testing with request and response validation
- Database interactions with PostgreSQL and ClickHouse
- AWS service interactions with S3 and more
- Web UI automation with Playwright
📋 Requirements
- Python 3.11+
- Dependencies as listed in requirements.txt
🚀 Installation
Via pip
pip install automation-testing-framework
From source
git clone https://github.com/udisamuel/automation_framework
cd automation_framework
pip install .
🔧 Quick Start
API Testing
from automation_framework import APIHelper, APIAssert
# Create API helper
api = APIHelper(base_url="https://api.example.com")
# Make a request
response = api.get("/users")
# Assert the response
APIAssert.status_code(response, 200)
users = APIAssert.json_body(response)
print(f"Found {len(users)} users")
UI Testing with Playwright
from playwright.sync_api import sync_playwright
from automation_framework import BasePage, Config
# Configure the framework
Config.setup(base_url="https://example.com")
# Initialize Playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
# Create a base page
base_page = BasePage(page)
# Navigate to a page
base_page.navigate_to("/login")
# Interact with the page
base_page.fill("#username", "test_user")
base_page.fill("#password", "password123")
base_page.click("#login-button")
# Take a screenshot
base_page.take_screenshot("login_successful")
# Close the browser
browser.close()
Database Testing
from automation_framework import DBHelper
# Create PostgreSQL helper (ClickHouse also supported)
db = DBHelper(
host="localhost",
port=5432,
database="testdb",
user="postgres",
password="postgres"
)
# Execute a query
results = db.execute_query("SELECT * FROM users WHERE active = %s", (True,))
# Print results
for row in results:
print(f"User: {row['username']}, Email: {row['email']}")
# Close the connection
db.close()
AWS Integration
from automation_framework import AWSHelper
# Create AWS helper
aws = AWSHelper(
region="us-east-1",
access_key_id="your_access_key",
secret_access_key="your_secret_key"
)
# List S3 buckets
buckets = aws.list_buckets()
print(f"Found {len(buckets)} buckets")
# Upload a file to S3
aws.upload_file("local_file.txt", "my-bucket", "remote_file.txt")
📋 Command Line Interface
The framework includes a command-line interface for common tasks:
# Show version
automationfw --version
# Show help
automationfw --help
# Configure the framework
automationfw config --base-url "https://example.com" --timeout 30000
# List current configuration
automationfw config --list
# Make an API request
automationfw api "https://api.example.com/users" --method GET
⚙️ Configuration
You can configure the framework in several ways:
- Environment variables
.envfile (using python-dotenv)- Programmatically via the Config class
Example .env file:
BASE_URL=https://example.com
DEFAULT_TIMEOUT=30000
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=testdb
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Programmatic configuration:
from automation_framework import Config
Config.setup(
base_url="https://example.com",
timeout=30000,
postgres_config={
"host": "localhost",
"port": 5432,
"db": "testdb",
"user": "postgres",
"password": "postgres"
}
)
📚 Documentation
For detailed documentation on all components, see the docstrings in the code or run:
# Generate HTML documentation with pdoc
pip install pdoc
pdoc --html --output-dir docs automation_framework
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for automation-testing-framework 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| automation_testing_framework-0.1.0.tar.gz | 41.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| automation_testing_framework-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.2 kB
Release files / automation_testing_framework-0.1.0.tar.gz
| Download URL | automation_testing_framework-0.1.0.tar.gz |
|---|---|
| Size | 41.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d74ce6d3a167152a60ef88d2e1896020de1fe1b9394ad4f28dddabee0f1ef32d
|
|
BLAKE2b-256 checksum How to use checksums |
52eb2e0a981550a0d096d0fb7b28538690c2311f238564b4fea630313c624071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.0
|
Release files / automation_testing_framework-0.1.0-py3-none-any.whl
| Download URL | automation_testing_framework-0.1.0-py3-none-any.whl |
|---|---|
| Size | 41.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2313ecf6d03b4c7f5dd4e07875cac6aacbb88c3990eb0421e4902f7ccdbe0bc8
|
|
BLAKE2b-256 checksum How to use checksums |
1efaaa3132db99c1750b146cd5b9c28e48bcb45384b92cfd8540115be32973f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.0
|