Bạn là một QA Engineer có kinh nghiệm trong testing ứng dụng thương mại điện tử.
Hãy viết test case chi tiết cho chức năng sau:
[ TÊN CHỨC NĂNG / FEATURE ] Ví dụ: Đăng ký tài khoản, Đặt hàng, Thanh toán, Tìm kiếm sản phẩm...
| import { test, expect } from '@playwright/test'; | |
| test.describe("Test suite: Material site", async () => { | |
| test.beforeAll(async () => { | |
| console.log("BeforeAll: Trước khi tất cả các test chạy"); | |
| }); | |
| test.afterAll(async () => { | |
| console.log("AfterAll: sau khi tất cả các test chạy"); | |
| }) |
| import { APIRequestContext } from '@playwright/test'; | |
| const BASE_URL = '/api/todo-app/v1'; | |
| interface TodoData { | |
| id?: number; | |
| title?: string; | |
| description?: string; | |
| status?: string; | |
| priority?: string; |
| import { test, expect } from '@playwright/test'; | |
| test("Test 1: Register page", async ({ page }) => { | |
| await test.step("Step 1: Đi đến trang material. Verify title hiển thị", async () => { | |
| await page.goto("https://material.playwrightvn.com/"); | |
| const titleLoc = page.locator("//h1"); | |
| await expect(titleLoc).toBeVisible(); | |
| }); |
| import { | |
| FullConfig, | |
| FullResult, | |
| Reporter, | |
| Suite, | |
| TestCase, | |
| TestResult | |
| } from '@playwright/test/reporter'; | |
| type TestInfo = { |
| import { test } from '@playwright/test'; | |
| test.describe("Dashboard tests", async () => { | |
| const authFile = 'playwright/.auth/user.json'; | |
| test.beforeEach(async ({ page }) => { | |
| await page.goto('https://e-commerce-dev.betterbytesvn.com/wp-login.php'); | |
| await page.getByRole('textbox', { name: 'Username or Email Address' }).click(); | |
| await page.getByRole('textbox', { name: 'Username or Email Address' }).fill(''); | |
| await page.getByRole('textbox', { name: 'Password' }).click(); |
| import { test, expect } from "@playwright/test"; | |
| import { TodoApi } from "../../src/pom/todo.api"; | |
| test("Test: chaining request", async ({ request }) => { | |
| const todoApi = new TodoApi(request); | |
| // Buoc 1: Goi API get --> id lon nhat | |
| const todos = await todoApi.getTodos(); | |
| const firstTodoId = todos[0].id; |
| import { Page, Locator } from '@playwright/test'; | |
| export class RegisterPage { | |
| // Khai báo page và các locator | |
| page: Page; | |
| usernameInput: Locator; | |
| emailInput: Locator; | |
| submitButton: Locator; | |
| constructor(page: Page) { |
End-to-end testing framework built with Playwright and TypeScript.
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <div class="container"> | |
| <!-- Form Đăng Ký --> | |
| <div class="registration-form"> | |
| <h2>Form Đăng Ký Học Viên</h2> | |
| <form id="studentForm"> | |
| <input id="fullname" name="name" type="text" placeholder="Họ và tên"> | |
| <input id="email" name="email" type="email" placeholder="Email"> |