UNPKG

playwright-fluent

Version:
56 lines (55 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.launchBrowser = exports.defaultLaunchOptions = void 0; const utils_1 = require("../../../utils"); const playwright_1 = require("playwright"); exports.defaultLaunchOptions = { headless: true, }; async function launchBrowser(name, options) { switch (name) { case 'chrome': { if (options && options.executablePath !== undefined) { const browser = await playwright_1.chromium.launch(options); return browser; } { const chromeOptions = { ...options, executablePath: (0, utils_1.getChromePath)(), }; const browser = await playwright_1.chromium.launch(chromeOptions); return browser; } } case 'chrome-canary': { if (options && options.executablePath !== undefined) { const browser = await playwright_1.chromium.launch(options); return browser; } { const chromeOptions = { ...options, executablePath: (0, utils_1.getChromeCanaryPath)(), }; const browser = await playwright_1.chromium.launch(chromeOptions); return browser; } } case 'chromium': { const browser = await playwright_1.chromium.launch(options); return browser; } case 'firefox': { const browser = await playwright_1.firefox.launch(options); return browser; } case 'webkit': { const browser = await playwright_1.webkit.launch(options); return browser; } default: throw new Error(`Browser named '${name}' is unknown. It should be one of 'chrome', 'chromium', 'chrome-canary', 'firefox', 'webkit'`); } } exports.launchBrowser = launchBrowser;