@serenity-js/playwright
Version:
Adapter that integrates @serenity-js/web with Playwright, enabling Serenity/JS reporting and using the Screenplay Pattern to write component and end-to-end test scenarios
52 lines • 2.39 kB
TypeScript
import type { BrowserCapabilities } from '@serenity-js/web';
import type * as playwright from 'playwright-core';
import type { ExtraBrowserContextOptions } from '../../ExtraBrowserContextOptions.js';
import { PlaywrightBrowsingSession } from './PlaywrightBrowsingSession.js';
import { PlaywrightPage } from './PlaywrightPage.js';
/**
* Playwright-specific implementation of [`BrowsingSession`](https://serenity-js.org/api/web/class/BrowsingSession/)
* for Electron applications.
*
* Use this class when you have an already-launched `ElectronApplication` instance,
* typically in Playwright Test scenarios where the app is managed per-worker.
*
* ## Example
*
* ```ts
* import { _electron as electron } from 'playwright';
* import { actorCalled } from '@serenity-js/core';
* import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright';
*
* const electronApp = await electron.launch({ args: ['main.js'] });
*
* const actor = actorCalled('Tester').whoCan(
* BrowseTheWebWithPlaywright.usingElectronApp(electronApp)
* );
*
* // After tests, close the app manually
* await electronApp.close();
* ```
*
* @group Models
*/
export declare class PlaywrightBrowsingSessionWithElectron extends PlaywrightBrowsingSession {
protected electronApp: playwright.ElectronApplication;
constructor(electronApp: playwright.ElectronApplication, extraBrowserContextOptions: Partial<ExtraBrowserContextOptions>, selectors: playwright.Selectors);
protected createBrowserContext(): Promise<playwright.BrowserContext>;
protected registerCurrentPage(): Promise<PlaywrightPage>;
/**
* Closes all Electron windows but does NOT close the Electron application itself.
* The application lifecycle is managed externally.
*/
closeAllPages(): Promise<void>;
/**
* Returns [basic meta-data](https://serenity-js.org/api/web/interface/BrowserCapabilities/) about the Electron application.
*
* **Please note** that since Playwright does not expose information about the operating system
* the tests are running on, **Serenity/JS assumes that the tests are running locally**
* and therefore returns the value of Node.js `process.platform` for `platformName`.
*/
browserCapabilities(): Promise<BrowserCapabilities>;
private getElectronVersion;
}
//# sourceMappingURL=PlaywrightBrowsingSessionWithElectron.d.ts.map