diff --git a/tests/electron/electron-app.spec.ts b/tests/electron/electron-app.spec.ts index 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,

Foobar

'); + 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.js new file mode 100644 index 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,

Foobar

'); + }, 2_000); +}) + +app.on('window-all-closed', e => e.preventDefault());