Skip to main content

AI-powered browser automation to test script converter

Project description

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!

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

browse_to_test-0.2.19.tar.gz (238.9 kB view details)

Uploaded Source

Built Distribution

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

browse_to_test-0.2.19-py3-none-any.whl (177.2 kB view details)

Uploaded Python 3

File details

Details for the file browse_to_test-0.2.19.tar.gz.

File metadata

  • Download URL: browse_to_test-0.2.19.tar.gz
  • Upload date:
  • Size: 238.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for browse_to_test-0.2.19.tar.gz
Algorithm Hash digest
SHA256 cd5859a451f4ab354a924cf353a1334152e9211d331b2d60774d9879fe5dee49
MD5 fd646bc8cf280de484386cacebe0e5ad
BLAKE2b-256 36aaba60a46dc25fb9d0d32b8cb24828f49fac7c57e577a90130131413d1d5be

See more details on using hashes here.

File details

Details for the file browse_to_test-0.2.19-py3-none-any.whl.

File metadata

File hashes

Hashes for browse_to_test-0.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 b5ca42c2963eeb606ee701e5e33de2f4aa5c6b34439622f5935e5de58bbc6408
MD5 7c528d5d672c3adcd7e0119a6bdb20db
BLAKE2b-256 44a81a0ab783030f19edd69370dfb7177ac494b98abc38a6e033c9d1a18c6ed7

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