electron-playwright
БесплатноБез исполняемых скриптовНе проверенUse whenever an Electron desktop app needs end-to-end tests, or a Spectron suite must be migrated: Playwright's _electron.launch, renderer windows as Pages…
от testland★ 18 звёзд на GitHubОб этом скилле
electron-playwright
Overview
Playwright ships a first-class _electron namespace that launches a
packaged Electron app by executablePath and drives both the main
process (Node.js, IPC, native modules) and renderer windows
(Chromium DOMs) from a single test (pwelectron). Per
Electron's own automated-testing tutorial (electrontest),
Playwright is one of three sanctioned test stacks (alongside WebdriverIO
and Selenium) for modern Electron projects.
Differentiation: unlike playwright-testing (which drives a running
Chromium / Firefox / WebKit browser via the browser / context / page
namespaces), electron-playwright uses the separate _electron namespace to
launch a packaged binary by path and probe the main process via
electronApp.evaluate() (pwelectronapp). Renderer-side page
patterns (Page Object, accessibility-first locators, trace viewer) carry over.
For legacy Spectron suites, see
references/spectron-migration.md; for the
strategic frame, desktop-test-strategy-reference.
When to use
- New Electron desktop app - pick Playwright
_electronas the modern default per electrontest. - Existing Electron suite still on Spectron - see the migration shopping list in references/spectron-migration.md.
- Tests need to assert main-process state (e.g.,
app.isPackaged,BrowserWindowcount, IPC channel payloads) in addition to renderer DOM. - Tests need to exercise packaged-app behaviour (file associations, single-instance lock, custom protocol handlers) that is unreachable from browser-only Playwright.
Step 1 - Install
Per electrontest:
npm install --save-dev @playwright/test
Playwright's _electron module is bundled inside playwright /
@playwright/test - no extra package is needed
(pwelectron). Supported Electron versions per
pwelectron: "Electron v12.2.0+, v13.4.0+, and v14+".
Step 2 - Author the first test
The canonical example from electrontest:
import { test, expect, _electron as electron } from '@playwright/test';
test('app launches and is not packaged in dev', async () => {
const electronApp = await electron.launch({ args: ['.'] });
// Main-process assertion: probe the Electron `app` module
const isPackaged = await electronApp.evaluate(async ({ app }) => {
return app.isPackaged;
});
expect(isPackaged).toBe(false);
// Renderer assertion: take a screenshot of the first window
const window = await electronApp.firstWindow();
await window.screenshot({ path: 'intro.png' });
await electronApp.close();
});
What's going on:
electron.launch({ args: ['.'] })launches Electron with the current directory as the main-script argument (pwelectron). For a packaged app, passexecutablePathto the packaged binary instead - its default per pwelectron isnode_modules/.bin/electron.electronApp.evaluate(pageFunction)runspageFunctioninside the main process; the first argument is "always the result of therequire('electron')in the main app script" (pwelectronapp).electronApp.firstWindow()"waits for the first application window to be opened" (pwelectronapp) and returns a PlaywrightPage- every standardplaywright-testinglocator (getByRole,getByLabel) works on it.
Step 3 - Launching a packaged binary
For tests of the packaged app (the artifact users install):
import path from 'node:path';
import { _electron as electron } from '@playwright/test';
const PACKAGED_BIN = process.platform === 'win32'
? path.resolve('dist/win-unpacked/MyApp.exe')
: process.platform === 'darwin'
? path.resolve('dist/mac/MyApp.app/Contents/MacOS/MyApp')
: path.resolve('dist/linux-unpacked/myapp');
const electronApp = await electron.launch({
executablePath: PACKAGED_BIN,
args: [],
env: { ...process.env, NODE_ENV: 'test' },
recordVideo: { dir: 'test-results/videos' },
});
The executablePath, env, cwd, recordVideo, recordHar, and
timeout options are documented on the _electron launch reference
(pwelectron).
Step 4 - Probing main + renderer in one test
Multi-surface assertion - main process owns app lifecycle, renderer owns DOM:
test('opening a project loads it into the renderer', async () => {
const electronApp = await electron.launch({ args: ['.'] });
const window = await electronApp.firstWindow();
// Renderer-side action via Playwright Page API
await window.getByRole('button', { name: /op
Установить electron-playwright в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл electron-playwright?
Use whenever an Electron desktop app needs end-to-end tests, or a Spectron suite must be migrated: Playwright's _electron.launch, renderer windows as Pages, main-process checks via electronApp.evaluate, and IPC and DOM assertions from one suite.
Как установить скилл electron-playwright?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл electron-playwright запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic