test: electron firstWindow() does not work with delayed navigation (#18093)

This commit is contained in:
Max Schmitt 2022-10-14 17:36:37 +02:00 committed by GitHub
parent 2efa96a882
commit 1c1060e85b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -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')],

View File

@ -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());