testdriver-e2e-testing
它能做什么
TestDriver 可以帮助你创建自动化测试,检查你的网站或应用是否按预期工作。它会模拟真实用户与界面的交互,发现 bug,并构建测试来防止这些 bug 再次出现。
适用场景
- ✓当你需要为网站或应用编写自动化测试时。
- ✓当某个用户流程难以用传统方法自动化时。
- ✓当你想确保某个特定页面或功能正常工作时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/testdriver-e2e-testing/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我创建一个自动化测试,检查我网站的登录表单是否正常工作。”
每周 5 个新技能,1 分钟读完。
工作原理
你需要在项目中安装 TestDriver,然后用自然语言描述界面应该做什么来编写测试。TestDriver 会在安全的环境中运行这些测试,并报告发现的所有问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
TestDriver End-to-End Testing
Overview
TestDriver is an AI code reviewer that actually runs your app. It automatically runs every pull request in a real desktop sandbox, finds bugs, and builds regression tests. Tests control browsers and native applications using natural language element descriptions and AI vision, and run as Vitest suites. This skill teaches an agent how to author, run, and debug TestDriver tests.
When to Use This Skill
- Use when you need to write an end-to-end test for a web or desktop application
- Use when automating a UI workflow that has no stable selectors (canvas, Electron, native apps)
- Use when the user asks to verify that a page or flow works ("check if the login page works")
- Use when debugging a failing TestDriver test
How It Works
Step 1: Set up the project
npx testdriverai init
This scaffolds package.json, example tests, vitest.config.mjs, and a GitHub Actions workflow. The user must set TD_API_KEY in .env (get a key at https://console.testdriver.ai/team).
Step 2: Write a test
Tests are Vitest suites using the TestDriver hooks:
import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";
describe("Login", () => {
it("signs in successfully", async (context) => {
const testdriver = TestDriver(context);
await testdriver.provision.chrome({ url: "https://example.com/login" });
const email = await testdriver.find("email input field");
await email.click();
await testdriver.type("user@example.com");
const submit = await testdriver.find("Sign In button");
await submit.click();
const result = await testdriver.assert("the dashboard is visible");
expect(result).toBeTruthy();
});
});
Step 3: Run and iterate
vitest run tests/login.test.mjs
Screenshots are captured automatically before and after every command and saved to .testdriver/screenshots/, named with the source line number for easy debugging.
Examples
Example 1: Testing a desktop (Electron) app
await testdriver.provision.electron({ appPath: "./dist/my-app" });
const menu = await testdriver.find("File menu in the menu bar");
await menu.click();
Example 2: Waiting for slow elements
const done = await testdriver.find("Loading complete indicator", { timeout: 30000 });
await done.click();
Best Practices
- ✅ Use specific element descriptions ("blue Sign In button in the header", not "button")
- ✅ Set both
testTimeoutandhookTimeoutto 900000 invitest.config.mjs - ✅ Add
assert()calls for verifiable pass/fail conditions - ✅ Always
awaitevery TestDriver call - ❌ Do not use
npx vitest; runvitest rundirectly - ❌ Do not rely on CSS selectors; TestDriver locates elements visually
Limitations
- Requires a TestDriver API key (
TD_API_KEY) and network access to provision sandboxes. - Only works with Vitest as the test runner.
- This skill does not replace environment-specific validation, testing, or expert review.
Security & Safety Notes
npx testdriverai initwrites project files to the current directory; run it only in a project you intend to modify.- The
TD_API_KEYcredential belongs in.env(gitignored by the scaffold). Never commit it. - Tests execute inside an isolated remote sandbox, not on the local machine.
Common Pitfalls
- Problem: Cleanup hooks fail with a 10s timeout.
Solution: Set
hookTimeout: 900000invitest.config.mjs; sandbox teardown and recording uploads take longer than Vitest's default. - Problem: Scrolling does nothing. Solution: An input field has focus. Press Escape or click the page background first, then scroll.
Related Skills
@webapp-testing- Playwright-based alternative for local web apps with stable DOM selectors
常见问题
我需要特殊的密钥才能使用吗?
需要。你需要一个 TestDriver API key,可以从它的官网获取,并安全地配置到你的项目中。
测试在哪里运行?
测试运行在云端一个安全、隔离的环境中,而不是你的本地电脑上,以确保安全。
可以用于任何类型的应用吗?
它主要为网页和桌面应用设计,尤其适用于界面元素没有容易找到的标识符的情况。
详情
作者的原始描述
Build E2E tests with TestDriver.ai, the AI code reviewer that runs every pull request in a real desktop sandbox, finds bugs, and builds regression tests
热度
- GitHub 星标
- 48k
- 排名
- #5972
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。