A comprehensive and modular Python-based testing framework for automating API, UI, database, and AWS integration tests
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file automation_testing_framework-0.1.0.tar.gz.
File metadata
- Download URL: automation_testing_framework-0.1.0.tar.gz
- Upload date:
- Size: 41.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d74ce6d3a167152a60ef88d2e1896020de1fe1b9394ad4f28dddabee0f1ef32d
|
|
| MD5 |
e3805ac80ef6b2ee2533e090a25fed4f
|
|
| BLAKE2b-256 |
52eb2e0a981550a0d096d0fb7b28538690c2311f238564b4fea630313c624071
|
File details
Details for the file automation_testing_framework-0.1.0-py3-none-any.whl.
File metadata
- Download URL: automation_testing_framework-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2313ecf6d03b4c7f5dd4e07875cac6aacbb88c3990eb0421e4902f7ccdbe0bc8
|
|
| MD5 |
f53104312dd604730764939489b0d15c
|
|
| BLAKE2b-256 |
1efaaa3132db99c1750b146cd5b9c28e48bcb45384b92cfd8540115be32973f3
|