UNPKG

@fpjs-incubator/broyster

Version:
45 lines (44 loc) 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebDriverFactory = void 0; const tslib_1 = require("tslib"); const webdriver = require("selenium-webdriver"); class WebDriverFactory { static createFromOptions(options, sessionCapabilities, firefoxProfile) { var _a; return tslib_1.__awaiter(this, void 0, void 0, function* () { const url = this.browserStackUrl; const builder = new webdriver.Builder().usingServer(url); switch ((_a = options.getBrowserName()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) { case 'firefox': { const firefoxOptions = options; if (firefoxProfile) { for (let index = 0; index < firefoxProfile.length; index++) { const preference = firefoxProfile[index]; firefoxOptions.setPreference(preference[0], preference[1]); } } builder.setFirefoxOptions(firefoxOptions); break; } case 'edge': { builder.setEdgeOptions(options); break; } case 'chrome': case 'samsung': { builder.setChromeOptions(options); break; } case 'safari': { builder.setSafariOptions(options); break; } } const driver = yield builder.withCapabilities(sessionCapabilities).build(); return driver; }); } } exports.WebDriverFactory = WebDriverFactory; WebDriverFactory.browserStackUrl = 'https://hub-cloud.browserstack.com/wd/hub';