Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- playwright
|
| 5 |
+
- test-automation
|
| 6 |
+
- qa
|
| 7 |
+
- e2e-testing
|
| 8 |
+
- rag
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
datasets:
|
| 11 |
+
- web-test-examples
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Playwright Test Automator
|
| 15 |
+
|
| 16 |
+
A specialized model for automated generation of Playwright E2E test scripts based on web application crawl data.
|
| 17 |
+
|
| 18 |
+
## Overview
|
| 19 |
+
|
| 20 |
+
Playwright Test Automator is built on a RAG-based architecture that combines AI-powered test generation with Playwright's robust browser automation capabilities. The model is designed to generate reliable, maintainable, and efficient end-to-end tests with minimal human intervention.
|
| 21 |
+
|
| 22 |
+
## Features
|
| 23 |
+
|
| 24 |
+
- **Automated Crawling**: Intelligently crawls web applications to discover interactive elements and page structures
|
| 25 |
+
- **Smart Login Detection**: Automatically identifies login forms and credentials fields
|
| 26 |
+
- **Robust Selector Generation**: Creates resilient selectors that withstand minor UI changes
|
| 27 |
+
- **Error Handling**: Implements comprehensive error handling for reliable test execution
|
| 28 |
+
- **Validation Framework**: Integrated with Giskard for model validation and continuous improvement
|
| 29 |
+
|
| 30 |
+
## Use Cases
|
| 31 |
+
|
| 32 |
+
- Generating regression test suites for web applications
|
| 33 |
+
- Automating QA workflows for small to large web projects
|
| 34 |
+
- Creating test scripts for complex user journeys
|
| 35 |
+
- Validating forms and interactive elements across browsers
|
| 36 |
+
|
| 37 |
+
## Requirements
|
| 38 |
+
|
| 39 |
+
- Python 3.11+
|
| 40 |
+
- Playwright
|
| 41 |
+
- OpenAI API access
|
| 42 |
+
- Supabase for knowledge retrieval (optional)
|
| 43 |
+
|
| 44 |
+
## Example Usage
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
from services.crawler_service import crawler_service
|
| 48 |
+
|
| 49 |
+
# Crawl a website and generate tests
|
| 50 |
+
test_result = await crawler_service.crawl_with_login(
|
| 51 |
+
url="https://example.com/login",
|
| 52 |
+
username="test_user",
|
| 53 |
+
password="password123"
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Generate a Playwright test from the crawl data
|
| 57 |
+
test_code = await crawler_service.generate_test_from_crawl_data(test_result)
|
| 58 |
+
|
| 59 |
+
# Write the test to a file
|
| 60 |
+
with open("example_test.spec.js", "w") as f:
|
| 61 |
+
f.write(test_code["code"])
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## Sample Generated Test
|
| 65 |
+
|
| 66 |
+
```javascript
|
| 67 |
+
// Example E2E Test
|
| 68 |
+
// Automated test for Example Application
|
| 69 |
+
// Auto-generated by Playwright Test Automator
|
| 70 |
+
|
| 71 |
+
import { test, expect } from '@playwright/test';
|
| 72 |
+
|
| 73 |
+
test('Example E2E Test', async ({ page }) => {
|
| 74 |
+
// Configure viewport for better element visibility
|
| 75 |
+
await page.setViewportSize({ width: 1280, height: 800 });
|
| 76 |
+
|
| 77 |
+
// Helper function for safer element interactions
|
| 78 |
+
async function safeClick(selector, description) {
|
| 79 |
+
// Implementation details...
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
// Navigate to the application
|
| 83 |
+
await page.goto('https://example.com/login');
|
| 84 |
+
|
| 85 |
+
// Login process
|
| 86 |
+
await page.fill("input[type='text'][name='username']", "test_user");
|
| 87 |
+
await page.fill("input[type='password']", "password123");
|
| 88 |
+
await safeClick("button[type='submit']", "login button");
|
| 89 |
+
|
| 90 |
+
// Verify successful login
|
| 91 |
+
await expect(page).toHaveURL(/dashboard/);
|
| 92 |
+
});
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
## Limitations
|
| 96 |
+
|
| 97 |
+
- Best performance on standard web forms and common UI patterns
|
| 98 |
+
- May require adjustments for highly dynamic or custom UI frameworks
|
| 99 |
+
- Requires valid credentials for protected areas of applications
|
| 100 |
+
|
| 101 |
+
## Training Methodology
|
| 102 |
+
|
| 103 |
+
This model was trained on a diverse set of web applications using a specialized dataset of high-quality test scripts. The training process included:
|
| 104 |
+
|
| 105 |
+
1. Web crawling of various application types
|
| 106 |
+
2. Test generation with OpenAI integration
|
| 107 |
+
3. Validation using Giskard framework
|
| 108 |
+
4. Iterative improvements based on execution results
|
| 109 |
+
|
| 110 |
+
## Citation
|
| 111 |
+
|
| 112 |
+
```
|
| 113 |
+
@misc{playwright-test-automator,
|
| 114 |
+
author = {QA RAG App Team},
|
| 115 |
+
title = {Playwright Test Automator},
|
| 116 |
+
year = {2025},
|
| 117 |
+
publisher = {Hugging Face},
|
| 118 |
+
journal = {HuggingFace Hub},
|
| 119 |
+
howpublished = {\url{https://huggingface.co/playwright-test-automator}}
|
| 120 |
+
}
|
| 121 |
+
```
|