docs: fix the Electron example

This commit is contained in:
Pavel Feldman 2021-04-04 14:06:30 -07:00
parent da1dafcadb
commit ee1bcd760b
2 changed files with 14 additions and 10 deletions

View File

@ -17,12 +17,12 @@ const { _electron: electron } = require('playwright');
const electronApp = await electron.launch({ args: ['main.js'] });
// Evaluation expression in the Electron context.
const appPath = await electronApp.evaluate(async (electron) => {
// This runs in the main Electron process, |electron| parameter
// here is always the result of the require('electron') in the main
// app script.
return electron.getAppPath();
const appPath = await electronApp.evaluate(async ({ app }) => {
// This runs in the main Electron process, parameter here is always
// the result of the require('electron') in the main app script.
return app.getAppPath();
});
console.log(appPath);
// Get the first window that the app opens, wait if necessary.
const window = await electronApp.firstWindow();
@ -34,6 +34,8 @@ const { _electron: electron } = require('playwright');
window.on('console', console.log);
// Click button.
await window.click('text=Click me');
// Exit app.
await electronApp.close();
})();
```

View File

@ -13,12 +13,12 @@ const { _electron: electron } = require('playwright');
const electronApp = await electron.launch({ args: ['main.js'] });
// Evaluation expression in the Electron context.
const appPath = await electronApp.evaluate(async (electron) => {
// This runs in the main Electron process, |electron| parameter
// here is always the result of the require('electron') in the main
// app script.
return electron.getAppPath();
const appPath = await electronApp.evaluate(async ({ app }) => {
// This runs in the main Electron process, parameter here is always
// the result of the require('electron') in the main app script.
return app.getAppPath();
});
console.log(appPath);
// Get the first window that the app opens, wait if necessary.
const window = await electronApp.firstWindow();
@ -30,6 +30,8 @@ const { _electron: electron } = require('playwright');
window.on('console', console.log);
// Click button.
await window.click('text=Click me');
// Exit app.
await electronApp.close();
})();
```