- Test Case ID: TC_API_[MODULE]_[NUMBER]
- Test Case Name: [Descriptive name]
- Module/Feature: [Feature name]
- API Endpoint: [Endpoint path]
- HTTP Method: [GET/POST/PUT/DELETE/PATCH]
- Priority: [Critical/High/Medium/Low]
- Type: [Functional/Security/Performance/Integration]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { expect, test } from '@playwright/test' | |
| test.describe('Simple suite to test report', async () => { | |
| test("Simple suite - 01", async ({ page }) => { | |
| await test.step("Step 1: Go to login site", async () => { | |
| await page.goto("https://e-commerce-dev.betterbytesvn.com/wp-login.php"); | |
| // expect điều kiện trang load xong | |
| const usernameInput = page.locator("//input[@id='user_login']"); | |
| await expect(usernameInput).toBeFocused(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { chromium } = require('playwright'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| async function downloadAndCheckFile() { | |
| const downloadPath = path.join(__dirname, 'downloads'); | |
| // Create downloads directory if it doesn't exist | |
| if (!fs.existsSync(downloadPath)) { | |
| fs.mkdirSync(downloadPath, { recursive: true }); |
Mock API (API giả lập) là một phiên bản giả của API thực, được tạo ra để mô phỏng hành vi và phản hồi của API thật mà không cần kết nối đến server backend thực tế. Mock API trả về dữ liệu mẫu đã được định nghĩa trước thay vì dữ liệu thực từ database hay các service khác.
Giả sử bạn đang phát triển một ứng dụng quản lý sản phẩm:
API thực:
Trả lời: Selenium WebDriver là một công cụ automation testing mã nguồn mở, cho phép tương tác trực tiếp với trình duyệt web thông qua các API native của browser. WebDriver hỗ trợ nhiều ngôn ngữ lập trình như Java, Python, C#, Ruby và JavaScript.
Ví dụ code Java:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { test, expect, Page } from '@playwright/test'; | |
| import { faker } from '@faker-js/faker'; | |
| import path from 'path'; | |
| test.describe('Lesson 02 - Ex 01', async () => { | |
| const baseUrl = 'https://material.playwrightvn.com/'; | |
| const registerData = { | |
| username: faker.person.fullName(), | |
| email: faker.internet.email(), |
NewerOlder