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.1.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.1-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bugster-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 fbb2f9fe42f01fe986201ed249141cfb75917e81e4fab76c4f98a3900c850ee6
MD5 55cb512b4828e64682a32dc46d32e324
BLAKE2b-256 cb14ea6edf55ee76282aa27811eec9835f5e6970c80c6f7b72a5d077be655fea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bugster-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fed3acac19e26ee7b940ad6a0b9044280f7cf371b5eebe675276e7b1205b458c
MD5 621f1b4b1e6e39c5c8154f4f90679b42
BLAKE2b-256 684a8c8a82521210ce3a362da746311fd79056987e5b93b6e9367a710fceb5fc

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