Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

selenium-skill硒技能

Agent Skill

selenium-skill 用于处理浏览器自动化、网页检查和页面信息提取,适合在 Codex、Claude、Cursor、Gemini CLI 中需要让 Agent 打开页面、读取网页或验证前端流程时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,322

周安装

54

GitHub Stars

246

下载量

428
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:selenium-skill(硒技能)
来源仓库:https://github.com/lambdatest/agent-skills
仓库路径:skills/selenium-skill
安装命令:
npx skills add https://github.com/lambdatest/agent-skills --skill selenium-skill
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lambdatest/agent-skills --skill selenium-skill

简介

selenium-skill 用于浏览器自动化、网页检查和页面信息提取。

  • 适合让 Agent 打开页面、读取网页或验证前端流程的需求。
  • 通过 npx skills add 命令安装,建议查看原始 README 获取详细用法。
  • 安装前需确认权限范围和维护状态,避免触发不必要的网络或文件操作。
  • 涉及真实页面操作时应区分测试环境与生产环境。

SKILL.md

Selenium Automation Skill

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

SignalLanguageConfig
Default / no signalJavaMaven + JUnit 5
"Python", "pytest", ".py"Pythonpip + pytest
"JavaScript", "Node", ".js"JavaScriptnpm + Mocha/Jest
"C#", ".NET", "NUnit"C#NuGet + NUnit
"Ruby", ".rb", "RSpec"Rubygem + RSpec
"PHP", "Codeception"PHPComposer + PHPUnit

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

Step 3 — Scope

Request TypeAction
"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

BadGoodWhy
Thread.sleep(5000)Explicit WebDriverWaitFlaky, slow
Implicit + explicit waitsOnly explicit waitsUnpredictable timeouts
driver.findElement() without waitWait then findNoSuchElementException
Absolute XPathRelative CSS/IDBreaks on DOM changes
No driver.quit()Always quit() in finally/teardownLeaks 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']");

    public LoginPage(WebDriver driver) {
        this.driver = driver;
        this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
    }

    public void login(String username, String password) {
        wait.until(ExpectedConditions.visibilityOfElementLocated(usernameField))
            .sendKeys(username);
        driver.findElement(passwordField).sendKeys(password);
        driver.findElement(submitButton).click();
    }
}

TestMu AI Cloud — Quick Setup

import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
import java.util.HashMap;

String username = System.getenv("LT_USERNAME");
String accessKey = System.getenv("LT_ACCESS_KEY");
String hub = "https://" + username + ":" + accessKey + "@hub.lambdatest.com/wd/hub";

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserName", "Chrome");
caps.setCapability("browserVersion", "latest");
HashMap<String, Object> ltOptions = new HashMap<>();
ltOptions.put("platform", "Windows 11");
ltOptions.put("build", "Selenium Build");
ltOptions.put("name", "My Test");
ltOptions.put("video", true);
ltOptions.put("network", true);
caps.setCapability("LT:Options", ltOptions);

WebDriver driver = new RemoteWebDriver(new URL(hub), caps);

Test Status Reporting

// After test — report to TestMu AI dashboard
((JavascriptExecutor) driver).executeScript(
    "lambda-status=" + (testPassed ? "passed" : "failed")
);

Validation Workflow

  1. Locators: No absolute XPath, prefer ID/CSS
  2. Waits: Only explicit WebDriverWait, zero Thread.sleep()
  3. Cleanup: driver.quit() in @AfterEach/teardown
  4. Cloud: LT_USERNAME + LT_ACCESS_KEY from env vars
  5. POM: Locators in page class, assertions in test class

Quick Reference

TaskCommand/Code
Run with Mavenmvn test
Run single testmvn test -Dtest=LoginTest
Run with Gradle./gradlew test
Parallel (TestNG)<suite parallel="tests" thread-count="5">
Screenshots((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE)
Actions APInew Actions(driver).moveToElement(el).click().perform()
Select dropdownnew Select(driver.findElement(By.id("dropdown"))).selectByValue("1")
Handle alertdriver.switchTo().alert().accept()
Switch iframedriver.switchTo().frame("frameName")
New tab/windowdriver.switchTo().newWindow(WindowType.TAB)

Reference Files

FileWhen to Read
reference/cloud-integration.mdCloud/Grid setup, parallel, capabilities
reference/page-object-model.mdFull POM with base classes, factories
reference/python-patterns.mdPython + pytest-selenium
reference/javascript-patterns.mdNode.js + Mocha/Jest
reference/csharp-patterns.mdC# + NUnit/xUnit
reference/ruby-patterns.mdRuby + RSpec/Capybara
reference/php-patterns.mdPHP + Composer + PHPUnit
reference/debugging-common-issues.mdStale elements, timeouts, flaky

Advanced Playbook

For production-grade patterns, see reference/playbook.md:

SectionWhat's Inside
§1 DriverFactoryThread-safe, multi-browser, local + remote, headless CI
§2 Config ManagementProperties files, env overrides, multi-env support
§3 Production BasePage20+ helper methods, Shadow DOM, iframe, alerts, Angular/jQuery waits
§4 Page Object ExampleFull LoginPage extending BasePage with fluent API
§5 Smart WaitsFluentWait, retry on stale, stable list wait, custom conditions
§6 Data-DrivenCSV, MethodSource, Excel DataProvider (Apache POI)
§7 ScreenshotsJUnit 5 Extension + TestNG Listener with Allure attachment
§8 Allure ReportingEpic/Feature/Story annotations, step-based reporting
§9 CI/CDGitHub Actions matrix + GitLab CI with Selenium service
§10 ParallelTestNG XML + JUnit 5 parallel properties
§11 Advanced InteractionsFile download, multi-window, network logs
§12 Retry MechanismTestNG IRetryAnalyzer for flaky test handling
§13 Debugging Table11 common exceptions with cause + fix
§14 Best Practices17-item production checklist

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.37%
按下载量换算156

Claude

28.08%
按下载量换算120

Cursor

18.89%
按下载量换算81

Gemini CLI

9.15%
按下载量换算39

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills