UNPKG

38.9 kBTypeScriptView Raw
1// -------------------- ATTENTION --------------------
2// Do not edit this file as it gets auto-generated!
3// For edits modify /scripts/templates/*.tpl.d.ts
4// Check CONTRIBUTING.md for more details.
5// --------------------------------------------------
6//
7/// <reference types="node"/>
8/// <reference types="webdriver"/>
9
10declare namespace WebdriverIO {
11 type LocationParam = 'x' | 'y';
12
13 interface LocationReturn {
14 x: number,
15 y: number
16 }
17
18 type SizeParam = 'width' | 'height';
19
20 interface SizeReturn {
21 width: number,
22 height: number
23 }
24
25 interface CSSProperty {
26 property: string;
27 value: any;
28 parsed?: {
29 // other
30 unit?: string;
31 // font-family
32 value?: any;
33 string: string;
34 // color
35 hex?: string;
36 alpha?: number;
37 type?: string;
38 rgba?: string
39 }
40 }
41
42 interface MultiRemoteCapabilities {
43 [instanceName: string]: {
44 capabilities: WebDriver.DesiredCapabilities;
45 };
46 }
47
48 interface ServiceOption {
49 [key: string]: any;
50 }
51 type ServiceEntry = string | HookFunctions | [string, ServiceOption] | object
52
53 interface Options {
54 /**
55 * Define the protocol you want to use for your browser automation.
56 * Currently only [`webdriver`](https://www.npmjs.com/package/webdriver) and
57 * [`devtools`](https://www.npmjs.com/package/devtools) are supported,
58 * as these are the main browser automation technologies available.
59 */
60 automationProtocol?: string;
61 runner?: string;
62 /**
63 * Your cloud service username (only works for Sauce Labs, Browserstack, TestingBot,
64 * CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will automatically
65 * set connection options for you.
66 */
67 user?: string;
68 /**
69 * Your cloud service access key or secret key (only works for Sauce Labs, Browserstack,
70 * TestingBot, CrossBrowserTesting or LambdaTest accounts). If set, WebdriverIO will
71 * automatically set connection options for you.
72 */
73 key?: string;
74 /**
75 * If running on Sauce Labs, you can choose to run tests between different datacenters:
76 * US or EU. To change your region to EU, add region: 'eu' to your config.
77 */
78 region?: string;
79 /**
80 * Sauce Labs provides a headless offering that allows you to run Chrome and Firefox tests headless.
81 */
82 headless?: string;
83 /**
84 * Define specs for test execution.
85 */
86 specs?: string[];
87 /**
88 * Exclude specs from test execution.
89 */
90 exclude?: string[];
91 /**
92 * An object describing various of suites, which you can then specify
93 * with the --suite option on the wdio CLI.
94 */
95 suites?: object;
96 /**
97 * Maximum number of total parallel running workers.
98 */
99 maxInstances?: number;
100 /**
101 * Maximum number of total parallel running workers per capability.
102 */
103 maxInstancesPerCapability?: number;
104 capabilities?: WebDriver.DesiredCapabilities[] | MultiRemoteCapabilities;
105 /**
106 * Directory to store all testrunner log files (including reporter logs and wdio logs).
107 * If not set, all logs are streamed to stdout. Since most reporters are made to log to
108 * stdout, it is recommended to only use this option for specific reporters where it
109 * makes more sense to push report into a file (like the junit reporter, for example).
110 *
111 * When running in standalone mode, the only log generated by WebdriverIO will be the wdio log.
112 */
113 outputDir?: string;
114 /**
115 * Shorten url command calls by setting a base URL.
116 */
117 baseUrl?: string;
118 /**
119 * If you want your test run to stop after a specific number of test failures, use bail.
120 * (It defaults to 0, which runs all tests no matter what.) Note: Please be aware that
121 * when using a third party test runner (such as Mocha), additional configuration might
122 * be required.
123 */
124 bail?: number;
125 /**
126 * The number of retry attempts for an entire specfile when it fails as a whole.
127 */
128 specFileRetries?: number;
129 readonly specFileRetryAttempts?: number;
130 /**
131 * Default timeout for all `waitFor*` commands. (Note the lowercase f in the option name.)
132 * This timeout only affects commands starting with `waitFor*` and their default wait time.
133 */
134 waitforTimeout?: number;
135 /**
136 * Default interval for all `waitFor*` commands to check if an expected state (e.g.,
137 * visibility) has been changed.
138 */
139 waitforInterval?: number;
140 /**
141 * Defines the test framework to be used by the WDIO testrunner.
142 */
143 framework?: string;
144 /**
145 * List of reporters to use. A reporter can be either a string, or an array of
146 * `['reporterName', { <reporter options> }]` where the first element is a string
147 * with the reporter name and the second element an object with reporter options.
148 */
149 reporters?: (string | object)[];
150 /**
151 * Determines in which interval the reporter should check if they are synchronised
152 * if they report their logs asynchronously (e.g. if logs are streamed to a 3rd
153 * party vendor).
154 */
155 reporterSyncInterval?: number;
156 /**
157 * Determines the maximum time reporters have to finish uploading all their logs
158 * until an error is being thrown by the testrunner.
159 */
160 reporterSyncTimeout?: number;
161 /**
162 * Services take over a specific job you don't want to take care of. They enhance
163 * your test setup with almost no effort.
164 */
165 services?: ServiceEntry[];
166 /**
167 * Node arguments to specify when launching child processes.
168 */
169 execArgv?: string[];
170 }
171
172 interface RemoteOptions extends WebDriver.Options, Omit<Options, 'capabilities'> { }
173
174 interface MultiRemoteOptions {
175 [instanceName: string]: WebDriver.DesiredCapabilities;
176 }
177
178 interface Suite {}
179 interface Test {}
180
181 interface Results {
182 finished: number,
183 passed: number,
184 failed: number
185 }
186
187 interface HookFunctions {
188 /**
189 * Gets executed once before all workers get launched.
190 * @param config wdio configuration object
191 * @param capabilities list of capabilities details
192 */
193 onPrepare?(
194 config: Config,
195 capabilities: WebDriver.DesiredCapabilities[]
196 ): void;
197
198 /**
199 * Gets executed before a worker process is spawned and can be used to initialise specific service
200 * for that worker as well as modify runtime environments in an async fashion.
201 * @param cid capability id (e.g 0-0)
202 * @param caps object containing capabilities for session that will be spawn in the worker
203 * @param specs specs to be run in the worker process
204 * @param args object that will be merged with the main configuration once worker is initialised
205 * @param execArgv list of string arguments passed to the worker process
206 */
207 onWorkerStart?(
208 cid: string,
209 caps: WebDriver.DesiredCapabilities,
210 specs: string[],
211 args: Config,
212 execArgv: string[]
213 ): void;
214
215 /**
216 * Gets executed after all workers got shut down and the process is about to exit. An error
217 * thrown in the onComplete hook will result in the test run failing.
218 * @param exitCode runner exit code
219 * @param config wdio configuration object
220 * @param capabilities list of capabilities details
221 * @param results test results
222 */
223 onComplete?(
224 exitCode: number,
225 config: Config,
226 capabilities: WebDriver.DesiredCapabilities,
227 results: Results
228 ): void;
229
230 /**
231 * Gets executed when a refresh happens.
232 * @param oldSessionId session id of old session
233 * @param newSessionId session id of new session
234 */
235 onReload?(
236 oldSessionId: string,
237 newSessionId: string
238 ): void;
239
240 /**
241 * Gets executed before test execution begins. At this point you can access to all global
242 * variables like `browser`. It is the perfect place to define custom commands.
243 * @param capabilities list of capabilities details
244 * @param specs specs to be run in the worker process
245 */
246 before?(
247 capabilities: WebDriver.DesiredCapabilities,
248 specs: string[]
249 ): void;
250
251 /**
252 * Runs before a WebdriverIO command gets executed.
253 * @param commandName command name
254 * @param args arguments that command would receive
255 */
256 beforeCommand?(
257 commandName: string,
258 args: any[]
259 ): void;
260
261 /**
262 * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
263 * beforeEach in Mocha). `stepData` and `world` are Cucumber framework specific properties.
264 * @param test details to current running test (or step in Cucumber)
265 * @param context context to current running test
266 * @param stepData Cucumber step data
267 * @param world Cucumber world
268 */
269 beforeHook?(test: any, context: any, stepData?: any, world?: any): void;
270
271 /**
272 * Gets executed just before initialising the webdriver session and test framework. It allows you
273 * to manipulate configurations depending on the capability or spec.
274 * @param config wdio configuration object
275 * @param capabilities list of capabilities details
276 * @param specs list of spec file paths that are to be run
277 */
278 beforeSession?(
279 config: Config,
280 capabilities: WebDriver.DesiredCapabilities,
281 specs: string[]
282 ): void;
283
284 /**
285 * Hook that gets executed before the suite starts.
286 * @param suite suite details
287 */
288 beforeSuite?(suite: Suite): void;
289
290 /**
291 * Function to be executed before a test (in Mocha/Jasmine) starts.
292 * @param test details to current running test (or step in Cucumber)
293 * @param context context to current running test
294 */
295 beforeTest?(test: Test, context: any): void;
296
297 /**
298 * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
299 * afterEach in Mocha). `stepData` and `world` are Cucumber framework specific.
300 * @param test details to current running test (or step in Cucumber)
301 * @param context context to current running test
302 * @param result test result
303 * @param stepData Cucumber step data
304 * @param world Cucumber world
305 */
306 afterHook?(test: any, context: any, result: {
307 error?: any,
308 result?: any,
309 passed: boolean,
310 duration: number,
311 retries: { limit: number, attempts: number }
312 }, stepData?: any, world?: any): void;
313
314 /**
315 * Gets executed after all tests are done. You still have access to all global variables from
316 * the test.
317 * @param result number of total failing tests
318 * @param capabilities list of capabilities details
319 * @param specs list of spec file paths that are to be run
320 */
321 after?(
322 result: number,
323 capabilities: WebDriver.DesiredCapabilities,
324 specs: string[]
325 ): void;
326
327 /**
328 * Runs after a WebdriverIO command gets executed
329 * @param commandName command name
330 * @param args arguments that command would receive
331 * @param result result of the command
332 * @param error error in case something went wrong
333 */
334 afterCommand?(
335 commandName: string,
336 args: any[],
337 result: any,
338 error?: Error
339 ): void;
340
341 /**
342 * Gets executed right after terminating the webdriver session.
343 * @param config wdio configuration object
344 * @param capabilities list of capabilities details
345 * @param specs list of spec file paths that are to be run
346 */
347 afterSession?(
348 config: Config,
349 capabilities: WebDriver.DesiredCapabilities,
350 specs: string[]
351 ): void;
352
353 /**
354 * Hook that gets executed after the suite has ended
355 * @param suite suite details
356 */
357 afterSuite?(suite: Suite): void;
358
359 /**
360 * Function to be executed after a test (in Mocha/Jasmine) ends.
361 * @param test details to current running test (or step in Cucumber)
362 * @param context context to current running test
363 * @param result test result
364 */
365 afterTest?(test: Test, context: any, result: {
366 error?: any,
367 result?: any,
368 passed: boolean,
369 duration: number,
370 retries: { limit: number, attempts: number }
371 }): void;
372 }
373 type _HooksArray = {
374 [K in keyof Pick<HookFunctions, "onPrepare" | "onWorkerStart" | "onComplete" | "before" | "after" | "beforeSession" | "afterSession">]: HookFunctions[K] | Array<HookFunctions[K]>;
375 };
376 type _Hooks = Omit<HookFunctions, "onPrepare" | "onWorkerStart" | "onComplete" | "before" | "after" | "beforeSession" | "afterSession">;
377 interface Hooks extends _HooksArray, _Hooks { }
378
379 type ActionTypes = 'press' | 'longPress' | 'tap' | 'moveTo' | 'wait' | 'release';
380 interface TouchAction {
381 action: ActionTypes,
382 x?: number,
383 y?: number,
384 element?: Element,
385 ms?: number
386 }
387 type TouchActions = string | TouchAction | TouchAction[];
388
389 type WaitForOptions = {
390 timeout?: number,
391 interval?: number,
392 timeoutMsg?: string,
393 reverse?: boolean,
394 }
395
396 type Matcher = {
397 name: string,
398 args: Array<string | object>
399 class?: string
400 }
401
402 type ReactSelectorOptions = {
403 props?: object,
404 state?: any[] | number | string | object | boolean
405 }
406
407 type MoveToOptions = {
408 xOffset?: number,
409 yOffset?: number
410 }
411
412 type DragAndDropOptions = {
413 duration?: number
414 }
415
416 type NewWindowOptions = {
417 windowName?: string,
418 windowFeatures?: string
419 }
420
421 type ClickOptions = {
422 button?: number | string,
423 x?: number,
424 y?: number
425 }
426
427 type WaitUntilOptions = {
428 timeout?: number,
429 timeoutMsg?: string,
430 interval?: number
431 }
432
433 type DragAndDropCoordinate = {
434 x: number,
435 y: number
436 }
437
438 interface Element {
439 selector: string;
440 elementId: string;
441
442 /**
443 * w3c
444 */
445 "element-6066-11e4-a52e-4f735466cecf"?: string;
446
447 /**
448 * jsonwp
449 */
450 ELEMENT?: string;
451
452 /**
453 * index in array of elements
454 * only applicable if the element found with `$$` command
455 */
456 index?: number;
457
458 /**
459 * WebdriverIO.Element or WebdriverIO.BrowserObject
460 */
461 parent: Element | WebdriverIO.BrowserObject;
462
463 /**
464 * add command to `element` scope
465 */
466 addCommand(
467 name: string,
468 func: Function
469 ): void;
470
471 /**
472 * The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver.html#findelements) command in order
473 * to fetch multiple elements on the page similar to the `$$` command from the browser scope. The difference when calling
474 * it from an element scope is that the driver will look within the children of that element.
475 */
476 $$(
477 selector: string | Function | Matcher
478 ): Promise<ElementArray>;
479
480 /**
481 * The `$` command is a short way to call the [`findElement`](/docs/api/webdriver.html#findelement) command in order
482 * to fetch a single element on the page similar to the `$` command from the browser scope. The difference when calling
483 * it from an element scope is that the driver will look within the children of that element. You can also pass in an object as selector
484 * where the object contains a property `element-6066-11e4-a52e-4f735466cecf` with the value of a reference
485 * to an element. The command will then transform the reference to an extended WebdriverIO element.
486 */
487 $(
488 selector: string | Function | Matcher
489 ): Promise<Element>;
490
491 /**
492 * Add a value to an object found by given selector. You can also use unicode
493 * characters like Left arrow or Back space. WebdriverIO will take care of
494 * translating them into unicode characters. You’ll find all supported characters
495 * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
496 * To do that, the value has to correspond to a key from the table.
497 */
498 addValue(
499 value: string | number | boolean | object | any[]
500 ): Promise<void>;
501
502 /**
503 * Clear a `<textarea>` or text `<input>` element’s value. Make sure you can interact with the
504 * element before using this command. You can't clear an input element that is disabled or in
505 * readonly mode.
506 */
507 clearValue(): Promise<void>;
508
509 /**
510 * Click on an element.
511 */
512 click(
513 options?: ClickOptions
514 ): Promise<void>;
515
516 /**
517 * The `customs$$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
518 */
519 custom$$(
520 strategyName: string,
521 strategyArguments: any
522 ): Promise<ElementArray>;
523
524 /**
525 * The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
526 */
527 custom$(
528 strategyName: string,
529 strategyArguments: any
530 ): Promise<Element>;
531
532 /**
533 * Double-click on an element.
534 */
535 doubleClick(): Promise<void>;
536
537 /**
538 * Drag an item to a destination element.
539 */
540 dragAndDrop(
541 target: Element | DragAndDropCoordinate,
542 options?: DragAndDropOptions
543 ): Promise<void>;
544
545 /**
546 * Get an attribute from a DOM-element based on the attribute name.
547 */
548 getAttribute(
549 attributeName: string
550 ): Promise<string>;
551
552 /**
553 * Get a css property from a DOM-element selected by given selector. The return value
554 * is formatted to be testable. Colors gets parsed via [rgb2hex](https://www.npmjs.org/package/rgb2hex)
555 * and all other properties get parsed via [css-value](https://www.npmjs.org/package/css-value).
556 */
557 getCSSProperty(
558 cssProperty: string
559 ): Promise<CSSProperty>;
560
561 /**
562 * Get source code of specified DOM element by selector.
563 */
564 getHTML(
565 includeSelectorTag?: boolean
566 ): Promise<string>;
567
568 /**
569 * Determine an element’s location on the page.
570 */
571 getLocation(
572 prop: LocationParam
573 ): Promise<number>;
574
575 /**
576 * Determine an element’s location on the page.
577 */
578 getLocation(): Promise<LocationReturn>;
579
580 /**
581 * The Get Element Property command will return the result of getting a property of an element.
582 */
583 getProperty(
584 property: string
585 ): Promise<object | string | boolean | number>;
586
587 /**
588 * Get the width and height for an DOM-element.
589 */
590 getSize(
591 prop: SizeParam
592 ): Promise<number>;
593
594 /**
595 * Get the width and height for an DOM-element.
596 */
597 getSize(): Promise<SizeReturn>;
598
599 /**
600 * Get tag name of a DOM-element.
601 */
602 getTagName(): Promise<string>;
603
604 /**
605 * Get the text content from a DOM-element. Make sure the element
606 * you want to request the text from [is interactable](http://www.w3.org/TR/webdriver/#interactable)
607 * otherwise you will get an empty string as return value. If the element is disabled or not
608 * visible and you still want to receive the text content use [getHTML](https://webdriver.io/docs/api/element/getHTML.html)
609 * as a workaround.
610 */
611 getText(): Promise<string>;
612
613 /**
614 * Get the value of a `<textarea>`, `<select>` or text `<input>` found by given selector.
615 * If multiple elements are found via the given selector, an array of values is returned instead.
616 * For input with checkbox or radio type use isSelected.
617 */
618 getValue(): Promise<string>;
619
620 /**
621 * Return true if the selected DOM-element:
622 * - exists;
623 * - is visible;
624 * - is within viewport (if not try scroll to it);
625 * - its center is not overlapped with another element;
626 * - is not disabled.
627 */
628 isClickable(): Promise<boolean>;
629
630 /**
631 * Return true if the selected DOM-element is displayed.
632 */
633 isDisplayed(): Promise<boolean>;
634
635 /**
636 * Return true if the selected DOM-element found by given selector is partially visible and within the viewport.
637 */
638 isDisplayedInViewport(): Promise<boolean>;
639
640 /**
641 * Return true or false if the selected DOM-element is enabled.
642 */
643 isEnabled(): Promise<boolean>;
644
645 /**
646 * Return true if the selected element matches with the provided one.
647 */
648 isEqual(
649 el: Element
650 ): Promise<boolean>;
651
652 /**
653 * Returns true if element exists in the DOM
654 */
655 isExisting(): Promise<boolean>;
656
657 /**
658 * Return true or false if the selected DOM-element currently has focus. If the selector matches
659 * multiple elements, it will return true if one of the elements has focus.
660 */
661 isFocused(): Promise<boolean>;
662
663 /**
664 * Will return true or false whether or not an `<option>` or `<input>` element of type
665 * checkbox or radio is currently selected.
666 */
667 isSelected(): Promise<boolean>;
668
669 /**
670 * Move the mouse by an offset of the specified element. If no element is specified,
671 * the move is relative to the current mouse cursor. If an element is provided but
672 * no offset, the mouse will be moved to the center of the element. If the element
673 * is not visible, it will be scrolled into view.
674 */
675 moveTo(
676 options?: MoveToOptions
677 ): Promise<void>;
678
679 /**
680 * The `react$$` command is a useful command to query multiple React Components
681 * by their actual name and filter them by props and state.
682 */
683 react$$(
684 selector: string,
685 options?: ReactSelectorOptions
686 ): Promise<ElementArray>;
687
688 /**
689 * The `react$` command is a useful command to query React Components by their
690 * actual name and filter them by props and state.
691 */
692 react$(
693 selector: string,
694 options?: ReactSelectorOptions
695 ): Promise<Element>;
696
697 /**
698 * Save a screenshot of an element to a PNG file on your OS.
699 */
700 saveScreenshot(
701 filename: string
702 ): Promise<Buffer>;
703
704 /**
705 * Scroll element into viewport ([MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)).
706 */
707 scrollIntoView(
708 scrollIntoViewOptions?: object | boolean
709 ): Promise<void>;
710
711 /**
712 * Select option with a specific value.
713 */
714 selectByAttribute(
715 attribute: string,
716 value: string
717 ): Promise<void>;
718
719 /**
720 * Select option with a specific index.
721 */
722 selectByIndex(
723 index: number
724 ): Promise<void>;
725
726 /**
727 * Select option with displayed text matching the argument.
728 */
729 selectByVisibleText(
730 text: string
731 ): Promise<void>;
732
733 /**
734 * Send a sequence of key strokes to an element (clears value before). If the element
735 * doesn't need to be cleared first then use addValue. You can also use
736 * unicode characters like Left arrow or Back space. WebdriverIO will take care of
737 * translating them into unicode characters. You’ll find all supported characters
738 * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
739 * To do that, the value has to correspond to a key from the table.
740 */
741 setValue(
742 value: string | number | boolean | object | any[]
743 ): Promise<void>;
744
745 /**
746 * Access elements inside a given element's shadowRoot
747 */
748 shadow$$(
749 selector: string | Function
750 ): Promise<ElementArray>;
751
752 /**
753 * Access an element inside a given element's shadowRoot
754 */
755 shadow$(
756 selector: string | Function
757 ): Promise<Element>;
758
759 /**
760 * The Touch Action API provides the basis of all gestures that can be automated in Appium.
761 * It is currently only available to native apps and can not be used to interact with webapps.
762 * At its core is the ability to chain together _ad hoc_ individual actions, which will then be
763 * applied to an element in the application on the device. The basic actions that can be used are:
764 */
765 touchAction(
766 action: TouchActions
767 ): Promise<void>;
768
769 /**
770 * Wait for an element for the provided amount of
771 * milliseconds to be clickable or not clickable.
772 */
773 waitForClickable(
774 options?: WaitForOptions
775 ): Promise<boolean>;
776
777 /**
778 * Wait for an element for the provided amount of
779 * milliseconds to be displayed or not displayed.
780 */
781 waitForDisplayed(
782 options?: WaitForOptions
783 ): Promise<boolean>;
784
785 /**
786 * Wait for an element (selected by css selector) for the provided amount of
787 * milliseconds to be (dis/en)abled. If multiple elements get queried by given
788 * selector, it returns true if at least one element is (dis/en)abled.
789 */
790 waitForEnabled(
791 options?: WaitForOptions
792 ): Promise<boolean>;
793
794 /**
795 * Wait for an element for the provided amount of
796 * milliseconds to be present within the DOM. Returns true if the selector
797 * matches at least one element that exists in the DOM, otherwise throws an
798 * error. If the reverse flag is true, the command will instead return true
799 * if the selector does not match any elements.
800 */
801 waitForExist(
802 options?: WaitForOptions
803 ): Promise<boolean>;
804
805 /**
806 * This wait command is your universal weapon if you want to wait on something. It expects a condition
807 * and waits until that condition is fulfilled with a truthy value. If you use the WDIO testrunner the
808 * commands within the condition are getting executed synchronously like in your test.
809 */
810 waitUntil(
811 condition: () => Promise<Boolean>,
812 options?: WaitUntilOptions
813 ): Promise<boolean>;
814 }
815
816 interface ElementArray extends Array<Element> {
817 selector: string | Function;
818 parent: Element | WebdriverIO.BrowserObject;
819 foundWith: string;
820 props: any[];
821 }
822
823 interface Timeouts {
824 implicit?: number,
825 pageLoad?: number,
826 script?: number
827 }
828
829 interface Browser extends WebDriver.BaseClient {
830 config: Config;
831 options: RemoteOptions;
832
833 /**
834 * add command to `browser` or `element` scope
835 */
836 addCommand(
837 name: string,
838 func: Function,
839 attachToElement?: boolean
840 ): void;
841
842 /**
843 * overwrite `browser` or `element` command
844 */
845 overwriteCommand(
846 name: string,
847 func: (origCommand: Function, ...args: any[]) => any,
848 attachToElement?: boolean
849 ): void;
850
851 /**
852 * create custom selector
853 */
854 addLocatorStrategy(
855 name: string,
856 func: (elementFetchingMethod: (selector: string) => any) => void
857 ): void
858
859 /**
860 * The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver.html#findelements) command in order
861 * to fetch multiple elements on the page. It returns an array with element results that will have an
862 * extended prototype to call action commands without passing in a selector. However if you still pass
863 * in a selector it will look for that element first and call the action on that element.
864 */
865 $$(
866 selector: string | Function
867 ): Promise<ElementArray>;
868
869 /**
870 * The `$` command is a short way to call the [`findElement`](/docs/api/webdriver.html#findelement) command in order
871 * to fetch a single element on the page. It returns an object that with an extended prototype to call
872 * action commands without passing in a selector. However if you still pass in a selector it will look
873 * for that element first and call the action on that element. You can also pass in an object as selector
874 * where the object contains a property `element-6066-11e4-a52e-4f735466cecf` with the value of a reference
875 * to an element. The command will then transform the reference to an extended WebdriverIO element.
876 */
877 $(
878 selector: string | Function | object
879 ): Promise<Element>;
880
881 /**
882 * The `customs$$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
883 */
884 custom$$(
885 strategyName: string,
886 strategyArguments: any
887 ): Promise<ElementArray>;
888
889 /**
890 * The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
891 */
892 custom$(
893 strategyName: string,
894 strategyArguments: any
895 ): Promise<Element>;
896
897 /**
898 * This command helps you to debug your integration tests. It stops the running browser and gives
899 * you time to jump into it and check the state of your application (e.g. using dev tools).
900 * Your terminal transforms into a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
901 * interface that will allow you to try out certain commands, find elements and test actions on
902 * them.
903 */
904 debug(): Promise<void>;
905
906 /**
907 * Delete cookies visible to the current page. By providing a cookie name it just removes the single cookie or more when multiple names are passed.
908 */
909 deleteCookies(
910 names?: string | string[]
911 ): Promise<void>;
912
913 /**
914 * Retrieve a [cookie](https://w3c.github.io/webdriver/webdriver-spec.html#cookies)
915 * visible to the current page. You can query a specific cookie by providing the cookie name or
916 * retrieve all.
917 */
918 getCookies(
919 names?: string[] | string
920 ): Promise<WebDriver.Cookie[]>;
921
922 /**
923 * Returns browser window size (and position for drivers with W3C support).
924 */
925 getWindowSize(): Promise<WebDriver.RectReturn>;
926
927 /**
928 * Send a sequence of key strokes to the active element. You can also use characters like
929 * "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
930 * characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
931 * To do that, the value has to correspond to a key from the table.
932 */
933 keys(
934 value: string | string[]
935 ): Promise<void>;
936
937 /**
938 * Open new window in browser. This command is the equivalent function to `window.open()`. This command does not
939 * work in mobile environments.
940 */
941 newWindow(
942 url: string,
943 options?: NewWindowOptions
944 ): Promise<string>;
945
946 /**
947 * Pauses execution for a specific amount of time. It is recommended to not use this command to wait for an
948 * element to show up. In order to avoid flaky test results it is better to use commands like
949 * [`waitForExist`](/docs/api/element/waitForExist.html) or other waitFor* commands.
950 */
951 pause(
952 milliseconds: number
953 ): Promise<void>;
954
955 /**
956 * The `react$$` command is a useful command to query multiple React Components
957 * by their actual name and filter them by props and state.
958 */
959 react$$(
960 selector: string,
961 options?: ReactSelectorOptions
962 ): Promise<ElementArray>;
963
964 /**
965 * The `react$` command is a useful command to query React Components by their
966 * actual name and filter them by props and state.
967 */
968 react$(
969 selector: string,
970 options?: ReactSelectorOptions
971 ): Promise<Element>;
972
973 /**
974 * Creates a new Selenium session with your current capabilities. This is useful if you
975 * test highly stateful application where you need to clean the browser session between
976 * the tests in your spec file to avoid creating hundreds of single test files with WDIO.
977 * Be careful though, this command affects your test time tremendously since spawning
978 * new Selenium sessions is very time consuming especially when using cloud services.
979 */
980 reloadSession(): Promise<void>;
981
982 /**
983 * Appium only. Save a video started by startRecordingScreen command to file.
984 * See [Appium docs](http://appium.io/docs/en/commands/device/recording-screen/start-recording-screen/)
985 */
986 saveRecordingScreen(
987 filepath: string
988 ): Promise<Buffer>;
989
990 /**
991 * Save a screenshot of the current browsing context to a PNG file on your OS. Be aware that
992 * some browser drivers take screenshots of the whole document (e.g. Geckodriver with Firefox)
993 * and others only of the current viewport (e.g. Chromedriver with Chrome).
994 */
995 saveScreenshot(
996 filepath: string
997 ): Promise<Buffer>;
998
999 /**
1000 * Sets one or more [cookies](https://w3c.github.io/webdriver/#cookies) for the current page. Make sure you are
1001 * on the page that should receive the cookie. You can't set a cookie for an arbitrary page without
1002 * being on that page.
1003 */
1004 setCookies(
1005 cookie: WebDriver.Cookie[] | WebDriver.Cookie
1006 ): Promise<void>;
1007
1008 /**
1009 * Sets the timeouts associated with the current session, timeout durations control such
1010 * behaviour as timeouts on script injection, document navigation, and element retrieval.
1011 * For more information and examples, see [timeouts guide](https://webdriver.io/docs/timeouts.html#selenium-timeouts).
1012 */
1013 setTimeout(
1014 timeouts: Timeouts
1015 ): Promise<void>;
1016
1017 /**
1018 * Resizes browser window outer size according to provided width and height.
1019 */
1020 setWindowSize(
1021 width: number,
1022 height: number
1023 ): Promise<null | object>;
1024
1025 /**
1026 * Switch focus to a particular tab / window.
1027 */
1028 switchWindow(
1029 urlOrTitleToMatch: string | RegExp
1030 ): Promise<void>;
1031
1032 /**
1033 * The Touch Action API provides the basis of all gestures that can be automated in Appium.
1034 * It is currently only available to native apps and can not be used to interact with webapps.
1035 * At its core is the ability to chain together _ad hoc_ individual actions, which will then be
1036 * applied to an element in the application on the device. The basic actions that can be used are:
1037 */
1038 touchAction(
1039 action: TouchActions
1040 ): Promise<void>;
1041
1042 /**
1043 * Uploads a file to the Selenium Standalone server or other browser driver
1044 * (e.g. Chromedriver) by using the [`file`](/api/protocol/file.html) command.
1045 * _Note:_ that this command is only supported if you use a Selenium Hub or
1046 * Chromedriver directly.
1047 */
1048 uploadFile(
1049 localPath: string
1050 ): Promise<string>;
1051
1052 /**
1053 * Protocol binding to load the URL of the browser. If a baseUrl is
1054 * specified in the config, it will be prepended to the url parameter using
1055 * node's url.resolve() method.
1056 */
1057 url(
1058 url?: string
1059 ): Promise<void>;
1060
1061 /**
1062 * This wait command is your universal weapon if you want to wait on something. It expects a condition
1063 * and waits until that condition is fulfilled with a truthy value. If you use the WDIO testrunner the
1064 * commands within the condition are getting executed synchronously like in your test.
1065 */
1066 waitUntil(
1067 condition: () => Promise<Boolean>,
1068 options?: WaitUntilOptions
1069 ): Promise<boolean>;
1070 }
1071
1072 interface Config extends Options, Omit<WebDriver.Options, "capabilities">, Hooks {}
1073}