1 | "use strict";
|
2 | function __export(m) {
|
3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
4 | }
|
5 | Object.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"));
|
14 | const attachSession_1 = require("./attachSession");
|
15 | const browserStack_1 = require("./browserStack");
|
16 | const direct_1 = require("./direct");
|
17 | const hosted_1 = require("./hosted");
|
18 | const local_1 = require("./local");
|
19 | const mock_1 = require("./mock");
|
20 | const sauce_1 = require("./sauce");
|
21 | const logger_1 = require("../logger");
|
22 | let logger = new logger_1.Logger('driverProviders');
|
23 | exports.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 | };
|
61 | exports.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 |
|
\ | No newline at end of file |