diff --git a/packages/playwright-core/src/client/electron.ts b/packages/playwright-core/src/client/electron.ts index a9e90b77f2..fcabfa494f 100644 --- a/packages/playwright-core/src/client/electron.ts +++ b/packages/playwright-core/src/client/electron.ts @@ -29,7 +29,7 @@ import type { Page } from './page'; import { ConsoleMessage } from './consoleMessage'; import type { Env, WaitForEventOptions, Headers, BrowserContextOptions } from './types'; import { Waiter } from './waiter'; -import { TargetClosedError } from './errors'; +import { TargetClosedError, isTargetClosedError } from './errors'; type ElectronOptions = Omit & { env?: Env, @@ -116,7 +116,13 @@ export class ElectronApplication extends ChannelOwner {}); + try { + await this._context.close(); + } catch (e) { + if (isTargetClosedError(e)) + return; + throw e; + } } async waitForEvent(event: string, optionsOrPredicate: WaitForEventOptions = {}): Promise {