UNPKG

@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

42 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaywrightBrowsingSessionWithBrowser = void 0; const PlaywrightBrowsingSession_1 = require("./PlaywrightBrowsingSession"); /** * @group Models */ class PlaywrightBrowsingSessionWithBrowser extends PlaywrightBrowsingSession_1.PlaywrightBrowsingSession { browser; browserContextOptions; constructor(browser, browserContextOptions, extraBrowserContextOptions, selectors) { super(extraBrowserContextOptions, selectors); this.browser = browser; this.browserContextOptions = browserContextOptions; } async createBrowserContext() { return this.browser.newContext(this.browserContextOptions); } async registerCurrentPage() { const context = await this.browserContext(); await context.newPage(); // calling context.newPage() triggers a callback registered via browserContext(), // which wraps playwright.Page in PlaywrightPage and adds it to the list of pages // returned by this.allPages() const allPages = await this.allPages(); return allPages.at(-1); } async closeAllPages() { await super.closeAllPages(); const context = await this.browserContext(); await context.close(); } async browserCapabilities() { return { browserName: this.browser._initializer.name, // todo: raise a PR to Playwright to expose this information platformName: process.platform, // todo: get the actual platform from Playwright browserVersion: this.browser.version() }; } } exports.PlaywrightBrowsingSessionWithBrowser = PlaywrightBrowsingSessionWithBrowser; //# sourceMappingURL=PlaywrightBrowsingSessionWithBrowser.js.map