forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.ts
485 lines (466 loc) · 14.8 KB
/
Options.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
import * as http from 'http'
import * as https from 'https'
import { RegisterOptions } from './Compiler'
import type { URL } from 'url'
import { W3CCapabilities, DesiredCapabilities, RemoteCapabilities, RemoteCapability, MultiRemoteCapabilities, Capabilities } from './Capabilities'
import { Hooks, ServiceEntry } from './Services'
import { ReporterEntry } from './Reporters'
export type WebDriverLogTypes = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'
export type SupportedProtocols = 'webdriver' | 'devtools' | './protocol-stub'
export type Agents = {http?: any, https?: any}
export interface RequestLibOptions {
agent?: Agents | null
followRedirect?: boolean
headers?: Record<string, unknown>
https?: Record<string, unknown>
json?: Record<string, unknown>
method?: string
responseType?: string
retry?: number
searchParams?: Record<string, unknown>
throwHttpErrors?: boolean
timeout?: number
url?: URL
path?: string
username?: string
password?: string
body?: any
}
export interface RequestLibResponse {
statusCode: number
body?: any
rawBody?: Buffer
}
/**
* WebdriverIO allows to connect to different WebDriver endpoints by capability
* so these connection options need to be part of capabilities
*/
export interface Connection {
/**
* Protocol to use when communicating with the Selenium standalone server (or driver).
*
* @default 'http'
*/
protocol?: string
/**
* Host of your WebDriver server.
*
* @default 'localhost'
*/
hostname?: string
/**
* Port your WebDriver server is on.
*
* @default 4444
*/
port?: number
/**
* Path to WebDriver endpoint or grid server.
*
* @default '/'
*/
path?: string
/**
* Query paramaters that are propagated to the driver server.
*/
queryParams?: {
[name: string]: string
}
/**
* Your cloud service username (only works for [Sauce Labs](https://saucelabs.com),
* [Browserstack](https://www.browserstack.com), [TestingBot](https://testingbot.com),
* [CrossBrowserTesting](https://crossbrowsertesting.com) or
* [LambdaTest](https://www.lambdatest.com) accounts). If set, WebdriverIO will
* automatically set connection options for you. If you don't use a cloud provider this
* can be used to authenticate any other WebDriver backend.
*/
user?: string
/**
* Your cloud service access key or secret key (only works for
* [Sauce Labs](https://saucelabs.com), [Browserstack](https://www.browserstack.com),
* [TestingBot](https://testingbot.com), [CrossBrowserTesting](https://crossbrowsertesting.com)
* or [LambdaTest](https://www.lambdatest.com) accounts). If set, WebdriverIO will
* automatically set connection options for you. If you don't use a cloud provider this
* can be used to authenticate any other WebDriver backend.
*/
key?: string
}
export interface WebDriver extends Connection {
/**
* Defines the capabilities you want to run in your WebDriver session. Check out the
* [WebDriver Protocol](https://w3c.github.io/webdriver/#capabilities) for more details.
* If you want to run multiremote session you need to define an object that has the
* browser instance names as string and their capabilities as values.
*
* @example
* ```js
* // WebDriver/DevTools session
* const browser = remote({
* capabilities: {
* browserName: 'chrome',
* browserVersion: 86
* platformName: 'Windows 10'
* }
* })
*
* // multiremote session
* const browser = remote({
* capabilities: {
* browserA: {
* browserName: 'chrome',
* browserVersion: 86
* platformName: 'Windows 10'
* },
* browserB: {
* browserName: 'firefox',
* browserVersion: 74
* platformName: 'Mac OS X'
* }
* }
* })
* ```
*/
capabilities: W3CCapabilities | DesiredCapabilities
/**
* Level of logging verbosity.
*
* @default 'info'
*/
logLevel?: WebDriverLogTypes
/**
* Set specific log levels per logger
* use 'silent' level to disable logger
*/
logLevels?: Record<string, WebDriverLogTypes>
/**
* Timeout for any WebDriver request to a driver or grid.
*
* @default 120000
*/
connectionRetryTimeout?: number
/**
* Count of request retries to the Selenium server.
*
* @default 3
*/
connectionRetryCount?: number
/**
* Specify custom headers to pass into every request.
*/
headers?: {
[name: string]: string
}
/**
* Allows you to use a custom http/https/http2 [agent](https://www.npmjs.com/package/got#agent) to make requests.
*
* @default
* ```js
* {
* http: new http.Agent({ keepAlive: true }),
* https: new https.Agent({ keepAlive: true })
* }
* ```
*/
agent?: {
http: http.Agent,
https: https.Agent
}
/**
* Function intercepting [HTTP request options](https://github.com/sindresorhus/got#options) before a WebDriver request is made.
*/
transformRequest?: (requestOptions: RequestLibOptions) => RequestLibOptions
/**
* Function intercepting HTTP response objects after a WebDriver response has arrived.
*/
transformResponse?: (response: RequestLibResponse, requestOptions: RequestLibOptions) => RequestLibResponse
/**
* Appium direct connect options (see: https://appiumpro.com/editions/86-connecting-directly-to-appium-hosts-in-distributed-environments)
*/
enableDirectConnect?: boolean;
/**
* Whether it requires SSL certificates to be valid in HTTP/s requests
* for an environment which cannot get process environment well.
*
* @default true
*/
strictSSL?: boolean
/**
* Directory to store all testrunner log files (including reporter logs and `wdio` logs).
* If not set, all logs are streamed to `stdout`. Since most reporters are made to log to
* `stdout`, it is recommended to only use this option for specific reporters where it
* makes more sense to push report into a file (like the `junit` reporter, for example).
*
* When running in standalone mode, the only log generated by WebdriverIO will be
* the `wdio` log.
*/
outputDir?: string
}
export interface MultiRemoteBrowserOptions {
sessionId?: string
capabilities: DesiredCapabilities
}
export type SauceRegions = 'us' | 'eu' | 'apac' | 'us-west-1' | 'us-east-1' | 'eu-central-1' | 'apac-southeast-1' | 'staging'
export interface WebdriverIO extends Omit<WebDriver, 'capabilities'> {
/**
* Defines the capabilities you want to run in your WebDriver session. Check out the
* [WebDriver Protocol](https://w3c.github.io/webdriver/#capabilities) for more details.
* If you want to run a multiremote session you need to define instead of an array of
* capabilities an object that has an arbitrary browser instance name as string and its
* capabilities as values.
*
* @example
* ```js
* // wdio.conf.js
* exports.config
* // ...
* capabilities: {
* browserName: 'safari',
* platformName: 'MacOS 10.13',
* ...
* }
* }
* ```
*
* @example
* ```
* // wdio.conf.js
* exports.config
* // ...
* capabilities: {
* browserA: {
* browserName: 'chrome',
* browserVersion: 86
* platformName: 'Windows 10'
* },
* browserB: {
* browserName: 'firefox',
* browserVersion: 74
* platformName: 'Mac OS X'
* }
* }
* })
* ```
*/
capabilities: RemoteCapability
/**
* Define the protocol you want to use for your browser automation.
* Currently only [`webdriver`](https://www.npmjs.com/package/webdriver) and
* [`devtools`](https://www.npmjs.com/package/devtools) are supported,
* as these are the main browser automation technologies available.
*/
automationProtocol?: SupportedProtocols
/**
* If running on Sauce Labs, you can choose to run tests between different datacenters:
* US or EU. To change your region to EU, add region: 'eu' to your config.
*/
region?: SauceRegions
/**
* Sauce Labs provides a headless offering that allows you to run Chrome and Firefox tests headless.
*/
headless?: boolean
/**
* Shorten url command calls by setting a base URL.
*/
baseUrl?: string
/**
* Default timeout for all `waitFor*` commands. (Note the lowercase f in the option name.)
* This timeout only affects commands starting with `waitFor*` and their default wait time.
*/
waitforTimeout?: number
/**
* Default interval for all `waitFor*` commands to check if an expected state (e.g.,
* visibility) has been changed.
*/
waitforInterval?: number
}
export interface Testrunner extends Hooks, Omit<WebdriverIO, 'capabilities'>, WebdriverIO.HookFunctionExtension {
/**
* Defines a set of capabilities you want to run in your testrunner session. Check out the
* [WebDriver Protocol](https://w3c.github.io/webdriver/#capabilities) for more details.
* If you want to run a multiremote session you need to define instead of an array of
* capabilities an object that has an arbitrary browser instance name as string and its
* capabilities as values.
*
* @example
* ```js
* // wdio.conf.js
* exports.config
* // ...
* capabilities: [{
* browserName: 'safari',
* platformName: 'MacOS 10.13',
* ...
* }, {
* browserName: 'microsoftedge',
* platformName: 'Windows 10',
* ...
* }]
* }
* ```
*
* @example
* ```
* // wdio.conf.js
* exports.config
* // ...
* capabilities: {
* browserA: {
* browserName: 'chrome',
* browserVersion: 86
* platformName: 'Windows 10'
* },
* browserB: {
* browserName: 'firefox',
* browserVersion: 74
* platformName: 'Mac OS X'
* }
* }
* })
* ```
*/
capabilities: RemoteCapabilities
/**
* Type of runner (currently only "local" is supported)
*/
runner?: 'local'
/**
* Define specs for test execution. You can either specify a glob
* pattern to match multiple files at once or wrap a glob or set of
* paths into an array to run them within a single worker process.
*/
specs?: (string | string[])[]
/**
* Exclude specs from test execution.
*/
exclude?: string[]
/**
* An object describing various of suites, which you can then specify
* with the --suite option on the wdio CLI.
*/
suites?: Record<string, string[]>
/**
* Maximum number of total parallel running workers.
*/
maxInstances?: number
/**
* Maximum number of total parallel running workers per capability.
*/
maxInstancesPerCapability?: number
/**
* If you want your test run to stop after a specific number of test failures, use bail.
* (It defaults to 0, which runs all tests no matter what.) Note: Please be aware that
* when using a third party test runner (such as Mocha), additional configuration might
* be required.
*/
bail?: number
/**
* The number of retry attempts for an entire specfile when it fails as a whole.
*/
specFileRetries?: number
/**
* Delay in seconds between the spec file retry attempts
*/
specFileRetriesDelay?: number
/**
* Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
*/
specFileRetriesDeferred?: boolean
/**
* Services take over a specific job you don't want to take care of. They enhance
* your test setup with almost no effort.
*/
services?: ServiceEntry[]
/**
* Defines the test framework to be used by the WDIO testrunner.
*/
framework?: string
/**
* List of reporters to use. A reporter can be either a string, or an array of
* `['reporterName', { <reporter options> }]` where the first element is a string
* with the reporter name and the second element an object with reporter options.
*/
reporters?: ReporterEntry[]
/**
* Determines in which interval the reporter should check if they are synchronised
* if they report their logs asynchronously (e.g. if logs are streamed to a 3rd
* party vendor).
*/
reporterSyncInterval?: number
/**
* Determines the maximum time reporters have to finish uploading all their logs
* until an error is being thrown by the testrunner.
*/
reporterSyncTimeout?: number
/**
* Node arguments to specify when launching child processes.
*/
execArgv?: string[]
/**
* A set of environment variables to be injected into the worker process.
*/
runnerEnv?: Record<string, any>
/**
* Files to watch when running `wdio` with the `--watch` flag.
*/
filesToWatch?: string[]
/**
* List of cucumber features with line numbers (when using [cucumber framework](https://webdriver.io/docs/frameworks.html#using-cucumber)).
* @default []
*/
cucumberFeaturesWithLineNumbers?: string[]
/**
* flags
*/
watch?: boolean
/**
* framework options
*/
mochaOpts?: WebdriverIO.MochaOpts
jasmineOpts?: WebdriverIO.JasmineOpts
cucumberOpts?: WebdriverIO.CucumberOpts
/**
* autocompile options
*/
autoCompileOpts?: AutoCompileConfig
}
export interface TSConfigPathsOptions {
baseUrl: string
paths: Record<string, string[]>
mainFields?: string[]
addMatchAll?: boolean
}
export interface AutoCompileConfig {
autoCompile?: boolean
tsNodeOpts?: RegisterOptions
babelOpts?: Record<string, any>
tsConfigPathsOpts?: TSConfigPathsOptions
}
export interface MultiRemote extends Omit<Testrunner, 'capabilities'> {
capabilities: MultiRemoteCapabilities
}
export type Definition<T> = {
[k in keyof T]: {
type: 'string' | 'number' | 'object' | 'boolean' | 'function'
default?: T[k]
required?: boolean
validate?: (option: T[k]) => void
match?: RegExp
}
}
export interface RunnerStart {
cid: string
specs: string[]
config: Testrunner
isMultiremote: boolean
instanceOptions: Record<string, WebdriverIO>
sessionId: string
capabilities: Capabilities
retry?: number
failures?: number
retries?: number
}
export interface RunnerEnd {
failures: number
cid: string
retries: number
}