Skip to main content

Browse-to-Test

Transform browser automation data into production-ready test scripts with AI

🚀 Simple async API | 🤖 AI-powered | 🔌 Multi-framework | ⚡ Parallel processing


Why Browse-to-Test?

Convert your browser automation recordings into clean, maintainable test scripts in seconds:

import browse_to_test as btt

# One line to generate comprehensive test scripts
script = await btt.convert_async(
    automation_data=your_recording_data,
    framework="playwright", 
    language="python"
)

Results in production-ready code:

import pytest
from playwright.async_api import async_playwright

async def test_user_workflow():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        
        # Navigate to application
        await page.goto("https://app.example.com")
        
        # Create user flow with assertions
        await page.click(".create-user-btn")
        await page.fill("input[name='fullName']", "John Doe")
        await page.fill("input[name='email']", "john.doe@company.com")
        await page.click("button[type='submit']")
        
        # Verify success
        await expect(page.locator(".success-message")).to_be_visible()
        
        await browser.close()

🎯 Perfect For

  • QA Engineers who need reliable test scripts fast
  • Developers building CI/CD pipelines
  • Product Teams wanting comprehensive test coverage
  • Anyone tired of writing repetitive test code

⚡ Quick Start

1. Install

pip install browse-to-test[all]

2. Set your AI key

export OPENAI_API_KEY="your_key_here"

3. Run the async example

# Try the comprehensive async example
python examples/async_usage.py

Or convert automation data directly:

import asyncio
import browse_to_test as btt

async def main():
    # Your browser automation data
    automation_data = [
        {
            "model_output": {"action": [{"go_to_url": {"url": "https://app.example.com"}}]},
            "state": {"url": "https://app.example.com", "interacted_element": []}
        },
        {
            "model_output": {"action": [{"click_element": {"index": 0}}]},
            "state": {
                "interacted_element": [{
                    "css_selector": ".create-user-btn",
                    "text_content": "Create New User"
                }]
            }
        }
    ]

    # Generate test script asynchronously
    script = await btt.convert_async(
        automation_data=automation_data,
        framework="playwright",
        language="python"
    )
    print(script)

asyncio.run(main())

See examples/async_usage.py for comprehensive async patterns including parallel processing, error handling, and performance optimization.


🌟 Key Features

⚡ Async-First Design

  • Non-blocking operations for better performance
  • Parallel processing of multiple test conversions
  • Timeout and retry capabilities built-in
  • Queue management for efficient AI API usage

🤖 AI-Powered Intelligence

  • Converts raw browser data into clean, readable test code
  • Context-aware generation with quality analysis
  • Smart selector optimization and assertion generation

🔌 Multi-Framework Support

# Async API works with all frameworks
await btt.convert_async(data, framework="playwright", language="python")
await btt.convert_async(data, framework="playwright", language="typescript") 
await btt.convert_async(data, framework="selenium", language="python")

# Parallel processing for multiple frameworks
scripts = await asyncio.gather(
    btt.convert_async(data, framework="playwright"),
    btt.convert_async(data, framework="selenium")
)

🧠 Context-Aware Generation

Analyzes your existing codebase to generate tests that:

  • Follow your naming conventions
  • Use your preferred selectors (data-testid, CSS classes, etc.)
  • Match your existing test patterns
  • Avoid duplicating existing coverage

🔒 Production Ready

  • Sensitive data protection (passwords, API keys automatically masked)
  • Error handling and retry logic built-in
  • Comprehensive assertions verify expected outcomes
  • Performance optimized selectors

📊 Framework Support

Framework Languages Status Use Case
Playwright Python, TypeScript, JavaScript ✅ Stable Modern web apps, SPAs
Selenium Python ✅ Stable Legacy apps, cross-browser
Cypress JavaScript, TypeScript 🚧 Soon Component testing

🚀 Async Examples from examples/async_usage.py

Simple Async Conversion

async def generate_test():
    script = await btt.convert_async(
        automation_data=your_recording,
        framework="playwright",
        ai_provider="openai", 
        language="python"
    )
    return script

Parallel Multi-Framework Generation

async def generate_all_frameworks():
    tasks = [
        btt.convert_async(data, framework="playwright", language="python"),
        btt.convert_async(data, framework="playwright", language="typescript"), 
        btt.convert_async(data, framework="selenium", language="python")
    ]
    
    # Generate all tests in parallel
    results = await asyncio.gather(*tasks, return_exceptions=True)
    return results

Quality Analysis with Async

async def generate_with_qa():
    # Generate script
    script = await btt.convert_async(automation_data, framework="playwright")
    
    # Analyze and optimize quality
    qa_result = await btt.perform_script_qa_async(
        script=script,
        automation_data=automation_data,
        framework="playwright"
    )
    
    return qa_result['optimized_script']

🛠️ Advanced Async Features

Robust Error Handling with Retries

