Version: 1.10.0


Electron application representation. You can use electron.launch([options]) to obtain the application instance. This instance you can control main electron process as well as work with Electron windows:

const { _electron: electron } = require('playwright');
(async () => {
// Launch Electron app.
const electronApp = await electron.launch({ args: ['main.js'] });
// Evaluation expression in the Electron context.
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();
// Get the first window that the app opens, wait if necessary.
const window = await electronApp.firstWindow();
// Print the title.
console.log(await window.title());
// Capture a screenshot.
await window.screenshot({ path: 'intro.png' });
// Direct Electron console to Node terminal.
window.on('console', console.log);
// Click button.
await'text=Click me');
// Exit app.
await electronApp.close();


This event is issued when the application closes.


This event is issued for every window that is created and loaded in Electron. It contains a Page that can be used for Playwright automation.


Closes Electron application.


This method returns browser context that can be used for setting up context-wide routing, etc.

electronApplication.evaluate(pageFunction[, arg])#

  • pageFunction <function|Electron> Function to be evaluated in the worker context.
  • arg <[EvaluationArgument]> Optional argument to pass to pageFunction.
  • returns: <Promise<Serializable>>

Returns the return value of pageFunction.

If the function passed to the electronApplication.evaluate(pageFunction[, arg]) returns a Promise, then electronApplication.evaluate(pageFunction[, arg]) would wait for the promise to resolve and return its value.

If the function passed to the electronApplication.evaluate(pageFunction[, arg]) returns a non-Serializable value, then electronApplication.evaluate(pageFunction[, arg]) returns undefined. Playwright also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity.

electronApplication.evaluateHandle(pageFunction, arg)#

Returns the return value of pageFunction as a JSHandle.

The only difference between electronApplication.evaluate(pageFunction[, arg]) and electronApplication.evaluateHandle(pageFunction, arg) is that electronApplication.evaluateHandle(pageFunction, arg) returns JSHandle.

If the function passed to the electronApplication.evaluateHandle(pageFunction, arg) returns a Promise, then electronApplication.evaluateHandle(pageFunction, arg) would wait for the promise to resolve and return its value.


Convenience method that waits for the first application window to be opened. Typically your script will start with:

const electronApp = await electron.launch({
args: ['main.js']
const window = await electronApp.firstWindow();
// ...

electronApplication.waitForEvent(event[, optionsOrPredicate])#

  • event <string> Event name, same one typically passed into *.on(event).
  • optionsOrPredicate <function|Object> Either a predicate that receives an event or an options object. Optional.
    • predicate <function> receives the event data and resolves to truthy value when the waiting should resolve.
    • timeout <number> maximum time to wait for in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout(timeout).
  • returns: <Promise<Object>>

Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the application is closed before the event is fired. Returns the event data value.

const [window] = await Promise.all([

Convenience method that returns all the opened windows.