import { launchElectronWithWindow, closeElectronApp, waitForAppReady, } from './playwright-automation'; import { pathToFileURL } from 'url'; /** * Example usage of the Playwright Electron automation functions * This demonstrates how other agents can interact with the desktop app */ async function exampleAutomation(): Promise { console.log('Starting Electron app automation example...'); try { const { app, window } = await launchElectronWithWindow(); console.log('App launched successfully'); const isReady = await waitForAppReady(app); if (!isReady) { console.error('App failed to become ready within timeout'); return; } console.log('App is ready for interaction'); await window.screenshot({ path: 'app-screenshot.png' }); console.log('Screenshot taken'); const title = await window.title(); console.log('App title:', title); const hasSettingsButton = await window.isVisible('button[aria-label="Settings"]').catch(() => false); console.log('Settings button visible:', hasSettingsButton); console.log('Waiting 3 seconds to observe the app...'); await window.waitForTimeout(3000); await closeElectronApp(app); console.log('App closed successfully'); } catch (error) { console.error('Error during automation:', error); process.exit(1); } } if (import.meta.url === pathToFileURL(process.argv[1]).href) { exampleAutomation().catch(console.error); } export { exampleAutomation };