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