diff --git a/docs/src/api/class-electronapplication.md b/docs/src/api/class-electronapplication.md index 6881bfee83..e848f4a6ab 100644 --- a/docs/src/api/class-electronapplication.md +++ b/docs/src/api/class-electronapplication.md @@ -135,6 +135,14 @@ Convenience method that waits for the first application window to be opened. // ... ``` +### option: ElectronApplication.firstWindow.timeout +* since: v1.33 +- `timeout` ?<[float]> + +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 +[`method: BrowserContext.setDefaultTimeout`]. + ## method: ElectronApplication.process * since: v1.21 - returns: <[ChildProcess]> diff --git a/packages/playwright-core/src/client/electron.ts b/packages/playwright-core/src/client/electron.ts index dfdfbb8664..2a4d2d7f3e 100644 --- a/packages/playwright-core/src/client/electron.ts +++ b/packages/playwright-core/src/client/electron.ts @@ -95,10 +95,10 @@ export class ElectronApplication extends ChannelOwner { + async firstWindow(options?: { timeout?: number }): Promise { if (this._windows.size) return this._windows.values().next().value; - return this.waitForEvent('window'); + return this.waitForEvent('window', options); } context(): BrowserContext { diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 0594a9a1b6..99337e9769 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -13402,8 +13402,16 @@ export interface ElectronApplication { * // ... * ``` * + * @param options */ - firstWindow(): Promise; + firstWindow(options?: { + /** + * 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)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout). + */ + timeout?: number; + }): Promise; /** * Returns the main process for this Electron Application.