Skip to main content

Python-Playwright based testing framework for Bugster's e2e testing agent

Project description

Bugster-framework

Bugster is a comprehensive testing and debugging framework designed to streamline end-to-end testing with Playwright. It provides a robust infrastructure for test automation, authentication handling, and detailed test reporting.

Features

  • Playwright Integration: Built on top of Playwright for reliable browser automation
  • Flexible Authentication: Support for multiple authentication strategies and credential management
  • Advanced Test Runner: Custom pytest plugin with dependency management between tests
  • Comprehensive Reporting: Automated screenshots, traces, and detailed test reports
  • Mouse and Keyboard Simulation: Enhanced input simulation with visual feedback
  • Test Metadata Management: Centralized configuration for test environments and settings

Installation

# Install using pip
pip install bugster

# Or if using Poetry
poetry add bugster

Usage

Basic Test Setup

import pytest
from bugster.core.bugster_expect import expect

def test_login_flow(page):
    # Navigate to login page
    page.goto("/login")
    
    # Fill login form
    page.get_by_placeholder("Email").fill("user@example.com")
    page.get_by_placeholder("Password").fill("password")
    page.get_by_role("button", name="Sign In").click()
    
    # Verify successful login
    expect(page.get_by_text("Welcome")).to_be_visible()

Authentication Strategies

Bugster supports flexible authentication methods:

from bugster.auth import UserInputLoginStrategy

# Define login steps
login_instructions = [
    {"action": "goto", "url": "/auth/sign-in"},
    {"action": "fill", "method": "placeholder", "value": "email", "text": "{email}"},
    {"action": "fill", "method": "placeholder", "value": "password", "text": "{password}"},
    {"action": "click", "method": "role", "value": "button", "kwargs": {"name": "Sign In"}}
]

# Create login strategy
auth_strategy = UserInputLoginStrategy(login_instructions)

Test Dependencies

@pytest.mark.depends(on=["test_login"])
def test_dashboard(page):
    # This test will only run if test_login passes
    page.goto("/dashboard")
    expect(page.get_by_text("Dashboard")).to_be_visible()

Trace Capture

from bugster.reporting.trace_viewer import start_trace, stop_and_save_trace

def test_with_trace(page, context):
    # Start recording trace
    start_trace(context)
    
    # Test steps...
    
    # Save trace for debugging
    trace_path = stop_and_save_trace(context, "my_test")
    print(f"Trace saved to: {trace_path}")

Configuration

Bugster uses a JSON configuration file for test settings:

{
  "settings": {
    "browser": "chromium",
    "headless": true,
    "viewport": {"width": 1920, "height": 1080}
  },
  "environment": {
    "dev": {
      "base_url": "https://dev.example.com",
      "auth_url": "https://dev.example.com/login"
    },
    "prod": {
      "base_url": "https://example.com",
      "auth_url": "https://example.com/login"
    }
  },
  "auth": {
    "credentials": [
      {
        "id": "admin",
        "email": "admin@example.com",
        "password": "admin_password"
      },
      {
        "id": "user",
        "email": "user@example.com",
        "password": "user_password"
      }
    ],
    "instructions": [
      {"action": "goto", "url": "/login"},
      {"action": "fill", "method": "placeholder", "value": "email", "text": "{email}"},
      {"action": "fill", "method": "placeholder", "value": "password", "text": "{password}"},
      {"action": "click", "method": "role", "value": "button", "kwargs": {"name": "Sign In"}}
    ]
  }
}

Running Tests

# Run tests with specific environment
pytest --env=dev

# Specify Bugster directory for credentials and reports
pytest --bugster-dir=/path/to/bugster

Contributing

We welcome contributions to Bugster! Please see our CONTRIBUTING.md file for details on how to contribute.

License

Bugster is released under the MIT License. See the LICENSE file for details.

Changelog

See the CHANGELOG.md file for details on what has changed in each version of Bugster.

Support

If you encounter any issues or have questions, please file an issue on the GitHub issue tracker.

Acknowledgements

Bugster is built on top of the excellent Playwright and pytest projects. We're grateful to the maintainers and contributors of these projects for their fantastic work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bugster-1.0.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bugster-1.0.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file bugster-1.0.0.tar.gz.

File metadata

  • Download URL: bugster-1.0.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.8 Darwin/23.1.0

File hashes

Hashes for bugster-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ca70595b6cf38e6e7236233b1d2d6085b0ca87231ddabd9428f8b6a9b9a757c5
MD5 cbe0f6b6f3d2152b5eccedb618fb9cc3
BLAKE2b-256 03a7007377037bd82811c9db0d8568cb0f02ee5ddbe512eb92cfae9cc7ff83dc

See more details on using hashes here.

File details

Details for the file bugster-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bugster-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.8 Darwin/23.1.0

File hashes

Hashes for bugster-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cc45a938f88c03d7faf72bc3506a5a214aa48d7bf8d1ff2fb962fd5a565f139
MD5 adf816b4cc65c8648735945f7062f771
BLAKE2b-256 571610bd1af91cdc55e3e89995b97acb93346b3cbd5498fd6966d01382352230

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page