This event is issued when the application process has been terminated.
Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. console.log
or
console.dir
.
The arguments passed into console.log
are available on the ConsoleMessage event handler argument.
Usage
electronApp.on('console', async msg => {
const values = [];
for (const arg of msg.args())
values.push(await arg.jsonValue());
console.log(...values);
});
await electronApp.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
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.
This method returns browser context that can be used for setting up context-wide routing, etc.
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
.
Function to be evaluated in the main Electron process.
Optional argument to pass to pageFunction
.
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
.
Function to be evaluated in the main Electron process.
Optional
arg: anyOptional argument to pass to pageFunction
.
Optional
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.
Function to be evaluated in the main Electron process.
Optional argument to pass to pageFunction
.
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.
Function to be evaluated in the main Electron process.
Optional
arg: anyOptional argument to pass to pageFunction
.
Optional
Convenience method that waits for the first application window to be opened.
Usage
const electronApp = await electron.launch({
args: ['main.js']
});
const window = await electronApp.firstWindow();
// ...
Optional
options: { Optional
Optional
timeout?: numberMaximum 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).
Removes an event listener added by on
or addListener
.
Removes an event listener added by on
or addListener
.
Removes an event listener added by on
or addListener
.
This event is issued when the application process has been terminated.
Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. console.log
or
console.dir
.
The arguments passed into console.log
are available on the ConsoleMessage event handler argument.
Usage
electronApp.on('console', async msg => {
const values = [];
for (const arg of msg.args())
values.push(await arg.jsonValue());
console.log(...values);
});
await electronApp.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
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.
Adds an event listener that will be automatically removed after it is triggered once. See addListener
for more information about this event.
Adds an event listener that will be automatically removed after it is triggered once. See addListener
for more information about this event.
Adds an event listener that will be automatically removed after it is triggered once. See addListener
for more information about this event.
This event is issued when the application process has been terminated.
Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. console.log
or
console.dir
.
The arguments passed into console.log
are available on the ConsoleMessage event handler argument.
Usage
electronApp.on('console', async msg => {
const values = [];
for (const arg of msg.args())
values.push(await arg.jsonValue());
console.log(...values);
});
await electronApp.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
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.
Removes an event listener added by on
or addListener
.
Removes an event listener added by on
or addListener
.
Removes an event listener added by on
or addListener
.
This event is issued when the application process has been terminated.
Optional
optionsOrPredicate: { Optional
Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. console.log
or
console.dir
.
The arguments passed into console.log
are available on the ConsoleMessage event handler argument.
Usage
electronApp.on('console', async msg => {
const values = [];
for (const arg of msg.args())
values.push(await arg.jsonValue());
console.log(...values);
});
await electronApp.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
Optional
optionsOrPredicate: { Optional
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.
Optional
optionsOrPredicate: { Optional
Generated using TypeDoc
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: