forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webdriverio.tpl.d.ts
513 lines (462 loc) · 16.8 KB
/
webdriverio.tpl.d.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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
/// <reference types="node"/>
/// <reference types="webdriver"/>
declare namespace WebdriverIO {
type LocationParam = 'x' | 'y';
interface LocationReturn {
x: number,
y: number
}
type SizeParam = 'width' | 'height';
interface SizeReturn {
width: number,
height: number
}
interface CSSProperty {
property: string;
value: any;
parsed?: {
// other
unit?: string;
// font-family
value?: any;
string: string;
// color
hex?: string;
alpha?: number;
type?: string;
rgba?: string
}
}
interface MultiRemoteCapabilities {
[instanceName: string]: {
capabilities: WebDriver.DesiredCapabilities;
};
}
interface ServiceOption {
[key: string]: any;
}
type ServiceEntry = string | HookFunctions | [string, ServiceOption] | object
interface Options {
/**
* 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?: string;
runner?: string;
/**
* Your cloud service username (only works for Sauce Labs, Browserstack, TestingBot,
* CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will automatically
* set connection options for you.
*/
user?: string;
/**
* Your cloud service access key or secret key (only works for Sauce Labs, Browserstack,
* TestingBot, CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will
* automatically set connection options for you.
*/
key?: string;
/**
* 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?: string;
/**
* Sauce Labs provides a headless offering that allows you to run Chrome and Firefox tests headless.
*/
headless?: string;
/**
* Define specs for test execution.
*/
specs?: 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?: object;
/**
* Maximum number of total parallel running workers.
*/
maxInstances?: number;
/**
* Maximum number of total parallel running workers per capability.
*/
maxInstancesPerCapability?: number;
capabilities?: WebDriver.DesiredCapabilities[] | MultiRemoteCapabilities;
/**
* 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;
/**
* Shorten url command calls by setting a base URL.
*/
baseUrl?: string;
/**
* 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;
readonly specFileRetryAttempts?: number;
/**
* 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;
/**
* 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?: (string | object)[];
/**
* 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;
/**
* 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[];
/**
* Node arguments to specify when launching child processes.
*/
execArgv?: string[];
}
interface RemoteOptions extends WebDriver.Options, Omit<Options, 'capabilities'> { }
interface MultiRemoteOptions {
[instanceName: string]: WebDriver.DesiredCapabilities;
}
interface Suite {}
interface Test {}
interface Results {
finished: number,
passed: number,
failed: number
}
interface HookFunctions {
/**
* Gets executed once before all workers get launched.
* @param config wdio configuration object
* @param capabilities list of capabilities details
*/
onPrepare?(
config: Config,
capabilities: WebDriver.DesiredCapabilities[]
): void;
/**
* Gets executed before a worker process is spawned and can be used to initialise specific service
* for that worker as well as modify runtime environments in an async fashion.
* @param cid capability id (e.g 0-0)
* @param caps object containing capabilities for session that will be spawn in the worker
* @param specs specs to be run in the worker process
* @param args object that will be merged with the main configuration once worker is initialised
* @param execArgv list of string arguments passed to the worker process
*/
onWorkerStart?(
cid: string,
caps: WebDriver.DesiredCapabilities,
specs: string[],
args: Config,
execArgv: string[]
): void;
/**
* Gets executed after all workers got shut down and the process is about to exit. An error
* thrown in the onComplete hook will result in the test run failing.
* @param exitCode runner exit code
* @param config wdio configuration object
* @param capabilities list of capabilities details
* @param results test results
*/
onComplete?(
exitCode: number,
config: Config,
capabilities: WebDriver.DesiredCapabilities,
results: Results
): void;
/**
* Gets executed when a refresh happens.
* @param oldSessionId session id of old session
* @param newSessionId session id of new session
*/
onReload?(
oldSessionId: string,
newSessionId: string
): void;
/**
* Gets executed before test execution begins. At this point you can access to all global
* variables like `browser`. It is the perfect place to define custom commands.
* @param capabilities list of capabilities details
* @param specs specs to be run in the worker process
*/
before?(
capabilities: WebDriver.DesiredCapabilities,
specs: string[]
): void;
/**
* Runs before a WebdriverIO command gets executed.
* @param commandName command name
* @param args arguments that command would receive
*/
beforeCommand?(
commandName: string,
args: any[]
): void;
/**
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
* beforeEach in Mocha). `stepData` and `world` are Cucumber framework specific properties.
* @param test details to current running test (or step in Cucumber)
* @param context context to current running test
* @param stepData Cucumber step data
* @param world Cucumber world
*/
beforeHook?(test: any, context: any, stepData?: any, world?: any): void;
/**
* Gets executed just before initialising the webdriver session and test framework. It allows you
* to manipulate configurations depending on the capability or spec.
* @param config wdio configuration object
* @param capabilities list of capabilities details
* @param specs list of spec file paths that are to be run
*/
beforeSession?(
config: Config,
capabilities: WebDriver.DesiredCapabilities,
specs: string[]
): void;
/**
* Hook that gets executed before the suite starts.
* @param suite suite details
*/
beforeSuite?(suite: Suite): void;
/**
* Function to be executed before a test (in Mocha/Jasmine) starts.
* @param test details to current running test (or step in Cucumber)
* @param context context to current running test
*/
beforeTest?(test: Test, context: any): void;
/**
* Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
* afterEach in Mocha). `stepData` and `world` are Cucumber framework specific.
* @param test details to current running test (or step in Cucumber)
* @param context context to current running test
* @param result test result
* @param stepData Cucumber step data
* @param world Cucumber world
*/
afterHook?(test: any, context: any, result: {
error?: any,
result?: any,
passed: boolean,
duration: number,
retries: { limit: number, attempts: number }
}, stepData?: any, world?: any): void;
/**
* Gets executed after all tests are done. You still have access to all global variables from
* the test.
* @param result number of total failing tests
* @param capabilities list of capabilities details
* @param specs list of spec file paths that are to be run
*/
after?(
result: number,
capabilities: WebDriver.DesiredCapabilities,
specs: string[]
): void;
/**
* Runs after a WebdriverIO command gets executed
* @param commandName command name
* @param args arguments that command would receive
* @param result result of the command
* @param error error in case something went wrong
*/
afterCommand?(
commandName: string,
args: any[],
result: any,
error?: Error
): void;
/**
* Gets executed right after terminating the webdriver session.
* @param config wdio configuration object
* @param capabilities list of capabilities details
* @param specs list of spec file paths that are to be run
*/
afterSession?(
config: Config,
capabilities: WebDriver.DesiredCapabilities,
specs: string[]
): void;
/**
* Hook that gets executed after the suite has ended
* @param suite suite details
*/
afterSuite?(suite: Suite): void;
/**
* Function to be executed after a test (in Mocha/Jasmine) ends.
* @param test details to current running test (or step in Cucumber)
* @param context context to current running test
* @param result test result
*/
afterTest?(test: Test, context: any, result: {
error?: any,
result?: any,
passed: boolean,
duration: number,
retries: { limit: number, attempts: number }
}): void;
}
type _HooksArray = {
[K in keyof Pick<HookFunctions, "onPrepare" | "onWorkerStart" | "onComplete" | "before" | "after" | "beforeSession" | "afterSession">]: HookFunctions[K] | Array<HookFunctions[K]>;
};
type _Hooks = Omit<HookFunctions, "onPrepare" | "onWorkerStart" | "onComplete" | "before" | "after" | "beforeSession" | "afterSession">;
interface Hooks extends _HooksArray, _Hooks { }
type ActionTypes = 'press' | 'longPress' | 'tap' | 'moveTo' | 'wait' | 'release';
interface TouchAction {
action: ActionTypes,
x?: number,
y?: number,
element?: Element,
ms?: number
}
type TouchActions = string | TouchAction | TouchAction[];
type WaitForOptions = {
timeout?: number,
interval?: number,
timeoutMsg?: string,
reverse?: boolean,
}
type Matcher = {
name: string,
args: Array<string | object>
class?: string
}
type ReactSelectorOptions = {
props?: object,
state?: any[] | number | string | object | boolean
}
type MoveToOptions = {
xOffset?: number,
yOffset?: number
}
type DragAndDropOptions = {
duration?: number
}
type NewWindowOptions = {
windowName?: string,
windowFeatures?: string
}
type ClickOptions = {
button?: number | string,
x?: number,
y?: number
}
type WaitUntilOptions = {
timeout?: number,
timeoutMsg?: string,
interval?: number
}
type DragAndDropCoordinate = {
x: number,
y: number
}
interface Element {
selector: string;
elementId: string;
/**
* w3c
*/
"element-6066-11e4-a52e-4f735466cecf"?: string;
/**
* jsonwp
*/
ELEMENT?: string;
/**
* index in array of elements
* only applicable if the element found with `$$` command
*/
index?: number;
/**
* WebdriverIO.Element or WebdriverIO.BrowserObject
*/
parent: Element | WebdriverIO.BrowserObject;
/**
* add command to `element` scope
*/
addCommand(
name: string,
func: Function
): void;
// ... element commands ...
}
interface ElementArray extends Array<Element> {
selector: string | Function;
parent: Element | WebdriverIO.BrowserObject;
foundWith: string;
props: any[];
}
interface Timeouts {
implicit?: number,
pageLoad?: number,
script?: number
}
interface Browser extends WebDriver.BaseClient {
config: Config;
options: RemoteOptions;
/**
* add command to `browser` or `element` scope
*/
addCommand(
name: string,
func: Function,
attachToElement?: boolean
): void;
/**
* overwrite `browser` or `element` command
*/
overwriteCommand(
name: string,
func: (origCommand: Function, ...args: any[]) => any,
attachToElement?: boolean
): void;
/**
* create custom selector
*/
addLocatorStrategy(
name: string,
func: (elementFetchingMethod: (selector: string) => any) => void
): void
// ... browser commands ...
}
interface Config extends Options, Omit<WebDriver.Options, "capabilities">, Hooks {}
}