Skip to content

Instantly share code, notes, and snippets.

View minhphong306's full-sized avatar
😄
Don't watch the clock. Do what it does! Keep going!

Phong Do minhphong306

😄
Don't watch the clock. Do what it does! Keep going!
View GitHub Profile
@minhphong306
minhphong306 / catpcha.spec.ts
Created April 8, 2026 14:40
catpcha.spec.ts
import { test, expect } from '@playwright/test';
import Tesseract from 'tesseract.js';
import fs from 'fs';
test('Giải mã Captcha bằng Tesseract OCR', async ({ page }) => {
// Bước 1: Mở trang thực hành
await page.goto('https://material.playwrightvn.com/036-captcha.html');
// Bước 2: Định vị (Locate) và Chụp ảnh (Screenshot) phần tử Captcha
const anhCaptcha = page.locator('#captcha-canvas'); // Selector id chứa ảnh captcha
@minhphong306
minhphong306 / requirement.md
Created April 8, 2026 13:59
requirement.md

Overview

Help me build a skill called "playwright-project-setup". This skill will be used to set up a new Playwright project.

Requirements

This skill contains 6 steps:

  1. Check if project is initialized or not. If not, we should run npm init -y playwright@latest
  2. Ask user for module structure, this will be used when we create the folder structure. The module structure is as follows:

For example, user has two modules: storefront, dashboard

@minhphong306
minhphong306 / helper-util.md
Created April 8, 2026 07:00
helper-util.md

Ranh giới giữa HelperUtil (Utility) thường khá mong manh, và tùy vào quy định của từng dự án mà chúng có thể được dùng thay thế cho nhau.

Tuy nhiên, nếu xét về mặt thiết kế phần mềm "chuẩn bài", mình có thể phân biệt dựa trên mục đíchngữ cảnh sử dụng như sau:


1. Sự khác biệt cốt lõi

Đặc điểm Utility (Util) Helper
@minhphong306
minhphong306 / test.spec.ts
Last active March 30, 2026 14:20
test.spec.ts
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");
})
@minhphong306
minhphong306 / content.md
Created March 29, 2026 14:51
content.md

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...


1. Functional Test Cases

@minhphong306
minhphong306 / pom.api.ts
Created March 29, 2026 11:55
pom.api.ts
import { APIRequestContext } from '@playwright/test';
const BASE_URL = '/api/todo-app/v1';
interface TodoData {
id?: number;
title?: string;
description?: string;
status?: string;
priority?: string;
@minhphong306
minhphong306 / script-lesson-07.spec.ts
Created March 27, 2026 15:32
script-lesson-07.spec.ts
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 = {
@minhphong306
minhphong306 / 01-login.spec.ts
Created March 22, 2026 15:30
Code demo pwa103
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;