Chuyển đến nội dung
Skillpedia
Kiểm thử48k · #5456

playwright-java

Skill này làm gì

Công cụ này giúp tạo các bài kiểm thử tự động để kiểm tra một website có hoạt động đúng không. Nó tổ chức mã để việc bảo trì và cộng tác dễ dàng hơn trong các dự án lớn.

Khi nào nên dùng

  • ✓Khi bắt đầu một dự án kiểm thử website mới.
  • ✓Khi viết mã để kiểm thử các tính năng cụ thể của website.
  • ✓Khi bạn cần báo cáo chi tiết về các bài kiểm thử.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/playwright-java/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/playwright-java/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một bài kiểm thử tự động cho trang đăng nhập bằng mẫu Page Object Model.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng một mẫu gọi là “Page Object Model” để tổ chức mã. Mỗi trang của website được biểu diễn thành một đối tượng trong mã, và các bài kiểm thử tương tác với các đối tượng này.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Supporting material availability

This catalog copy contains the inline guidance below, but does not include the following supporting paths. They are external prerequisites, not bundled files:

  • <support-root>/references/config.md
  • <support-root>/references/page-objects.md
  • <support-root>/references/assertions.md
  • <support-root>/references/fixtures.md
  • <support-root>/templates/BaseTest.java
  • <support-root>/templates/BasePage.java
  • src/test/resources/junit-platform.properties

Ask for the original supporting material or an existing installation before using a step that depends on these paths; this catalog does not identify a verified download source for them. Resolve each path relative to that installation, inspect its contents, and verify any applicable license and execution prerequisites. Do not run a command or claim a referenced procedure was followed until its required file exists. Do not fabricate the missing scripts or treat an unrelated file with the same name as equivalent. Independent steps fully documented here can proceed within the user’s authorized scope; report any dependent step as unavailable.

Playwright Java – Advanced Test Automation

Overview

This skill produces production-quality, enterprise-grade Playwright Java test code. It enforces the Page Object Model (POM), strict locator strategies, thread-safe parallel execution, and full Allure reporting integration. Targets Java 17+ and Playwright 1.44+.

Supporting reference files are available for deeper topics:

Topic File
Maven POM, ConfigReader, Docker/CI setup references/config.md
Component pattern, dropdowns, uploads, waits references/page-objects.md
Full assertion API, soft assertions, visual testing references/assertions.md
Fixtures, test data factory, auth state, retry references/fixtures.md
Drop-in base class templates templates/BaseTest.java, templates/BasePage.java

When to Use This Skill

  • Use when scaffolding a new Playwright Java project from scratch
  • Use when writing Page Object classes or JUnit 5 test classes
  • Use when the user asks about cross-browser testing, parallel execution, or Allure reports
  • Use when fixing flaky tests or replacing Thread.sleep() with proper waits
  • Use when setting up Playwright in CI/CD pipelines (GitHub Actions, Jenkins, Docker)
  • Use when combining API calls and UI assertions in a single test (hybrid testing)
  • Use when the user mentions "POM pattern", "BrowserContext", "Playwright fixtures", or "traces"

How It Works

Step 1: Decide the Approach

Use this matrix to pick the right pattern before writing any code:

User Request Approach
New project from scratch Full scaffold — see references/config.md
Single feature test POM page class + JUnit5 test class
API + UI hybrid APIRequestContext alongside Page
Cross-browser @MethodSource parameterized over browser names
Flaky test fix Replace sleep with waitFor / waitForResponse
CI integration playwright install --with-deps in pipeline
Parallel execution junit-platform.properties + ThreadLocal
Rich reporting Allure + Playwright trace + video recording

Step 2: Scaffold the Project Structure

Always use this layout when creating a new project:

src/
├── test/
│   ├── java/com/company/tests/
│   │   ├── base/
│   │   │   ├── BaseTest.java        ← templates/BaseTest.java
│   │   │   └── BasePage.java        ← templates/BasePage.java
│   │   ├── pages/
│   │   │   └── LoginPage.java
│   │   ├── tests/
│   │   │   └── LoginTest.java
│   │   ├── utils/
│   │   │   ├── TestDataFactory.java
│   │   │   └── WaitUtils.java
│   │   └── config/
│   │       └── ConfigReader.java
│   └── resources/
│       ├── test.properties
│       ├── junit-platform.properties
│       └── testdata/users.json
pom.xml

Step 3: Set Up Thread-Safe BaseTest

public class BaseTest {
    protected static ThreadLocal<Playwright>     playwrightTL = new ThreadLocal<>();
    protected static ThreadLocal<Browser>        browserTL    = new ThreadLocal<>();
    protected static ThreadLocal<BrowserContext> contextTL    = new ThreadLocal<>();
    protected static ThreadLocal<Page>           pageTL       = new ThreadLocal<>();

    protected Page page() { return pageTL.get(); }

    @BeforeEach
    void setUp() {
        Playwright playwright = Playwright.create();

…
Câu hỏi thường gặp

“Page Object Model” là gì?

Đây là cách tổ chức mã kiểm thử, trong đó mỗi trang web (hoặc một phần của nó) trở thành một đối tượng trong mã. Điều này giúp bài kiểm thử dễ đọc và dễ bảo trì hơn.

“Parallel tests” là gì?

Nghĩa là chạy nhiều bài kiểm thử cùng lúc, giúp quá trình kiểm tra website nhanh hơn.

“Allure reports” là gì?

Đây là các báo cáo trực quan và chi tiết cho thấy kết quả của từng bài kiểm thử, bao gồm các bước, ảnh chụp màn hình và nhật ký.

Chi tiết

Mô tả gốc của tác giả

Scaffold, write, debug, and enhance enterprise-grade Playwright E2E tests in Java using Page Object Model, JUnit 5, Allure reporting, and parallel execution.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5456
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự