This repository was archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathindex.ts
126 lines (118 loc) · 4.19 KB
/
index.ts
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
export * from './attachSession';
export * from './browserStack';
export * from './direct';
export * from './driverProvider';
export * from './hosted';
export * from './local';
export * from './mock';
export * from './sauce';
export * from './experitest';
export * from './testObject';
export * from './kobiton';
import {AttachSession} from './attachSession';
import {BrowserStack} from './browserStack';
import {DriverProvider} from './driverProvider';
import {Direct} from './direct';
import {Hosted} from './hosted';
import {Local} from './local';
import {Mock} from './mock';
import {Sauce} from './sauce';
import {Experitest} from './experitest';
import {TestObject} from './testObject';
import {Kobiton} from './kobiton';
import {Config} from '../config';
import {Logger} from '../logger';
let logger = new Logger('driverProviders');
export let buildDriverProvider = (config: Config): DriverProvider => {
let driverProvider: DriverProvider;
if (config.directConnect) {
driverProvider = new Direct(config);
logWarnings('directConnect', config);
} else if (config.seleniumAddress) {
if (config.seleniumSessionId) {
driverProvider = new AttachSession(config);
logWarnings('attachSession', config);
} else {
driverProvider = new Hosted(config);
logWarnings('hosted', config);
}
} else if (config.testobjectUser && config.testobjectKey) {
driverProvider = new TestObject(config);
logWarnings('testObject', config);
} else if (config.kobitonUser && config.kobitonKey) {
driverProvider = new Kobiton(config);
logWarnings('kobiton', config);
} else if (config.browserstackUser && config.browserstackKey) {
driverProvider = new BrowserStack(config);
logWarnings('browserStack', config);
} else if (config.sauceUser && config.sauceKey) {
driverProvider = new Sauce(config);
logWarnings('sauce', config);
} else if (config.experitestKey && config.experitestCloudAddress) {
driverProvider = new Experitest(config);
logWarnings('experitest', config);
} else if (config.seleniumServerJar) {
driverProvider = new Local(config);
logWarnings('local', config);
} else if (config.mockSelenium) {
driverProvider = new Mock(config);
logWarnings('mock', config);
} else {
driverProvider = new Local(config);
logWarnings('local', config);
}
return driverProvider;
};
export let logWarnings = (providerType: string, config: Config): void => {
let warnInto = 'Using driver provider ' + providerType +
', but also found extra driver provider parameter(s): ';
let warnList: string[] = [];
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 ('testObject' !== providerType && config.testObjectUser) {
warnList.push('testobjectUser');
}
if ('testObject' !== providerType && config.testObjectKey) {
warnList.push('testobjectKey');
}
if ('kobitonUser' !== providerType && config.kobitonUser) {
warnList.push('kobitonUser');
}
if ('kobitonKey' !== providerType && config.kobitonKey) {
warnList.push('kobitonKey');
}
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 ('experitest' !== providerType && config.experitestKey) {
warnList.push('experitestKey');
}
if ('experitest' !== providerType && config.experitestCloudAddress) {
warnList.push('experitestCloudAddress');
}
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(', '));
}
};