mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: fix the Electron example
This commit is contained in:
parent
da1dafcadb
commit
ee1bcd760b
@ -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();
|
||||
})();
|
||||
```
|
||||
|
||||
|
@ -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();
|
||||
})();
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user