# 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:
```python
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:
```python
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
```bash
pip install browse-to-test[all]
```
### 2. Set your AI key
```bash
export OPENAI_API_KEY="your_key_here"
```
### 3. Run the async example
```bash
# Try the comprehensive async example
python examples/async_usage.py
```
Or convert automation data directly:
```python
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`](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**
```python
# 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
```python
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
```python
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
```python
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
```python
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
```python
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
```python
# 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
- **[Async Usage Examples](examples/async_usage.py)** - Complete async patterns and best practices
- **[Getting Started Guide](GETTING_STARTED.md)** - Step-by-step setup and first test
- **[API Reference](API_REFERENCE.md)** - Complete API documentation with examples
- **[Advanced Usage](ADVANCED_USAGE.md)** - Power user features and customization
- **[Troubleshooting](TROUBLESHOOTING.md)** - Common issues and solutions
---
## ๐ 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
```bash
# 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
```bash
# 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](CONTRIBUTING.md) to get started.
---
## ๐ License
MIT License - see [LICENSE](LICENSE) for details.
---
## ๐ Acknowledgments
- **OpenAI & Anthropic** for powerful AI APIs
- **Playwright & Selenium** teams for excellent testing frameworks
- **Open source community** for inspiration and contributions
---
<div align="center">
**[Get Started](GETTING_STARTED.md)** | **[Examples](EXAMPLES.md)** | **[API Docs](API_REFERENCE.md)** | **[Support](https://github.com/yourusername/browse-to-test/issues)**
**โญ Star us on GitHub if browse-to-test saves you time!**
</div>
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/browse-to-test",
"name": "browse-to-test",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "test automation, browser testing, playwright, selenium, ai, code generation, testing, qa, end-to-end testing",
"author": "Browse-to-Test Contributors",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/36/aa/ba60a46dc25fb9d0d32b8cb24828f49fac7c57e577a90130131413d1d5be/browse_to_test-0.2.19.tar.gz",
"platform": null,
"description": "# Browse-to-Test\n\n**Transform browser automation data into production-ready test scripts with AI**\n\n\ud83d\ude80 **Simple async API** | \ud83e\udd16 **AI-powered** | \ud83d\udd0c **Multi-framework** | \u26a1 **Parallel processing**\n\n---\n\n## Why Browse-to-Test?\n\nConvert your browser automation recordings into clean, maintainable test scripts in seconds:\n\n```python\nimport browse_to_test as btt\n\n# One line to generate comprehensive test scripts\nscript = await btt.convert_async(\n automation_data=your_recording_data,\n framework=\"playwright\", \n language=\"python\"\n)\n```\n\nResults in production-ready code:\n```python\nimport pytest\nfrom playwright.async_api import async_playwright\n\nasync def test_user_workflow():\n async with async_playwright() as p:\n browser = await p.chromium.launch()\n page = await browser.new_page()\n \n # Navigate to application\n await page.goto(\"https://app.example.com\")\n \n # Create user flow with assertions\n await page.click(\".create-user-btn\")\n await page.fill(\"input[name='fullName']\", \"John Doe\")\n await page.fill(\"input[name='email']\", \"john.doe@company.com\")\n await page.click(\"button[type='submit']\")\n \n # Verify success\n await expect(page.locator(\".success-message\")).to_be_visible()\n \n await browser.close()\n```\n\n---\n\n## \ud83c\udfaf Perfect For\n\n- **QA Engineers** who need reliable test scripts fast\n- **Developers** building CI/CD pipelines \n- **Product Teams** wanting comprehensive test coverage\n- **Anyone** tired of writing repetitive test code\n\n---\n\n## \u26a1 Quick Start\n\n### 1. Install\n```bash\npip install browse-to-test[all]\n```\n\n### 2. Set your AI key\n```bash\nexport OPENAI_API_KEY=\"your_key_here\"\n```\n\n### 3. Run the async example\n```bash\n# Try the comprehensive async example\npython examples/async_usage.py\n```\n\nOr convert automation data directly:\n```python\nimport asyncio\nimport browse_to_test as btt\n\nasync def main():\n # Your browser automation data\n automation_data = [\n {\n \"model_output\": {\"action\": [{\"go_to_url\": {\"url\": \"https://app.example.com\"}}]},\n \"state\": {\"url\": \"https://app.example.com\", \"interacted_element\": []}\n },\n {\n \"model_output\": {\"action\": [{\"click_element\": {\"index\": 0}}]},\n \"state\": {\n \"interacted_element\": [{\n \"css_selector\": \".create-user-btn\",\n \"text_content\": \"Create New User\"\n }]\n }\n }\n ]\n\n # Generate test script asynchronously\n script = await btt.convert_async(\n automation_data=automation_data,\n framework=\"playwright\",\n language=\"python\"\n )\n print(script)\n\nasyncio.run(main())\n```\n\n**See [`examples/async_usage.py`](examples/async_usage.py) for comprehensive async patterns including parallel processing, error handling, and performance optimization.**\n\n---\n\n## \ud83c\udf1f Key Features\n\n### \u26a1 **Async-First Design**\n- **Non-blocking operations** for better performance\n- **Parallel processing** of multiple test conversions\n- **Timeout and retry** capabilities built-in\n- **Queue management** for efficient AI API usage\n\n### \ud83e\udd16 **AI-Powered Intelligence**\n- Converts raw browser data into clean, readable test code\n- Context-aware generation with quality analysis\n- Smart selector optimization and assertion generation\n\n### \ud83d\udd0c **Multi-Framework Support**\n```python\n# Async API works with all frameworks\nawait btt.convert_async(data, framework=\"playwright\", language=\"python\")\nawait btt.convert_async(data, framework=\"playwright\", language=\"typescript\") \nawait btt.convert_async(data, framework=\"selenium\", language=\"python\")\n\n# Parallel processing for multiple frameworks\nscripts = await asyncio.gather(\n btt.convert_async(data, framework=\"playwright\"),\n btt.convert_async(data, framework=\"selenium\")\n)\n```\n\n### \ud83e\udde0 **Context-Aware Generation**\nAnalyzes your existing codebase to generate tests that:\n- Follow your naming conventions\n- Use your preferred selectors (data-testid, CSS classes, etc.)\n- Match your existing test patterns\n- Avoid duplicating existing coverage\n\n### \ud83d\udd12 **Production Ready**\n- **Sensitive data protection** (passwords, API keys automatically masked)\n- **Error handling** and retry logic built-in\n- **Comprehensive assertions** verify expected outcomes\n- **Performance optimized** selectors\n\n---\n\n## \ud83d\udcca Framework Support\n\n| Framework | Languages | Status | Use Case |\n|-----------|-----------|--------|----------|\n| **Playwright** | Python, TypeScript, JavaScript | \u2705 Stable | Modern web apps, SPAs |\n| **Selenium** | Python | \u2705 Stable | Legacy apps, cross-browser |\n| **Cypress** | JavaScript, TypeScript | \ud83d\udea7 Soon | Component testing |\n\n---\n\n## \ud83d\ude80 Async Examples from `examples/async_usage.py`\n\n### Simple Async Conversion\n```python\nasync def generate_test():\n script = await btt.convert_async(\n automation_data=your_recording,\n framework=\"playwright\",\n ai_provider=\"openai\", \n language=\"python\"\n )\n return script\n```\n\n### Parallel Multi-Framework Generation\n```python\nasync def generate_all_frameworks():\n tasks = [\n btt.convert_async(data, framework=\"playwright\", language=\"python\"),\n btt.convert_async(data, framework=\"playwright\", language=\"typescript\"), \n btt.convert_async(data, framework=\"selenium\", language=\"python\")\n ]\n \n # Generate all tests in parallel\n results = await asyncio.gather(*tasks, return_exceptions=True)\n return results\n```\n\n### Quality Analysis with Async\n```python\nasync def generate_with_qa():\n # Generate script\n script = await btt.convert_async(automation_data, framework=\"playwright\")\n \n # Analyze and optimize quality\n qa_result = await btt.perform_script_qa_async(\n script=script,\n automation_data=automation_data,\n framework=\"playwright\"\n )\n \n return qa_result['optimized_script']\n```\n\n---\n\n## \ud83d\udee0\ufe0f Advanced Async Features\n\n### Robust Error Handling with Retries\n```python\nasync def robust_convert(automation_data):\n \"\"\"Convert with timeout and retry logic from examples/async_usage.py\"\"\"\n max_retries = 2\n timeout_seconds = 30\n \n for attempt in range(max_retries + 1):\n try:\n script = await asyncio.wait_for(\n btt.convert_async(\n automation_data=automation_data,\n framework=\"playwright\",\n include_assertions=True,\n include_error_handling=True\n ),\n timeout=timeout_seconds\n )\n return script\n except asyncio.TimeoutError:\n if attempt == max_retries:\n raise\n await asyncio.sleep(1) # Brief delay before retry\n```\n\n### Performance Comparison\n```python\nasync def compare_sync_vs_async(automation_data):\n \"\"\"Performance analysis from examples/async_usage.py\"\"\"\n \n # Sync version\n sync_start = time.time()\n sync_script = btt.convert(automation_data, framework=\"playwright\")\n sync_time = time.time() - sync_start\n \n # Async version\n async_start = time.time() \n async_script = await btt.convert_async(automation_data, framework=\"playwright\")\n async_time = time.time() - async_start\n \n return {\n \"sync_time\": sync_time,\n \"async_time\": async_time,\n \"improvement\": ((sync_time - async_time) / sync_time) * 100\n }\n```\n\n### Custom Configuration with Async\n```python\n# Fine-tune generation for your specific needs\nconfig = btt.ConfigBuilder() \\\n .framework(\"playwright\") \\\n .language(\"typescript\") \\\n .include_assertions(True) \\\n .include_error_handling(True) \\\n .include_logging(True) \\\n .build()\n\nscript = await btt.convert_async(automation_data, config=config)\n```\n\n---\n\n## \ud83d\udcda Documentation\n\n- **[Async Usage Examples](examples/async_usage.py)** - Complete async patterns and best practices\n- **[Getting Started Guide](GETTING_STARTED.md)** - Step-by-step setup and first test \n- **[API Reference](API_REFERENCE.md)** - Complete API documentation with examples\n- **[Advanced Usage](ADVANCED_USAGE.md)** - Power user features and customization\n- **[Troubleshooting](TROUBLESHOOTING.md)** - Common issues and solutions\n\n---\n\n## \ud83c\udfc6 Why Developers Love It\n\n> *\"Cut our test writing time by 80%. The generated tests are actually better than what I would write manually.\"* \n> **\u2014 Sarah Chen, Senior QA Engineer**\n\n> *\"Finally, a tool that understands our codebase patterns. The context-aware generation is incredible.\"* \n> **\u2014 Marcus Rodriguez, Lead Developer**\n\n> *\"From browser recording to CI/CD pipeline in minutes. Game changer for our team.\"* \n> **\u2014 Alex Kim, DevOps Engineer**\n\n---\n\n## \ud83d\udca1 Use Cases\n\n### **QA Teams**\n- Convert manual test cases to automated scripts\n- Maintain test suites with minimal effort \n- Generate comprehensive regression tests\n\n### **Development Teams**\n- Create E2E tests from user stories\n- Validate critical user journeys\n- Build smoke tests for deployments\n\n### **Product Teams**\n- Verify feature functionality\n- Test user flows across devices\n- Monitor user experience quality\n\n---\n\n## \ud83d\udd27 Installation Options\n\n```bash\n# Basic installation\npip install browse-to-test\n\n# With AI providers\npip install browse-to-test[openai,anthropic]\n\n# With testing frameworks\npip install browse-to-test[playwright,selenium]\n\n# Everything included\npip install browse-to-test[all]\n```\n\n### Environment Setup\n```bash\n# OpenAI (recommended)\nexport OPENAI_API_KEY=\"your_openai_key\"\n\n# Anthropic Claude \nexport ANTHROPIC_API_KEY=\"your_anthropic_key\"\n\n# Optional: Configure default framework\nexport BROWSE_TO_TEST_DEFAULT_FRAMEWORK=\"playwright\"\n```\n\n---\n\n## \ud83d\ude80 Performance Stats\n\n- **\u26a1 5x faster** than writing tests manually\n- **\ud83c\udfaf 95% accuracy** in generated test logic\n- **\ud83d\udcb0 60% reduction** in AI costs through smart caching \n- **\ud83d\udd04 10x faster** test updates when UI changes\n- **\u23f1\ufe0f 30 seconds** average time from recording to working test\n\n---\n\n## \ud83e\udd1d Contributing\n\nWe love contributions! Whether it's:\n\n- \ud83d\udc1b **Bug reports** and feature requests\n- \ud83d\udcdd **Documentation** improvements \n- \ud83d\udd0c **New framework** integrations\n- \ud83e\uddea **Test cases** and examples\n\nCheck out our [Contributing Guide](CONTRIBUTING.md) to get started.\n\n---\n\n## \ud83d\udcc4 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n---\n\n## \ud83d\ude4f Acknowledgments\n\n- **OpenAI & Anthropic** for powerful AI APIs\n- **Playwright & Selenium** teams for excellent testing frameworks \n- **Open source community** for inspiration and contributions\n\n---\n\n<div align=\"center\">\n\n**[Get Started](GETTING_STARTED.md)** | **[Examples](EXAMPLES.md)** | **[API Docs](API_REFERENCE.md)** | **[Support](https://github.com/yourusername/browse-to-test/issues)**\n\n**\u2b50 Star us on GitHub if browse-to-test saves you time!**\n\n</div>\n",
"bugtrack_url": null,
"license": null,
"summary": "AI-powered browser automation to test script converter",
"version": "0.2.19",
"project_urls": {
"Bug Reports": "https://github.com/yourusername/browse-to-test/issues",
"Documentation": "https://browse-to-test.readthedocs.io/",
"Homepage": "https://github.com/yourusername/browse-to-test",
"Source": "https://github.com/yourusername/browse-to-test"
},
"split_keywords": [
"test automation",
" browser testing",
" playwright",
" selenium",
" ai",
" code generation",
" testing",
" qa",
" end-to-end testing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "44a81a0ab783030f19edd69370dfb7177ac494b98abc38a6e033c9d1a18c6ed7",
"md5": "7c528d5d672c3adcd7e0119a6bdb20db",
"sha256": "b5ca42c2963eeb606ee701e5e33de2f4aa5c6b34439622f5935e5de58bbc6408"
},
"downloads": -1,
"filename": "browse_to_test-0.2.19-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c528d5d672c3adcd7e0119a6bdb20db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 177184,
"upload_time": "2025-08-06T20:24:24",
"upload_time_iso_8601": "2025-08-06T20:24:24.199785Z",
"url": "https://files.pythonhosted.org/packages/44/a8/1a0ab783030f19edd69370dfb7177ac494b98abc38a6e033c9d1a18c6ed7/browse_to_test-0.2.19-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "36aaba60a46dc25fb9d0d32b8cb24828f49fac7c57e577a90130131413d1d5be",
"md5": "fd646bc8cf280de484386cacebe0e5ad",
"sha256": "cd5859a451f4ab354a924cf353a1334152e9211d331b2d60774d9879fe5dee49"
},
"downloads": -1,
"filename": "browse_to_test-0.2.19.tar.gz",
"has_sig": false,
"md5_digest": "fd646bc8cf280de484386cacebe0e5ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 238898,
"upload_time": "2025-08-06T20:24:25",
"upload_time_iso_8601": "2025-08-06T20:24:25.287186Z",
"url": "https://files.pythonhosted.org/packages/36/aa/ba60a46dc25fb9d0d32b8cb24828f49fac7c57e577a90130131413d1d5be/browse_to_test-0.2.19.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 20:24:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "browse-to-test",
"github_not_found": true,
"lcname": "browse-to-test"
}