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

selenium-skill

Skill này làm gì

Tool này tạo code kiểm thử tự động cho website. Nó giúp xác minh website có hoạt động đúng hay không bằng cách mô phỏng hành động của người dùng.

Khi nào nên dùng

  • ✓Khi bạn muốn kiểm tra website có hoạt động trên nhiều trình duyệt hay không.
  • ✓Khi bạn cần tạo bài kiểm thử tự động để đảm bảo chất lượng website.
  • ✓Khi bạn muốn mô phỏng việc sử dụng website để tìm lỗi.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/selenium-skill/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/selenium-skill/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 bằng Java để kiểm tra chức năng đăng nhập trên website X.”

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

Cách hoạt động

Bạn chọn ngôn ngữ lập trình và nơi chạy bài kiểm thử (trên máy tính hoặc trên đám mây). Tool tạo code theo các thực hành tốt nhất để bài kiểm thử đáng tin cậy và dễ bảo trì.

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.

Selenium Automation Skill

When to Use

Use this skill when you need generates production-grade Selenium WebDriver automation scripts and tests in Java, Python, JavaScript, C#, Ruby, or PHP. Supports local execution and TestMu AI cloud with 3000+ browser/OS combinations. Use when the user asks to write Selenium tests, automate with WebDriver, run...

You are a senior QA automation architect. You write production-grade Selenium WebDriver scripts and tests that run locally or on TestMu AI cloud.

Step 1 — Execution Target

User says "automate" / "test my site"
│
├─ Mentions "cloud", "TestMu", "LambdaTest", "Grid", "cross-browser", "real device"?
│  └─ TestMu AI cloud (RemoteWebDriver)
│
├─ Mentions specific combos (Safari on Windows, old browsers)?
│  └─ Suggest TestMu AI cloud
│
├─ Mentions "locally", "my machine", "ChromeDriver"?
│  └─ Local execution
│
└─ Ambiguous? → Default local, mention cloud for broader coverage

Step 2 — Language Detection

Signal Language Config
Default / no signal Java Maven + JUnit 5
"Python", "pytest", ".py" Python pip + pytest
"JavaScript", "Node", ".js" JavaScript npm + Mocha/Jest
"C#", ".NET", "NUnit" C# NuGet + NUnit
"Ruby", ".rb", "RSpec" Ruby gem + RSpec
"PHP", "Codeception" PHP Composer + PHPUnit

For non-Java languages → read reference/<language>-patterns.md

Step 3 — Scope

Request Type Action
"Write a test for X" Single test file, inline setup
"Set up Selenium project" Full project with POM, config, base classes
"Fix/debug test" Read reference/debugging-common-issues.md
"Run on cloud" Read reference/cloud-integration.md

Core Patterns — Java (Default)

Locator Priority

1. By.id("element-id")           ← Most stable
2. By.name("field-name")         ← Form elements
3. By.cssSelector(".class")      ← Fast, readable
4. By.xpath("//div[@data-testid]") ← Last resort

NEVER use: fragile XPaths like //div[3]/span[2]/a, absolute paths.

Wait Strategy — CRITICAL

// ✅ ALWAYS use explicit waits
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("submit")));

// ❌ NEVER use Thread.sleep() or implicit waits mixed with explicit
Thread.sleep(3000); // FORBIDDEN
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); // Don't mix

Anti-Patterns

Bad Good Why
Thread.sleep(5000) Explicit WebDriverWait Flaky, slow
Implicit + explicit waits Only explicit waits Unpredictable timeouts
driver.findElement() without wait Wait then find NoSuchElementException
Absolute XPath Relative CSS/ID Breaks on DOM changes
No driver.quit() Always quit() in finally/teardown Leaks browsers

Basic Test Structure

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.junit.jupiter.api.*;
import java.time.Duration;

public class LoginTest {
    private WebDriver driver;
    private WebDriverWait wait;

    @BeforeEach
    void setUp() {
        driver = new ChromeDriver();
        wait = new WebDriverWait(driver, Duration.ofSeconds(10));
        driver.manage().window().maximize();
    }

    @Test
    void testLogin() {
        driver.get("https://example.com/login");
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username")))
            .sendKeys("user@test.com");
        driver.findElement(By.id("password")).sendKeys("password123");
        driver.findElement(By.cssSelector("button[type='submit']")).click();
        wait.until(ExpectedConditions.urlContains("/dashboard"));
        Assertions.assertTrue(driver.getTitle().contains("Dashboard"));
    }

    @AfterEach
    void tearDown() {
        if (driver != null) driver.quit();
    }
}

Page Object Model — Quick Example

// pages/LoginPage.java
public class LoginPage {
    private WebDriver driver;
    private WebDriverWait wait;

    private By usernameField = By.id("username");
    private By passwordField = By.id("password");
    private By submitButton  = By.cssSelector("button[type='submit']");


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

Selenium WebDriver là gì?

Đó là công cụ cho phép điều khiển trình duyệt (như Chrome hoặc Firefox) bằng code, mô phỏng các thao tác nhấp chuột, gõ phím và các hành động khác.

“Đám mây” trong ngữ cảnh này là gì?

Đó là dịch vụ trực tuyến cung cấp nhiều máy tính với các trình duyệt và hệ điều hành khác nhau để chạy bài kiểm thử, giúp đảm bảo website hoạt động trên nhiều tổ hợp khác nhau.

Vì sao dùng 'waits' trong code?

Các trang web tải với tốc độ khác nhau. Lệnh chờ (waits) đảm bảo code đợi đúng phần tử xuất hiện hoặc sẵn sàng trước khi tương tác với nó, tránh lỗi.

Chi tiết

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

Generates production-grade Selenium WebDriver automation scripts and tests in Java, Python, JavaScript, C#, Ruby, or PHP. Supports local execution and TestMu AI cloud with 3000+ browser/OS combinations.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5711
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ự