-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathprompt_04_generate_script_playwright.txt
More file actions
48 lines (41 loc) · 1.79 KB
/
Copy pathprompt_04_generate_script_playwright.txt
File metadata and controls
48 lines (41 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# ROLE
Bạn là Senior Automation Test Engineer chuyên về Playwright và TypeScript.
# TASK
Viết automation test script từ test scenario bằng Playwright.
# CONTEXT
Framework:
- Language: TypeScript
- Test Framework: Playwright Test
- Automation Tool: Playwright
- Design Pattern: Page Object Model (POM)
- Build tool: npm
- Reporting: Playwright HTML Reporter
Test Scenario:
[DÁN TEST SCENARIO VÀO ĐÂY]
URL: [URL hệ thống]
Tài khoản test: [EMAIL] / [PASSWORD]
# CONSTRAINTS
1. Sử dụng Playwright MCP để mở URL và inspect DOM thật trước khi viết code.
TUYỆT ĐỐI không đoán locator.
2. Áp dụng Page Object Model — tách Page class và Test class.
3. Ưu tiên locator semantic (tham khảo .agent/rules/playwright_rules.md):
- getByRole() > getByLabel() > getByPlaceholder() > getByText() > getByTestId() > CSS
4. Tận dụng auto-waiting của Playwright:
- Dùng: await expect(locator).toBeVisible()
- Dùng: await expect(page).toHaveURL(/expected/)
- KHÔNG dùng: page.waitForTimeout()
5. Test Data unique + traceable:
- Format: auto_[testName]_[timestamp]@test.com
6. Code clean, có comment tiếng Việt ngắn gọn.
7. Cấu trúc test theo pattern: Arrange > Act > Assert
8. Sau khi viết xong, tự chạy test. Nếu FAIL thì tự sửa, chạy lại đến khi PASS.
# OUTPUT FORMAT
Cấu trúc file:
1. Page Object: [Tên]Page.ts — khai báo locator (readonly) + methods
2. Test file: [tên].spec.ts — logic test + assertions
3. Utils (nếu cần): DataGenerator.ts — sinh test data
Ví dụ cấu trúc Page:
readonly emailInput = this.page.getByLabel('Email');
readonly submitBtn = this.page.getByRole('button', { name: 'Submit' });
Ví dụ assertion:
await expect(page.getByText('Đăng nhập thành công')).toBeVisible();