electron-drive-skill
它能做什么
这个工具可以用来控制 Electron 应用。你可以在应用内点击、输入文字、截图,并运行代码来测试它。
适用场景
- ✓验证应用中的界面改动是否正常生效。
- ✓复现只在最终版本程序中出现的 bug。
- ✓测试用户第一次打开应用时看到的初始界面。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/electron-drive-skill/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“测试设置页面上的“保存”按钮。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会在一个隔离的环境中启动应用。然后,你可以发出“点击这里”或“输入这段文字”之类的指令,与应用互动,查看一切是否按预期运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Driving the Electron app
Overview
scripts/drive.mjs launches the project's Electron app under Playwright in a
background daemon and keeps it running between commands, so each action
(click, type, snapshot, screenshot, eval) is one fast shell call. Every launch
uses a scratch profile, so the agent can check a UI change or reproduce a bug
in the real app, not only in unit tests, without touching the user's data.
When to Use This Skill
- Use when you need to verify a UI change in the running Electron app.
- Use when reproducing a renderer or startup bug, or a failure that only shows up in the production build (for example a stricter CSP).
- Use when checking first-run, onboarding or settings screens.
- Use when exercising a feature end to end, including IPC through the preload bridge or code in the main process.
- Do not use it for web apps without Electron, or for multi-window flows (see Limitations).
How It Works
Step 1: Check prerequisites
scripts/drive.mjs, in this skill's directory, finds the project by the
nearest package.json, so run it from anywhere inside the project. Set DR
to its absolute path.
It needs electron and playwright-core (1.49 or later) installed in the
project. If start says either is missing, tell the user rather than
installing it yourself. Launch settings come from drive.config.json at the
project root (see Step 4); with no file, it runs electron ..
Step 2: Start, look, act, stop
DR=<this skill's directory>/scripts/drive.mjs
$DR start # last build, profile 'default'; prints status
$DR snapshot # accessibility tree: find what to click, by role and name
$DR click 'role=button[name="Get started"]'
$DR fill 'role=textbox[name="Email"]' 'test@example.com'
$DR wait 'text=Welcome'
$DR screenshot # prints a PNG path; Read it to see the window
$DR logs --lines 80 # main and renderer console, plus the config's logFile
$DR stop # ALWAYS, before finishing
- Start options:
--build: run the config'sbuildcommand first. Needed after any source change if the app runs from a build, because the build is otherwise stale;startprints its age.--fresh: wipe the scratch profile, which gives you the app's first-run state.--profile <name>: a separate scratch profile.--dev: see Step 5.
- Targets are Playwright selectors. Prefer
role=button[name="…"]fromsnapshotoutput, thentext=…, then CSS. --ends the flags. Put it before text that starts with dashes:$DR fill 'role=textbox[name="Args"]' -- --verbose.- Other commands:
select <target> <value|label>,press <key>,status,screenshot --selector <css>.$DR helplists everything.
Step 3: Run code in the app
eval <js> runs in the renderer, main <js> in the main process
(electron and process are in scope, require is not). Use a bare
expression, or a body with return. - reads the code from stdin, which
avoids quoting entirely. The result comes back as JSON, so return plain data:
a DOM node or a function comes back as undefined or {}.
To exercise IPC, call whatever the app's preload exposes through eval. That
goes through the real preload bridge, as the app's own renderer code does.
Step 4: Configure the launch (optional)
drive.config.json at the project root; every field is optional:
{
"build": "npm run build",
"args": ["."],
"env": { "APP_DATA_DIR": "{profile}/data" },
"logFile": "logs/main.log",
"dev": {
"args": ["."],
"env": { "ELECTRON_RENDERER_URL": "http://localhost:5173" },
"url": "http://localhost:5173"
}
}
args: what Electron is launched with: an app directory whosepackage.jsonmainis the built entry point, or the entry file itself.env: added to the app's environment.{profile}becomes the scratch profile directory (inenvvalues only, not inargs). This is how data kept outsideuserDatais redirected:APP_DATA_DIRis only an example name, and it has an effect only if the app reads it. Check the app's source for the variable it actually uses.logFile: a log file relative to the profile directory, shown bylogs.
If a project has no config and start fails or launches the wrong thing,
work out these values from the project's package.json and build setup,
then suggest a drive.config.json to the user.
…
常见问题
什么是“scratch profile”?
它是一个临时的、相互隔离的运行环境,应用在里面运行。这样可以确保测试不会影响你正常的数据或设置。
工具怎么知道该点击哪里,或者该输入什么?
它使用“选择器”来描述屏幕上的元素,比如按钮或文本框,这和浏览器在网页中查找元素的方式类似。
这个工具可以测试任何类型的应用吗?
不可以。这个工具只适用于用 Electron 构建的应用,不适用于普通的网页应用,也不支持多窗口流程。
详情
作者的原始描述
Launch the project's Electron app on a scratch profile and drive it: click, type, screenshot, run renderer or main-process code, read logs. Use to verify UI changes end to end.
热度
- GitHub 星标
- 48k
- 排名
- #6273
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。