UNPKG

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