playwright-windows-wrapper
v1.0.1
Published
A unified automation wrapper combining Playwright and Appium for hybrid web and Windows native testing.
Maintainers
Readme
playwright-windows-wrapper
A unified, hybrid test automation wrapper that bridges Playwright (for web automation) and Appium/WinAppDriver (for native Windows desktop applications). Write single-script end-to-end flows that seamlessly jump between standard browsers and native .exe applications.
🚀 Key Features
- Unified API: Control both web elements and native desktop UI components using one client interface.
- Advanced Desktop Interactions: Right-clicks, double-clicks, drag-and-drop, and hardware keyboard shortcuts (
Ctrl + A, etc.) mapped natively to Windows. - Window Controls: Maximize, minimize, and inspect native application windows easily.
🛠️ Prerequisites
Because Windows desktop automation requires access to OS-level accessibility trees, you must configure your host machine before running desktop tests:
- Enable Windows Developer Mode:
Go to Settings > Update & Security > For developers and toggle Developer Mode to On. - Install Appium Globally:
npm install -g appium
Getting Started -
Step 1: Install Playwright Test
If you haven't already initialized Playwright's testing framework in your test project (D:\test111), run:
Bash
npm i -D @playwright/test
Step 2: Create test.spec.ts
Create your test file using Playwright's test and expect syntax. You can import your custom wrapper directly into it.
TypeScript
// test.spec.ts
import { test, expect } from '@playwright/test';
import { UltimateAutomationWrapper } from 'playwright-windows-wrapper';
test('Hybrid Web and Windows Desktop Test', async ({ page }) => {
const driver = new UltimateAutomationWrapper();
// 1. Test the Desktop App (Notepad)
console.log('Launching Notepad...');
await driver.initDesktop('notepad.exe');
await driver.typeText('//*[@Name="Text Editor"]', 'Hello from Playwright Spec!');
// Assert using standard Playwright expect mechanics
const isVisible = await driver.isElementDisplayed('//*[@Name="Text Editor"]');
expect(isVisible).toBe(true);
// 2. Test the Web App (using Playwright's built-in page fixture)
console.log('Navigating to Web portal...');
await page.goto('https://duckduckgo.com');
await page.fill('#searchbox_input', 'Playwright automation');
// 3. Cleanup both layers
await driver.closeAll();
});
Step 3: Run the Spec File
Make sure your background Appium server is running (npx appium), then run your spec file using the Playwright CLI:
Bash
npx playwright test test.spec.ts --headed