index.js 3.44 KB
Newer Older
jatuporn Tonggasem's avatar
jatuporn Tonggasem committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./attachSession"));
__export(require("./browserStack"));
__export(require("./direct"));
__export(require("./driverProvider"));
__export(require("./hosted"));
__export(require("./local"));
__export(require("./mock"));
__export(require("./sauce"));
const attachSession_1 = require("./attachSession");
const browserStack_1 = require("./browserStack");
const direct_1 = require("./direct");
const hosted_1 = require("./hosted");
const local_1 = require("./local");
const mock_1 = require("./mock");
const sauce_1 = require("./sauce");
const logger_1 = require("../logger");
let logger = new logger_1.Logger('driverProviders');
exports.buildDriverProvider = (config) => {
    let driverProvider;
    if (config.directConnect) {
        driverProvider = new direct_1.Direct(config);
        exports.logWarnings('directConnect', config);
    }
    else if (config.seleniumAddress) {
        if (config.seleniumSessionId) {
            driverProvider = new attachSession_1.AttachSession(config);
            exports.logWarnings('attachSession', config);
        }
        else {
            driverProvider = new hosted_1.Hosted(config);
            exports.logWarnings('hosted', config);
        }
    }
    else if (config.browserstackUser && config.browserstackKey) {
        driverProvider = new browserStack_1.BrowserStack(config);
        exports.logWarnings('browserStack', config);
    }
    else if (config.sauceUser && config.sauceKey) {
        driverProvider = new sauce_1.Sauce(config);
        exports.logWarnings('sauce', config);
    }
    else if (config.seleniumServerJar) {
        driverProvider = new local_1.Local(config);
        exports.logWarnings('local', config);
    }
    else if (config.mockSelenium) {
        driverProvider = new mock_1.Mock(config);
        exports.logWarnings('mock', config);
    }
    else {
        driverProvider = new local_1.Local(config);
        exports.logWarnings('local', config);
    }
    return driverProvider;
};
exports.logWarnings = (providerType, config) => {
    let warnInto = 'Using driver provider ' + providerType +
        ', but also found extra driver provider parameter(s): ';
    let warnList = [];
    if ('directConnect' !== providerType && config.directConnect) {
        warnList.push('directConnect');
    }
    if ('attachSession' !== providerType && 'hosted' !== providerType && config.seleniumAddress) {
        warnList.push('seleniumAddress');
    }
    if ('attachSession' !== providerType && config.seleniumSessionId) {
        warnList.push('seleniumSessionId');
    }
    if ('browserStack' !== providerType && config.browserstackUser) {
        warnList.push('browserstackUser');
    }
    if ('browserStack' !== providerType && config.browserstackKey) {
        warnList.push('browserstackKey');
    }
    if ('sauce' !== providerType && config.sauceUser) {
        warnList.push('sauceUser');
    }
    if ('sauce' !== providerType && config.sauceKey) {
        warnList.push('sauceKey');
    }
    if ('local' !== providerType && config.seleniumServerJar) {
        warnList.push('seleniumServerJar');
    }
    if ('mock' !== providerType && config.mockSelenium) {
        warnList.push('mockSelenium');
    }
    if (warnList.length !== 0) {
        logger.warn(warnInto + warnList.join(', '));
    }
};
//# sourceMappingURL=index.js.map