Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: electron firstWindow() does not work with delayed navigation (#18093)
Max Schmitt1c1060e85bd9
diff --git a/tests/electron/electron-app.spec.ts b/tests/electron/electron-app.spec.tsindex 5f6ed031f6..27c8e78cf9 100644--- a/tests/electron/electron-app.spec.ts+++ b/tests/electron/electron-app.spec.ts@@ -181,6 +181,19 @@ test('should record video', async ({ playwright }, testInfo) => {expect(fs.statSync(videoPath).size).toBeGreaterThan(0);});+test('should be able to get the first window when with a delayed navigation', async ({ playwright }) => {+ test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/17765' });+ test.fixme();++ const app = await playwright._electron.launch({+ args: [path.join(__dirname, 'electron-window-app-delayed-loadURL.js')],+ });+ const page = await app.firstWindow();+ await expect(page).toHaveURL('data:text/html,<h1>Foobar</h1>');+ await expect(page.locator('h1')).toHaveText('Foobar');+ await app.close();+});+test('should detach debugger on app-initiated exit', async ({ playwright }) => {const electronApp = await playwright._electron.launch({args: [path.join(__dirname, 'electron-app.js')],diff --git a/tests/electron/electron-window-app-delayed-loadURL.js b/tests/electron/electron-window-app-delayed-loadURL.jsnew file mode 100644index 0000000000..d94f6f8fee--- /dev/null+++ b/tests/electron/electron-window-app-delayed-loadURL.js@@ -0,0 +1,13 @@+const { app, BrowserWindow } = require('electron');++app.whenReady().then(() => {+ const win = new BrowserWindow({+ width: 800,+ height: 600,+ });+ setTimeout(() => {+ win.loadURL('data:text/html,<h1>Foobar</h1>');+ }, 2_000);+})++app.on('window-all-closed', e => e.preventDefault());