From ee1bcd760b194d684c110bd39d5248a890076c31 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sun, 4 Apr 2021 14:06:30 -0700 Subject: [PATCH] docs: fix the Electron example --- docs/src/api/class-electron.md | 12 +++++++----- docs/src/api/class-electronapplication.md | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/src/api/class-electron.md b/docs/src/api/class-electron.md index 6a5489c422..d1c8283217 100644 --- a/docs/src/api/class-electron.md +++ b/docs/src/api/class-electron.md @@ -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(); })(); ``` diff --git a/docs/src/api/class-electronapplication.md b/docs/src/api/class-electronapplication.md index 0b0fd3914c..bc5b3136ef 100644 --- a/docs/src/api/class-electronapplication.md +++ b/docs/src/api/class-electronapplication.md @@ -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(); })(); ```