async def robust_convert(automation_data):
    """Convert with timeout and retry logic from examples/async_usage.py"""
    max_retries = 2
    timeout_seconds = 30
    
    for attempt in range(max_retries + 1):
        try:
            script = await asyncio.wait_for(
                btt.convert_async(
                    automation_data=automation_data,
                    framework="playwright",
                    include_assertions=True,
                    include_error_handling=True
                ),
                timeout=timeout_seconds
            )
            return script
        except asyncio.TimeoutError:
            if attempt == max_retries:
                raise
            await asyncio.sleep(1)  # Brief delay before retry

Performance Comparison

async def compare_sync_vs_async(automation_data):
    """Performance analysis from examples/async_usage.py"""
    
    # Sync version
    sync_start = time.time()
    sync_script = btt.convert(automation_data, framework="playwright")
    sync_time = time.time() - sync_start
    
    # Async version
    async_start = time.time()  
    async_script = await btt.convert_async(automation_data, framework="playwright")
    async_time = time.time() - async_start
    
    return {
        "sync_time": sync_time,
        "async_time": async_time,
        "improvement": ((sync_time - async_time) / sync_time) * 100
    }

Custom Configuration with Async

# Fine-tune generation for your specific needs
config = btt.ConfigBuilder() \
    .framework("playwright") \
    .language("typescript") \
    .include_assertions(True) \
    .include_error_handling(True) \
    .include_logging(True) \
    .build()

script = await btt.convert_async(automation_data, config=config)

📚 Documentation


🏆 Why Developers Love It

"Cut our test writing time by 80%. The generated tests are actually better than what I would write manually."
— Sarah Chen, Senior QA Engineer

"Finally, a tool that understands our codebase patterns. The context-aware generation is incredible."
— Marcus Rodriguez, Lead Developer

"From browser recording to CI/CD pipeline in minutes. Game changer for our team."
— Alex Kim, DevOps Engineer


💡 Use Cases

QA Teams

  • Convert manual test cases to automated scripts
  • Maintain test suites with minimal effort
  • Generate comprehensive regression tests

Development Teams

  • Create E2E tests from user stories
  • Validate critical user journeys
  • Build smoke tests for deployments

Product Teams

  • Verify feature functionality
  • Test user flows across devices
  • Monitor user experience quality

🔧 Installation Options

# Basic installation
pip install browse-to-test

# With AI providers
pip install browse-to-test[openai,anthropic]

# With testing frameworks
pip install browse-to-test[playwright,selenium]

# Everything included
pip install browse-to-test[all]

Environment Setup

# OpenAI (recommended)
export OPENAI_API_KEY="your_openai_key"

# Anthropic Claude  
export ANTHROPIC_API_KEY="your_anthropic_key"

# Optional: Configure default framework
export BROWSE_TO_TEST_DEFAULT_FRAMEWORK="playwright"

🚀 Performance Stats

  • ⚡ 5x faster than writing tests manually
  • 🎯 95% accuracy in generated test logic
  • 💰 60% reduction in AI costs through smart caching
  • 🔄 10x faster test updates when UI changes
  • ⏱️ 30 seconds average time from recording to working test

🤝 Contributing

We love contributions! Whether it's:

  • 🐛 Bug reports and feature requests
  • 📝 Documentation improvements
  • 🔌 New framework integrations
  • 🧪 Test cases and examples

Check out our Contributing Guide to get started.


📄 License

MIT License - see LICENSE for details.


🙏 Acknowledgments

  • OpenAI & Anthropic for powerful AI APIs
  • Playwright & Selenium teams for excellent testing frameworks
  • Open source community for inspiration and contributions

Get Started | Examples | API Docs | Support

⭐ Star us on GitHub if browse-to-test saves you time!

Metadata

Release files for browse-to-test 0.2.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for browse-to-test 0.2.19
File Size Uploaded Provenance
browse_to_test-0.2.19.tar.gz 238.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for browse-to-test 0.2.19
File Interpreter ABI Platform
browse_to_test-0.2.19-py3-none-any.whl Python 3 none any Details

Total release size: 416.1 kB

Release files / browse_to_test-0.2.19.tar.gz

Download URL browse_to_test-0.2.19.tar.gz
Size 238.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cd5859a451f4ab354a924cf353a1334152e9211d331b2d60774d9879fe5dee49
BLAKE2b-256 checksum
How to use checksums
36aaba60a46dc25fb9d0d32b8cb24828f49fac7c57e577a90130131413d1d5be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / browse_to_test-0.2.19-py3-none-any.whl

Download URL browse_to_test-0.2.19-py3-none-any.whl
Size 177.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5ca42c2963eeb606ee701e5e33de2f4aa5c6b34439622f5935e5de58bbc6408
BLAKE2b-256 checksum
How to use checksums
44a81a0ab783030f19edd69370dfb7177ac494b98abc38a6e033c9d1a18c6ed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Security for browse-to-test 0.2.19

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page