@zhiweiliu/playwright-generator 1.0.55 → 1.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -31
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Playwright LLM Test Case Generator
|
|
2
2
|
|
|
3
|
+
> ⚠️ **Version Notice**: Versions v1.0.1 to v1.0.55 are development builds and are not recommended for use. Please upgrade to **v1.0.56 or above** if you are still running these versions.
|
|
4
|
+
|
|
3
5
|
This module streamlines the generation of Playwright test cases by integrating with Large Language Models. While there are many AI-based test frameworks that allow test cases to be written in natural language, the following drawbacks are commonly found with these approaches.
|
|
4
6
|
|
|
5
7
|
## Table of Contents
|
|
@@ -34,6 +36,7 @@ This module streamlines the generation of Playwright test cases by integrating w
|
|
|
34
36
|
- [Qwen Models](#qwen-models-by-alibaba)
|
|
35
37
|
- [DeepSeek Models](#deepseek-models-by-deepseek-ai)
|
|
36
38
|
- [Using LM Studio](#using-lm-studio-alternative)
|
|
39
|
+
- [VS Code Extension](#vs-code-extension)
|
|
37
40
|
- [Contributing](#contributing)
|
|
38
41
|
- [Development Setup](#development-setup)
|
|
39
42
|
- [License](#license)
|
|
@@ -77,7 +80,7 @@ This project implements an npx command in TypeScript and is released as an NPM m
|
|
|
77
80
|
npx playwright-generator init
|
|
78
81
|
```
|
|
79
82
|
|
|
80
|
-
The installed module will have
|
|
83
|
+
The installed module will have rich features to facilitate your day-to-day test automation tasks.
|
|
81
84
|
|
|
82
85
|
## Prerequisites
|
|
83
86
|
|
|
@@ -132,10 +135,6 @@ project-root/
|
|
|
132
135
|
│ ├── generated.test.ts
|
|
133
136
|
│ └── helpers/ # Generated helper classes
|
|
134
137
|
│ └── *.ts
|
|
135
|
-
├── page-objects/ # Page Object Models (optional)
|
|
136
|
-
│ └── *.po.ts
|
|
137
|
-
├── utils/ # Helper utilities
|
|
138
|
-
│ └── *.ts
|
|
139
138
|
├── audit/ # Screenshots and artifacts from failed tests
|
|
140
139
|
│ └── screenshots/
|
|
141
140
|
├── .env # Environment variables (local only, ignored by Git)
|
|
@@ -304,7 +303,7 @@ npx playwright-generator generate-helper LoginHelper --model local
|
|
|
304
303
|
**Output**: The generated helper class is written to `generated/helpers/LoginHelper.ts`:
|
|
305
304
|
|
|
306
305
|
```typescript
|
|
307
|
-
import { Page } from
|
|
306
|
+
import { Page } from "@playwright/test";
|
|
308
307
|
|
|
309
308
|
/**
|
|
310
309
|
* This is a helper class for login related actions
|
|
@@ -376,17 +375,6 @@ npm run report
|
|
|
376
375
|
|
|
377
376
|
### Advanced Features
|
|
378
377
|
|
|
379
|
-
**Page Object Models (POM)**:
|
|
380
|
-
|
|
381
|
-
- Create reusable page objects in the `page-objects/` folder to improve test maintainability
|
|
382
|
-
- Example: `page-objects/login.po.ts` for login page interactions
|
|
383
|
-
- Reference page objects in your natural language test cases for better structure
|
|
384
|
-
|
|
385
|
-
**Test Utilities**:
|
|
386
|
-
|
|
387
|
-
- Helper functions available in `utils/` for common operations (wait strategies, error handling, etc.)
|
|
388
|
-
- Custom assertions and reporters can be added for specialized testing needs
|
|
389
|
-
|
|
390
378
|
**Parallel Execution**:
|
|
391
379
|
|
|
392
380
|
- Configure parallel test execution in `playwright.config.ts`
|
|
@@ -418,9 +406,8 @@ Workflow file location: `.github/workflows/playwright-tests.yml`
|
|
|
418
406
|
- Specific selectors or UI elements mentioned
|
|
419
407
|
- Expected outcomes clearly stated
|
|
420
408
|
4. **Code Review**: Always review generated code before committing
|
|
421
|
-
5. **
|
|
422
|
-
|
|
423
|
-
8. **Helper Classes**: Use `generate-helper` to create reusable helper classes for common actions, reducing duplication across test cases
|
|
409
|
+
5. **Assertions**: Be explicit about what you're asserting
|
|
410
|
+
7. **Helper Classes**: Use `generate-helper` to create reusable helper classes for common actions, reducing duplication across test cases
|
|
424
411
|
|
|
425
412
|
### Troubleshooting
|
|
426
413
|
|
|
@@ -457,11 +444,13 @@ The `local` provider sends requests to `LOCAL_LLM_URL/v1/chat/completions`, the
|
|
|
457
444
|
### 1. Install Ollama
|
|
458
445
|
|
|
459
446
|
**macOS / Linux**:
|
|
447
|
+
|
|
460
448
|
```bash
|
|
461
449
|
curl -fsSL https://ollama.com/install.sh | sh
|
|
462
450
|
```
|
|
463
451
|
|
|
464
452
|
**macOS (Homebrew)**:
|
|
453
|
+
|
|
465
454
|
```bash
|
|
466
455
|
brew install ollama
|
|
467
456
|
```
|
|
@@ -490,6 +479,7 @@ ollama pull codellama
|
|
|
490
479
|
```
|
|
491
480
|
|
|
492
481
|
To list all models you have pulled:
|
|
482
|
+
|
|
493
483
|
```bash
|
|
494
484
|
ollama list
|
|
495
485
|
```
|
|
@@ -516,17 +506,17 @@ npx playwright-generator generate --tc TC-0001
|
|
|
516
506
|
|
|
517
507
|
### Recommended Models
|
|
518
508
|
|
|
519
|
-
| Model
|
|
520
|
-
|
|
521
|
-
| `llama3`
|
|
522
|
-
| `codellama`
|
|
523
|
-
| `mistral`
|
|
524
|
-
| `llama3:8b`
|
|
525
|
-
| `deepseek-coder`
|
|
526
|
-
| `deepseek-coder-v2` | ~8.9 GB | Stronger code quality than v1
|
|
527
|
-
| `deepseek-r1`
|
|
528
|
-
| `qwen2.5-coder`
|
|
529
|
-
| `qwen2.5`
|
|
509
|
+
| Model | Size | Best For |
|
|
510
|
+
| ------------------- | ------- | ----------------------------------------- |
|
|
511
|
+
| `llama3` | ~4.7 GB | General use, good code quality |
|
|
512
|
+
| `codellama` | ~3.8 GB | Code generation tasks |
|
|
513
|
+
| `mistral` | ~4.1 GB | Fast, low memory usage |
|
|
514
|
+
| `llama3:8b` | ~8 GB | Higher quality output |
|
|
515
|
+
| `deepseek-coder` | ~3.8 GB | Code-focused, strong TypeScript |
|
|
516
|
+
| `deepseek-coder-v2` | ~8.9 GB | Stronger code quality than v1 |
|
|
517
|
+
| `deepseek-r1` | ~4.7 GB | Reasoning-focused, good for complex logic |
|
|
518
|
+
| `qwen2.5-coder` | ~4.7 GB | Strong TypeScript/code generation |
|
|
519
|
+
| `qwen2.5` | ~4.7 GB | General use, multilingual |
|
|
530
520
|
|
|
531
521
|
### Qwen Models (by Alibaba)
|
|
532
522
|
|
|
@@ -581,6 +571,37 @@ LOCAL_LLM_MODEL=Meta-Llama-3-8B-Instruct # Must match the model name shown in
|
|
|
581
571
|
|
|
582
572
|
> Note: Local models are slower than cloud APIs — expect 30–120 seconds per generation depending on hardware. No data leaves your machine.
|
|
583
573
|
|
|
574
|
+
## VS Code Extension
|
|
575
|
+
|
|
576
|
+
A VS Code extension is available to provide a graphical interface for `playwright-generator` — configure your AI model, generate test cases and helper classes, and run your tests without leaving the editor.
|
|
577
|
+
|
|
578
|
+
**Install from the Marketplace**:
|
|
579
|
+
|
|
580
|
+
[Playwright Generator — VS Code Extension](https://marketplace.visualstudio.com/items?itemName=zhiweiliu.playwright-generator-vscode)
|
|
581
|
+
|
|
582
|
+
Or search for `Playwright Generator` in the VS Code Extensions panel (`Ctrl+Shift+X`).
|
|
583
|
+
|
|
584
|
+
### Features
|
|
585
|
+
|
|
586
|
+
- **Config tab** — configure AI model credentials and Playwright settings; changes are auto-saved to `.env`
|
|
587
|
+
- **Generate tab** — browse and search test case IDs from `tests/`; generate TypeScript test code with one click
|
|
588
|
+
- **Helpers tab** — browse helper definitions from `helpers/`; see which actions have been generated and generate missing ones
|
|
589
|
+
- **Run tab** — run all tests, run by tag, run with UI, debug, and view the last HTML report
|
|
590
|
+
|
|
591
|
+
### Requirements
|
|
592
|
+
|
|
593
|
+
- A workspace initialised with `npx playwright-generator init`
|
|
594
|
+
- A `.env` file in the workspace root
|
|
595
|
+
|
|
596
|
+
### Getting Started
|
|
597
|
+
|
|
598
|
+
1. Install the extension from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=zhiweiliu.playwright-generator-vscode)
|
|
599
|
+
2. Open your `playwright-generator` project in VS Code
|
|
600
|
+
3. Click the Playwright Generator icon in the Activity Bar
|
|
601
|
+
4. Configure your AI model in the **Config** tab
|
|
602
|
+
5. Select a test case and click **Generate** in the **Generate** tab
|
|
603
|
+
6. Run your tests from the **Run** tab
|
|
604
|
+
|
|
584
605
|
## Contributing
|
|
585
606
|
|
|
586
607
|
Contributions are welcome! Please follow these guidelines:
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ const program = new commander_1.Command();
|
|
|
13
13
|
program
|
|
14
14
|
.name("playwright-generator")
|
|
15
15
|
.description("Generate Playwright test cases from natural language using LLM")
|
|
16
|
-
.version("1.0.
|
|
16
|
+
.version("1.0.56");
|
|
17
17
|
// Init command
|
|
18
18
|
program
|
|
19
19
|
.command("init [projectPath]")
|