@appium/types 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/driver.ts CHANGED
@@ -12,11 +12,22 @@ import {
12
12
  BaseDriverCapConstraints,
13
13
  W3CCapabilities,
14
14
  Capabilities,
15
+ ExecuteMethodMap,
15
16
  } from '.';
16
17
  import {ServerArgs} from './config';
17
18
  import {AsyncReturnType, ConditionalPick} from 'type-fest';
18
19
 
19
20
  export interface ITimeoutCommands {
21
+ /**
22
+ * Set the various timeouts associated with a session
23
+ * @see {@link https://w3c.github.io/webdriver/#set-timeouts}
24
+ *
25
+ * @param type - used only for the old (JSONWP) command, the type of the timeout
26
+ * @param ms - used only for the old (JSONWP) command, the ms for the timeout
27
+ * @param script - the number in ms for the script timeout, used for the W3C command
28
+ * @param pageLoad - the number in ms for the pageLoad timeout, used for the W3C command
29
+ * @param implicit - the number in ms for the implicit wait timeout, used for the W3C command
30
+ */
20
31
  timeouts(
21
32
  type: string,
22
33
  ms: number | string,
@@ -24,43 +35,157 @@ export interface ITimeoutCommands {
24
35
  pageLoad?: number,
25
36
  implicit?: number | string
26
37
  ): Promise<void>;
38
+
39
+ /**
40
+ * Set the new command timeout
41
+ *
42
+ * @param ms - the timeout in ms
43
+ */
27
44
  setNewCommandTimeout(ms: number): void;
45
+
46
+ /**
47
+ * Set the implicit wait timeout
48
+ *
49
+ * @param ms - the timeout in ms
50
+ *
51
+ * @deprecated Use `timeouts` instead
52
+ */
28
53
  implicitWait(ms: number | string): Promise<void>;
54
+
55
+ /**
56
+ * A helper method (not a command) used to set the implicit wait value
57
+ *
58
+ * @param ms - the implicit wait in ms
59
+ */
29
60
  setImplicitWait(ms: number): void;
61
+
62
+ /**
63
+ * Periodically retry an async function up until the currently set implicit wait timeout
64
+ *
65
+ * @param condition - the behaviour to retry until it returns truthy
66
+ *
67
+ * @returns The return value of the condition
68
+ */
30
69
  implicitWaitForCondition(condition: () => Promise<any>): Promise<unknown>;
70
+
71
+ /**
72
+ * Get the current timeouts
73
+ * @see {@link https://w3c.github.io/webdriver/#get-timeouts}
74
+ *
75
+ * @returns A map of timeout names to ms values
76
+ */
31
77
  getTimeouts(): Promise<Record<string, number>>;
78
+
79
+ /**
80
+ * Set the implicit wait value that was sent in via the W3C protocol
81
+ *
82
+ * @param ms - the timeout in ms
83
+ */
32
84
  implicitWaitW3C(ms: number): Promise<void>;
85
+
86
+ /**
87
+ * Set the implicit wait value that was sent in via the JSONWP
88
+ *
89
+ * @param ms - the timeout in ms
90
+ * @deprecated
91
+ */
33
92
  implicitWaitMJSONWP(ms: number): Promise<void>;
93
+
94
+ /**
95
+ * Set the page load timeout value that was sent in via the W3C protocol
96
+ *
97
+ * @param ms - the timeout in ms
98
+ */
34
99
  pageLoadTimeoutW3C(ms: number): Promise<void>;
100
+
101
+ /**
102
+ * Set the page load timeout value that was sent in via the JSONWP
103
+ *
104
+ * @param ms - the timeout in ms
105
+ * @deprecated
106
+ */
35
107
  pageLoadTimeoutMJSONWP(ms: number): Promise<void>;
108
+
109
+ /**
110
+ * Set the script timeout value that was sent in via the W3C protocol
111
+ *
112
+ * @param ms - the timeout in ms
113
+ */
36
114
  scriptTimeoutW3C(ms: number): Promise<void>;
115
+
116
+ /**
117
+ * Set the script timeout value that was sent in via the JSONWP
118
+ *
119
+ * @param ms - the timeout in ms
120
+ * @deprecated
121
+ */
37
122
  scriptTimeoutMJSONWP(ms: number): Promise<void>;
123
+
124
+ /**
125
+ * Set Appium's new command timeout
126
+ *
127
+ * @param ms - the timeout in ms
128
+ */
38
129
  newCommandTimeout(ms: number): Promise<void>;
130
+
131
+ /**
132
+ * Get a timeout value from a number or a string
133
+ *
134
+ * @param ms - the timeout value as a number or a string
135
+ *
136
+ * @returns The timeout as a number in ms
137
+ */
39
138
  parseTimeoutArgument(ms: number | string): number;
40
139
  }
41
140
 
42
141
  export interface IEventCommands {
142
+ /**
143
+ * Add a custom-named event to the Appium event log
144
+ *
145
+ * @param vendor - the name of the vendor or tool the event belongs to, to namespace the event
146
+ * @param event - the name of the event itself
147
+ */
43
148
  logCustomEvent(vendor: string, event: string): Promise<void>;
149
+
150
+ /**
151
+ * Get a list of events that have occurred in the current session
152
+ *
153
+ * @param type - filter the returned events by including one or more types
154
+ *
155
+ * @returns The event history for the session
156
+ */
44
157
  getLogEvents(type?: string | string[]): Promise<EventHistory | Record<string, number>>;
45
158
  }
46
159
 
47
160
  export interface ISessionCommands {
161
+ /**
162
+ * Get data for all sessions running on an Appium server
163
+ *
164
+ * @returns A list of session data objects
165
+ */
48
166
  getSessions(): Promise<MultiSessionData[]>;
167
+
168
+ /**
169
+ * Get the data for the current session
170
+ *
171
+ * @returns A session data object
172
+ */
49
173
  getSession(): Promise<SingularSessionData>;
50
174
  }
51
175
 
52
176
  export interface IExecuteCommands {
177
+ /**
178
+ * Call an `Execute Method` by its name with the given arguments. This method will check that the
179
+ * driver has registered the method matching the name, and send it the arguments.
180
+ *
181
+ * @param script - the name of the Execute Method
182
+ * @param args - a singleton array containing an arguments object
183
+ *
184
+ * @returns The result of calling the Execute Method
185
+ */
53
186
  executeMethod(script: string, args: [StringRecord] | []): Promise<any>;
54
187
  }
55
188
 
56
- export interface ExecuteMethodDef<D> {
57
- command: keyof ConditionalPick<Required<D>, DriverCommand>;
58
- params?: {
59
- required?: ReadonlyArray<string>;
60
- optional?: ReadonlyArray<string>;
61
- };
62
- }
63
- export type ExecuteMethodMap<D> = Readonly<Record<string, Readonly<ExecuteMethodDef<D>>>>;
64
189
  export interface MultiSessionData<
65
190
  C extends Constraints = BaseDriverCapConstraints,
66
191
  Extra extends StringRecord | void = void
@@ -75,15 +200,100 @@ export type SingularSessionData<
75
200
  > = Capabilities<C, Extra> & {events?: EventHistory; error?: string};
76
201
 
77
202
  export interface IFindCommands<Ctx = any> {
203
+ /**
204
+ * Find a UI element given a locator strategy and a selector, erroring if it can't be found
205
+ * @see {@link https://w3c.github.io/webdriver/#find-element}
206
+ *
207
+ * @param strategy - the locator strategy
208
+ * @param selector - the selector to combine with the strategy to find the specific element
209
+ *
210
+ * @returns The element object encoding the element id which can be used in element-related
211
+ * commands
212
+ */
78
213
  findElement(strategy: string, selector: string): Promise<Element>;
214
+
215
+ /**
216
+ * Find a a list of all UI elements matching a given a locator strategy and a selector
217
+ * @see {@link https://w3c.github.io/webdriver/#find-elements}
218
+ *
219
+ * @param strategy - the locator strategy
220
+ * @param selector - the selector to combine with the strategy to find the specific elements
221
+ *
222
+ * @returns A possibly-empty list of element objects
223
+ */
79
224
  findElements(strategy: string, selector: string): Promise<Element[]>;
225
+
226
+ /**
227
+ * Find a UI element given a locator strategy and a selector, erroring if it can't be found. Only
228
+ * look for elements among the set of descendants of a given element
229
+ * @see {@link https://w3c.github.io/webdriver/#find-element-from-element}
230
+ *
231
+ * @param strategy - the locator strategy
232
+ * @param selector - the selector to combine with the strategy to find the specific element
233
+ * @param elementId - the id of the element to use as the search basis
234
+ *
235
+ * @returns The element object encoding the element id which can be used in element-related
236
+ * commands
237
+ */
80
238
  findElementFromElement(strategy: string, selector: string, elementId: string): Promise<Element>;
239
+
240
+ /**
241
+ * Find a a list of all UI elements matching a given a locator strategy and a selector. Only
242
+ * look for elements among the set of descendants of a given element
243
+ * @see {@link https://w3c.github.io/webdriver/#find-elements-from-element}
244
+ *
245
+ * @param strategy - the locator strategy
246
+ * @param selector - the selector to combine with the strategy to find the specific elements
247
+ * @param elementId - the id of the element to use as the search basis
248
+ *
249
+ * @returns A possibly-empty list of element objects
250
+ */
81
251
  findElementsFromElement(
82
252
  strategy: string,
83
253
  selector: string,
84
254
  elementId: string
85
255
  ): Promise<Element[]>;
86
256
 
257
+ /**
258
+ * Find an element from a shadow root
259
+ * @see {@link https://w3c.github.io/webdriver/#find-element-from-shadow-root}
260
+ * @param strategy - the locator strategy
261
+ * @param selector - the selector to combine with the strategy to find the specific elements
262
+ * @param shadowId - the id of the element to use as the search basis
263
+ *
264
+ * @returns The element inside the shadow root matching the selector
265
+ */
266
+ findElementFromShadowRoot?(
267
+ strategy: string,
268
+ selector: string,
269
+ shadowId: string
270
+ ): Promise<Element>;
271
+
272
+ /**
273
+ * Find elements from a shadow root
274
+ * @see {@link https://w3c.github.io/webdriver/#find-element-from-shadow-root}
275
+ * @param strategy - the locator strategy
276
+ * @param selector - the selector to combine with the strategy to find the specific elements
277
+ * @param shadowId - the id of the element to use as the search basis
278
+ *
279
+ * @returns A possibly empty list of elements inside the shadow root matching the selector
280
+ */
281
+ findElementsFromShadowRoot?(
282
+ strategy: string,
283
+ selector: string,
284
+ shadowId: string
285
+ ): Promise<Element[]>;
286
+
287
+ /**
288
+ * A helper method that returns one or more UI elements based on the search criteria
289
+ *
290
+ * @param strategy - the locator strategy
291
+ * @param selector - the selector
292
+ * @param mult - whether or not we want to find multiple elements
293
+ * @param context - the element to use as the search context basis if desiredCapabilities
294
+ *
295
+ * @returns A single element or list of elements
296
+ */
87
297
  findElOrEls<Mult extends boolean>(
88
298
  strategy: string,
89
299
  selector: string,
@@ -91,6 +301,17 @@ export interface IFindCommands<Ctx = any> {
91
301
  context?: Ctx
92
302
  ): Promise<Mult extends true ? Element[] : Element>;
93
303
 
304
+ /**
305
+ * This is a wrapper for {@linkcode IFindCommands.findElOrEls} that validates locator strategies
306
+ * and implements the `appium:printPageSourceOnFindFailure` capability
307
+ *
308
+ * @param strategy - the locator strategy
309
+ * @param selector - the selector
310
+ * @param mult - whether or not we want to find multiple elements
311
+ * @param context - the element to use as the search context basis if desiredCapabilities
312
+ *
313
+ * @returns A single element or list of elements
314
+ */
94
315
  findElOrElsWithProcessing<Mult extends boolean>(
95
316
  strategy: string,
96
317
  selector: string,
@@ -98,6 +319,12 @@ export interface IFindCommands<Ctx = any> {
98
319
  context?: Ctx
99
320
  ): Promise<Mult extends true ? Element[] : Element>;
100
321
 
322
+ /**
323
+ * Get the current page/app source as HTML/XML
324
+ * @see {@link https://w3c.github.io/webdriver/#get-page-source}
325
+ *
326
+ * @returns The UI hierarchy in a platform-appropriate format (e.g., HTML for a web page)
327
+ */
101
328
  getPageSource(): Promise<string>;
102
329
  }
103
330
 
@@ -152,7 +379,19 @@ export interface LogDef<C extends Constraints, T = unknown> {
152
379
  }
153
380
 
154
381
  export interface ISettingsCommands {
382
+ /**
383
+ * Update the session's settings dictionary with a new settings object
384
+ *
385
+ * @param settings - A key-value map of setting names to values. Settings not named in the map
386
+ * will not have their value adjusted.
387
+ */
155
388
  updateSettings: (settings: StringRecord) => Promise<void>;
389
+
390
+ /**
391
+ * Get the current settings for the session
392
+ *
393
+ * @returns The settings object
394
+ */
156
395
  getSettings(): Promise<StringRecord>;
157
396
  }
158
397
 
@@ -162,13 +401,37 @@ export interface SessionHandler<
162
401
  C extends Constraints = BaseDriverCapConstraints,
163
402
  Extra extends StringRecord | void = void
164
403
  > {
404
+ /**
405
+ * Start a new automation session
406
+ * @see {@link https://w3c.github.io/webdriver/#new-session}
407
+ *
408
+ * @remarks
409
+ * The shape of this method is strange because it used to support both JSONWP and W3C
410
+ * capabilities. This will likely change in the future to simplify.
411
+ *
412
+ * @param w3cCaps1 - the new session capabilities
413
+ * @param w3cCaps2 - another place the new session capabilities could be sent (typically left undefined)
414
+ * @param w3cCaps - another place the new session capabilities could be sent (typically left undefined)
415
+ * @param driverData - a list of DriverData objects representing other sessions running for this
416
+ * driver on the same Appium server. This information can be used to help ensure no conflict of
417
+ * resources
418
+ *
419
+ * @returns The capabilities object representing the created session
420
+ */
165
421
  createSession(
166
422
  w3cCaps1: W3CCapabilities<C, Extra>,
167
423
  w3cCaps2?: W3CCapabilities<C, Extra>,
168
- w3cCaps?: W3CCapabilities<C, Extra>,
424
+ w3cCaps3?: W3CCapabilities<C, Extra>,
169
425
  driverData?: DriverData[]
170
426
  ): Promise<CreateResult>;
171
427
 
428
+ /**
429
+ * Stop an automation session
430
+ * @see {@link https://w3c.github.io/webdriver/#delete-session}
431
+ *
432
+ * @param sessionId - the id of the session that is to be deleted
433
+ * @param driverData - the driver data for other currently-running sessions
434
+ */
172
435
  deleteSession(sessionId?: string, driverData?: DriverData[]): Promise<DeleteResult>;
173
436
  }
174
437
 
@@ -251,7 +514,7 @@ export interface Cookie {
251
514
 
252
515
  // Appium W3C WebDriver Extension
253
516
 
254
- export interface ScreenRecordOptions {
517
+ export interface StartScreenRecordOptions {
255
518
  remotePath?: string;
256
519
  username?: string;
257
520
  password?: string;
@@ -267,6 +530,16 @@ export interface ScreenRecordOptions {
267
530
  bugReport?: string;
268
531
  }
269
532
 
533
+ export interface StopScreenRecordOptions {
534
+ remotePath?: string;
535
+ user?: string;
536
+ pass?: string;
537
+ method?: string;
538
+ headers?: Record<string, string>;
539
+ fileFieldName?: string;
540
+ formFields: Record<string, string> | Array<[string, string]>;
541
+ }
542
+
270
543
  // JSONWP
271
544
 
272
545
  export type Size = Pick<Rect, 'width' | 'height'>;
@@ -374,17 +647,88 @@ export interface Driver<
374
647
  IExecuteCommands,
375
648
  SessionHandler<[string, any], void, C>,
376
649
  Core {
650
+ /**
651
+ * The set of command line arguments set for this driver
652
+ */
377
653
  cliArgs: CArgs;
654
+
378
655
  // The following methods are implemented by `BaseDriver`.
656
+
657
+ /**
658
+ * Execute a driver (WebDriver-protocol) command by its name as defined in the routes file
659
+ *
660
+ * @param cmd - the name of the command
661
+ * @param args - arguments to pass to the command
662
+ *
663
+ * @returns The result of running the command
664
+ */
379
665
  executeCommand(cmd: string, ...args: any[]): Promise<any>;
666
+
667
+ /**
668
+ * Signify to any owning processes that this driver encountered an error which should cause the
669
+ * session to terminate immediately (for example an upstream service failed)
670
+ *
671
+ * @param err - the Error object which is causing the shutdown
672
+ */
380
673
  startUnexpectedShutdown(err?: Error): Promise<void>;
674
+
675
+ /**
676
+ * Start the timer for the New Command Timeout, which when it runs out, will stop the current
677
+ * session
678
+ */
381
679
  startNewCommandTimeout(): Promise<void>;
680
+
681
+ /**
682
+ * Reset the current session (run the delete session and create session subroutines)
683
+ *
684
+ * @deprecated Use explicit session management commands instead
685
+ */
382
686
  reset(): Promise<void>;
687
+
688
+ /**
689
+ * The processed capabilities used to start the session represented by the current driver instance
690
+ */
383
691
  caps?: Capabilities<C>;
692
+
693
+ /**
694
+ * The original capabilities used to start the session represented by the current driver instance
695
+ */
384
696
  originalCaps?: W3CCapabilities<C>;
697
+
698
+ /**
699
+ * The constraints object used to validate capabilities
700
+ */
385
701
  desiredCapConstraints: C;
702
+
703
+ /**
704
+ * Validate the capabilities used to start a session
705
+ *
706
+ * @param caps - the capabilities
707
+ *
708
+ * @internal
709
+ *
710
+ * @returns Whether or not the capabilities are valid
711
+ */
386
712
  validateDesiredCaps(caps: Capabilities<C>): boolean;
713
+
714
+ /**
715
+ * A helper function to log unrecognized capabilities to the console
716
+ *
717
+ * @params caps - the capabilities
718
+ *
719
+ * @internal
720
+ */
387
721
  logExtraCaps(caps: Capabilities<C>): void;
722
+
723
+ /**
724
+ * A helper function used to assign server information to the driver instance so the driver knows
725
+ * where the server is Running
726
+ *
727
+ * @param server - the server object
728
+ * @param host - the server hostname
729
+ * @param port - the server port
730
+ * @param path - the server base url
731
+ */
388
732
  assignServer?(server: AppiumServer, host: string, port: number, path: string): void;
389
733
  }
390
734
 
@@ -400,80 +744,655 @@ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints
400
744
  serverPort?: number;
401
745
  serverPath?: string;
402
746
 
403
- // WebDriver
747
+ // WebDriver spec commands
748
+
749
+ /**
750
+ * Navigate to a given url
751
+ * @see {@link https://w3c.github.io/webdriver/#navigate-to}
752
+ *
753
+ * @param url - the url
754
+ */
404
755
  setUrl?(url: string): Promise<void>;
756
+
757
+ /**
758
+ * Get the current url
759
+ * @see {@link https://w3c.github.io/webdriver/#get-current-url}
760
+ *
761
+ * @returns The url
762
+ */
405
763
  getUrl?(): Promise<string>;
764
+
765
+ /**
766
+ * Navigate back in the page history
767
+ * @see {@link https://w3c.github.io/webdriver/#back}
768
+ */
406
769
  back?(): Promise<void>;
770
+
771
+ /**
772
+ * Navigate forward in the page history
773
+ * @see {@link https://w3c.github.io/webdriver/#forward}
774
+ */
407
775
  forward?(): Promise<void>;
776
+
777
+ /**
778
+ * Refresh the page
779
+ * @see {@link https://w3c.github.io/webdriver/#refresh}
780
+ */
408
781
  refresh?(): Promise<void>;
782
+
783
+ /**
784
+ * Get the current page title
785
+ * @see {@link https://w3c.github.io/webdriver/#get-title}
786
+ *
787
+ * @returns The title
788
+ *
789
+ * @example
790
+ * ```js
791
+ * await driver.getTitle()
792
+ * ```
793
+ * ```py
794
+ * driver.title
795
+ * ```
796
+ * ```java
797
+ * driver.getTitle();
798
+ * ```
799
+ */
409
800
  title?(): Promise<string>;
801
+
802
+ /**
803
+ * Get the handle (id) associated with the current browser window
804
+ * @see {@link https://w3c.github.io/webdriver/#get-window-handle}
805
+ *
806
+ * @returns The handle string
807
+ */
410
808
  getWindowHandle?(): Promise<string>;
809
+
810
+ /**
811
+ * Close the current browsing context (window)
812
+ * @see {@link https://w3c.github.io/webdriver/#close-window}
813
+ *
814
+ * @returns An array of window handles representing currently-open windows
815
+ */
411
816
  closeWindow?(): Promise<string[]>;
817
+
818
+ /**
819
+ * Switch to a specified window
820
+ * @see {@link https://w3c.github.io/webdriver/#switch-to-window}
821
+ *
822
+ * @param handle - the window handle of the window to make active
823
+ */
412
824
  setWindow?(handle: string): Promise<void>;
825
+
826
+ /**
827
+ * Get a set of handles representing open browser windows
828
+ * @see {@link https://w3c.github.io/webdriver/#get-window-handles}
829
+ *
830
+ * @returns An array of window handles representing currently-open windows
831
+ */
413
832
  getWindowHandles?(): Promise<string[]>;
833
+
834
+ /**
835
+ * Create a new browser window
836
+ * @see {@link https://w3c.github.io/webdriver/#new-window}
837
+ *
838
+ * @param type - a hint to the driver whether to create a "tab" or "window"
839
+ *
840
+ * @returns An object containing the handle of the newly created window and its type
841
+ */
842
+ createNewWindow?(type?: NewWindowType): Promise<NewWindow>;
843
+
844
+ /**
845
+ * Switch the current browsing context to a frame
846
+ * @see {@link https://w3c.github.io/webdriver/#switch-to-frame}
847
+ *
848
+ * @param id - the frame id, index, or `null` (indicating the top-level context)
849
+ */
414
850
  setFrame?(id: null | number | string): Promise<void>;
851
+
852
+ /**
853
+ * Set the current browsing context to the parent of the current context
854
+ * @see {@link https://w3c.github.io/webdriver/#switch-to-parent-frame}
855
+ */
856
+ switchToParentFrame?(): Promise<void>;
857
+
858
+ /**
859
+ * Get the size and position of the current window
860
+ * @see {@link https://w3c.github.io/webdriver/#get-window-rect}
861
+ *
862
+ * @returns A `Rect` JSON object with x, y, width, and height properties
863
+ */
415
864
  getWindowRect?(): Promise<Rect>;
865
+
866
+ /**
867
+ * Set the current window's size and position
868
+ * @see {@link https://w3c.github.io/webdriver/#set-window-rect}
869
+ *
870
+ * @param x - the screen coordinate for the new left edge of the window
871
+ * @param y - the screen coordinate for the new top edge of the window
872
+ * @param width - the width in pixels to resize the window to
873
+ * @param height - the height in pixels to resize the window to
874
+ *
875
+ * @returns The actual `Rect` of the window after running the command
876
+ */
416
877
  setWindowRect?(x: number, y: number, width: number, height: number): Promise<Rect>;
878
+
879
+ /**
880
+ * Run the window-manager specific 'maximize' operation on the current window
881
+ * @see {@link https://w3c.github.io/webdriver/#maximize-window}
882
+ *
883
+ * @returns The actual `Rect` of the window after running the command
884
+ */
417
885
  maximizeWindow?(): Promise<Rect>;
886
+
887
+ /**
888
+ * Run the window-manager specific 'minimize' operation on the current window
889
+ * @see {@link https://w3c.github.io/webdriver/#minimize-window}
890
+ *
891
+ * @returns The actual `Rect` of the window after running the command
892
+ */
418
893
  minimizeWindow?(): Promise<Rect>;
894
+
895
+ /**
896
+ * Put the current window into full screen mode
897
+ * @see {@link https://w3c.github.io/webdriver/#fullscreen-window}
898
+ *
899
+ * @returns The actual `Rect` of the window after running the command
900
+ */
419
901
  fullScreenWindow?(): Promise<Rect>;
420
- createNewWindow?(type?: NewWindowType): Promise<NewWindow>;
902
+
903
+ /**
904
+ * Get the active element
905
+ * @see {@link https://w3c.github.io/webdriver/#get-active-element}
906
+ *
907
+ * @returns The JSON object encapsulating the active element reference
908
+ */
421
909
  active?(): Promise<Element>;
910
+
911
+ /**
912
+ * Get the shadow root of an element
913
+ * @see {@link https://w3c.github.io/webdriver/#get-element-shadow-root}
914
+ *
915
+ * @param elementId - the id of the element to retrieve the shadow root for
916
+ *
917
+ * @returns The shadow root for an element, as an element
918
+ */
919
+ elementShadowRoot?(elementId: string): Promise<Element>;
920
+
921
+ /**
922
+ * Determine if the reference element is selected or not
923
+ * @see {@link https://w3c.github.io/webdriver/#is-element-selected}
924
+ *
925
+ * @param elementId - the id of the element
926
+ *
927
+ * @returns True if the element is selected, False otherwise
928
+ */
422
929
  elementSelected?(elementId: string): Promise<boolean>;
930
+
931
+ /**
932
+ * Retrieve the value of an element's attribute
933
+ * @see {@link https://w3c.github.io/webdriver/#get-element-attribute}
934
+ *
935
+ * @param name - the attribute name
936
+ * @param elementId - the id of the element
937
+ *
938
+ * @returns The attribute value
939
+ */
423
940
  getAttribute?(name: string, elementId: string): Promise<string | null>;
941
+
942
+ /**
943
+ * Retrieve the value of a named property of an element's JS object
944
+ * @see {@link https://w3c.github.io/webdriver/#get-element-property}
945
+ *
946
+ * @param name - the object property name
947
+ * @param elementId - the id of the element
948
+ *
949
+ * @returns The property value
950
+ */
424
951
  getProperty?(name: string, elementId: string): Promise<string | null>;
952
+
953
+ /**
954
+ * Retrieve the value of a CSS property of an element
955
+ * @see {@link https://w3c.github.io/webdriver/#get-element-css-value}
956
+ *
957
+ * @param name - the CSS property name
958
+ * @param elementId - the id of the element
959
+ *
960
+ * @returns The property value
961
+ */
425
962
  getCssProperty?(name: string, elementId: string): Promise<string>;
963
+
964
+ /**
965
+ * Get the text of an element as rendered
966
+ * @see {@link https://w3c.github.io/webdriver/#get-element-text}
967
+ *
968
+ * @param elementId - the id of the element
969
+ *
970
+ * @returns The text rendered for the element
971
+ */
426
972
  getText?(elementId: string): Promise<string>;
973
+
974
+ /**
975
+ * Get the tag name of an element
976
+ * @see {@link https://w3c.github.io/webdriver/#get-element-tag-name}
977
+ *
978
+ * @param elementId - the id of the element
979
+ *
980
+ * @returns The tag name
981
+ */
427
982
  getName?(elementId: string): Promise<string>;
983
+
984
+ /**
985
+ * Get the dimensions and position of an element
986
+ * @see {@link https://w3c.github.io/webdriver/#get-element-rect}
987
+ *
988
+ * @param elementId - the id of the element
989
+ *
990
+ * @returns The Rect object containing x, y, width, and height properties
991
+ */
428
992
  getElementRect?(elementId: string): Promise<Rect>;
993
+
994
+ /**
995
+ * Determine whether an element is enabled
996
+ * @see {@link https://w3c.github.io/webdriver/#is-element-enabled}
997
+ *
998
+ * @param elementId - the id of the element
999
+ *
1000
+ * @returns True if the element is enabled, False otherwise
1001
+ */
429
1002
  elementEnabled?(elementId: string): Promise<boolean>;
1003
+
1004
+ /**
1005
+ * Get the WAI-ARIA role of an element
1006
+ * @see {@link https://w3c.github.io/webdriver/#get-computed-role}
1007
+ *
1008
+ * @param elementId - the id of the element
1009
+ *
1010
+ * @returns The role
1011
+ */
1012
+ getComputedRole?(elementId: string): Promise<string | null>;
1013
+
1014
+ /**
1015
+ * Get the accessible name/label of an element
1016
+ * @see {@link https://w3c.github.io/webdriver/#get-computed-label}
1017
+ *
1018
+ * @param elementId - the id of the element
1019
+ *
1020
+ * @returns The accessible name
1021
+ */
1022
+ getComputedLabel?(elementId: string): Promise<string | null>;
1023
+
1024
+ /**
1025
+ * Determine whether an element is displayed
1026
+ * @see {@link https://w3c.github.io/webdriver/#element-displayedness}
1027
+ *
1028
+ * @param elementId - the id of the element
1029
+ *
1030
+ * @returns True if any part of the element is rendered within the viewport, False otherwise
1031
+ */
430
1032
  elementDisplayed?(elementId: string): Promise<boolean>;
1033
+
1034
+ /**
1035
+ * Click/tap an element
1036
+ * @see {@link https://w3c.github.io/webdriver/#element-click}
1037
+ *
1038
+ * @param elementId - the id of the element
1039
+ */
431
1040
  click?(elementId: string): Promise<void>;
1041
+
1042
+ /**
1043
+ * Clear the text/value of an editable element
1044
+ * @see {@link https://w3c.github.io/webdriver/#element-clear}
1045
+ *
1046
+ * @param elementId - the id of the element
1047
+ */
432
1048
  clear?(elementId: string): Promise<void>;
1049
+
1050
+ /**
1051
+ * Send keystrokes to an element (or otherwise set its value)
1052
+ * @see {@link https://w3c.github.io/webdriver/#element-send-keys}
1053
+ *
1054
+ * @param text - the text to send to the element
1055
+ * @param elementId - the id of the element
1056
+ */
433
1057
  setValue?(text: string, elementId: string): Promise<void>;
1058
+
1059
+ /**
1060
+ * Execute JavaScript (or some other kind of script) in the browser/app context
1061
+ * @see {@link https://w3c.github.io/webdriver/#execute-script}
1062
+ *
1063
+ * @param script - the string to be evaluated as the script, which will be made the body of an
1064
+ * anonymous function in the case of JS
1065
+ * @param args - the list of arguments to be applied to the script as a function
1066
+ *
1067
+ * @returns The return value of the script execution
1068
+ */
434
1069
  execute?(script: string, args: unknown[]): Promise<unknown>;
1070
+
1071
+ /**
1072
+ * Execute JavaScript (or some other kind of script) in the browser/app context, asynchronously
1073
+ * @see {@link https://w3c.github.io/webdriver/#execute-async-script}
1074
+ *
1075
+ * @param script - the string to be evaluated as the script, which will be made the body of an
1076
+ * anonymous function in the case of JS
1077
+ * @param args - the list of arguments to be applied to the script as a function
1078
+ *
1079
+ * @returns The promise resolution of the return value of the script execution (or an error
1080
+ * object if the promise is rejected)
1081
+ */
435
1082
  executeAsync?(script: string, args: unknown[]): Promise<unknown>;
1083
+
1084
+ /**
1085
+ * Get all cookies known to the browsing context
1086
+ * @see {@link https://w3c.github.io/webdriver/#get-all-cookies}
1087
+ *
1088
+ * @returns A list of serialized cookies
1089
+ */
436
1090
  getCookies?(): Promise<Cookie[]>;
1091
+
1092
+ /**
1093
+ * Get a cookie by name
1094
+ * @see {@link https://w3c.github.io/webdriver/#get-named-cookie}
1095
+ *
1096
+ * @param name - the name of the cookie
1097
+ *
1098
+ * @returns A serialized cookie
1099
+ */
437
1100
  getCookie?(name: string): Promise<Cookie>;
1101
+
1102
+ /**
1103
+ * Add a cookie to the browsing context
1104
+ * @see {@link https://w3c.github.io/webdriver/#add-cookie}
1105
+ *
1106
+ * @param cookie - the cookie data including properties like name, value, path, domain,
1107
+ * secure, httpOnly, expiry, and samesite
1108
+ */
438
1109
  setCookie?(cookie: Cookie): Promise<void>;
1110
+
1111
+ /**
1112
+ * Delete a named cookie
1113
+ * @see {@link https://w3c.github.io/webdriver/#delete-cookie}
1114
+ *
1115
+ * @param name - the name of the cookie to delete
1116
+ */
439
1117
  deleteCookie?(name: string): Promise<void>;
1118
+
1119
+ /**
1120
+ * Delete all cookies
1121
+ * @see {@link https://w3c.github.io/webdriver/#delete-all-cookies}
1122
+ */
440
1123
  deleteCookies?(): Promise<void>;
1124
+
1125
+ /**
1126
+ * Perform touch or keyboard actions
1127
+ * @see {@link https://w3c.github.io/webdriver/#perform-actions}
1128
+ *
1129
+ * @param actions - the action sequence
1130
+ */
441
1131
  performActions?(actions: ActionSequence[]): Promise<void>;
1132
+
1133
+ /**
1134
+ * Release all keys or buttons that are currently pressed
1135
+ * @see {@link https://w3c.github.io/webdriver/#release-actions}
1136
+ */
442
1137
  releaseActions?(): Promise<void>;
1138
+
1139
+ /**
1140
+ * Dismiss a simple dialog/alert
1141
+ * @see {@link https://w3c.github.io/webdriver/#dismiss-alert}
1142
+ */
443
1143
  postDismissAlert?(): Promise<void>;
1144
+
1145
+ /**
1146
+ * Accept a simple dialog/alert
1147
+ * @see {@link https://w3c.github.io/webdriver/#accept-alert}
1148
+ */
444
1149
  postAcceptAlert?(): Promise<void>;
1150
+
1151
+ /**
1152
+ * Get the text of the displayed alert
1153
+ * @see {@link https://w3c.github.io/webdriver/#get-alert-text}
1154
+ *
1155
+ * @returns The text of the alert
1156
+ */
445
1157
  getAlertText?(): Promise<string | null>;
1158
+
1159
+ /**
1160
+ * Set the text field of an alert prompt
1161
+ * @see {@link https://w3c.github.io/webdriver/#send-alert-text}
1162
+ *
1163
+ * @param text - the text to send to the prompt
1164
+ */
446
1165
  setAlertText?(text: string): Promise<void>;
1166
+
1167
+ /**
1168
+ * Get a screenshot of the current document as rendered
1169
+ * @see {@link https://w3c.github.io/webdriver/#take-screenshot}
1170
+ *
1171
+ * @returns A base64-encoded string representing the PNG image data
1172
+ */
447
1173
  getScreenshot?(): Promise<string>;
1174
+
1175
+ /**
1176
+ * Get an image of a single element as rendered on screen
1177
+ * @see {@link https://w3c.github.io/webdriver/#take-element-screenshot}
1178
+ *
1179
+ * @param elementId - the id of the element
1180
+ *
1181
+ * @returns A base64-encoded string representing the PNG image data for the element rect
1182
+ */
448
1183
  getElementScreenshot?(elementId: string): Promise<string>;
449
- getComputedRole?(elementId: string): Promise<string | null>;
450
- getComputedLabel?(elementId: string): Promise<string | null>;
451
1184
 
452
1185
  // Appium W3C WebDriver Extension
1186
+
1187
+ /**
1188
+ * Shake the device
1189
+ *
1190
+ * @deprecated
1191
+ */
453
1192
  mobileShake?(): Promise<void>;
1193
+
1194
+ /**
1195
+ * Get the current time on the device under timeouts
1196
+ *
1197
+ * @param format - the date/time format you would like the response into
1198
+ *
1199
+ * @returns The formatted time
1200
+ */
454
1201
  getDeviceTime?(format?: string): Promise<string>;
1202
+
1203
+ /**
1204
+ * Lock the device, and optionally unlock the device after a certain amount of time
1205
+ *
1206
+ * @param seconds - the number of seconds after which to unlock the device. Set to zero or leave
1207
+ * empty to not unlock the device automatically
1208
+ *
1209
+ * @deprecated
1210
+ */
455
1211
  lock?(seconds?: number): Promise<void>;
1212
+
1213
+ /**
1214
+ * Unlock the device
1215
+ *
1216
+ * @deprecated
1217
+ */
456
1218
  unlock?(): Promise<void>;
1219
+
1220
+ /**
1221
+ * Determine whether the device is locked
1222
+ *
1223
+ * @returns True if the device is locked, false otherwise
1224
+ *
1225
+ * @deprecated
1226
+ */
457
1227
  isLocked?(): Promise<boolean>;
458
- startRecordingScreen?(options?: ScreenRecordOptions): Promise<void>;
459
- stopRecordingScreen?(options?: ScreenRecordOptions): Promise<string>;
1228
+
1229
+ /**
1230
+ * Direct Appium to start recording the device screen
1231
+ *
1232
+ * @param options - parameters for screen recording
1233
+ *
1234
+ * @deprecated
1235
+ */
1236
+ startRecordingScreen?(options?: StartScreenRecordOptions): Promise<void>;
1237
+
1238
+ /**
1239
+ * Direct Appium to stop screen recording and return the video
1240
+ *
1241
+ * @param options - parameters for stopping like video Uploading
1242
+ *
1243
+ * @returns The base64-encoded video data
1244
+ *
1245
+ * @deprecated
1246
+ */
1247
+ stopRecordingScreen?(options?: StopScreenRecordOptions): Promise<string>;
1248
+
1249
+ /**
1250
+ * List the performance data types supported by this driver, which can be used in a call to get
1251
+ * the performance data by type.
1252
+ *
1253
+ * @returns The list of types
1254
+ *
1255
+ * @deprecated
1256
+ */
460
1257
  getPerformanceDataTypes?(): Promise<string[]>;
1258
+
1259
+ /**
1260
+ * Get the list of performance data associated with a given type
1261
+ *
1262
+ * @param packageName - the package name / id of the app to retrieve data for
1263
+ * @param dataType - the performance data type; one of those retrieved in a call to
1264
+ * getPerformanceDataTypes
1265
+ * @param dataReadTimeout - how long to wait for data before timing out
1266
+ *
1267
+ * @returns A list of performance data strings
1268
+ *
1269
+ * @deprecated
1270
+ */
461
1271
  getPerformanceData?(
462
1272
  packageName: string,
463
1273
  dataType: string,
464
1274
  dataReadTimeout?: number
465
1275
  ): Promise<string[]>;
1276
+
1277
+ /**
1278
+ * Press a device hardware key by its code for the default duration
1279
+ *
1280
+ * @param keycode - the keycode
1281
+ * @param metastate - the code denoting the simultaneous pressing of any meta keys (shift etc)
1282
+ * @param flags - the code denoting the combination of extra flags
1283
+ *
1284
+ * @deprecated
1285
+ */
466
1286
  pressKeyCode?(keycode: number, metastate?: number, flags?: number): Promise<void>;
1287
+
1288
+ /**
1289
+ * Press a device hardware key by its code for a longer duration
1290
+ *
1291
+ * @param keycode - the keycode
1292
+ * @param metastate - the code denoting the simultaneous pressing of any meta keys (shift etc)
1293
+ * @param flags - the code denoting the combination of extra flags
1294
+ *
1295
+ * @deprecated
1296
+ */
467
1297
  longPressKeyCode?(keycode: number, metastate?: number, flags?: number): Promise<void>;
1298
+
1299
+ /**
1300
+ * Apply a synthetic fingerprint to the fingerprint detector of the device
1301
+ *
1302
+ * @param fingerprintId - the numeric ID of the fingerprint to use
1303
+ *
1304
+ * @deprecated
1305
+ */
468
1306
  fingerprint?(fingerprintId: number): Promise<void>;
1307
+
1308
+ /**
1309
+ * Simulate sending an SMS message from a certain phone number to the device
1310
+ *
1311
+ * @param phoneNumber - the number to pretend the message is from
1312
+ * @param message - the SMS text
1313
+ *
1314
+ * @deprecated
1315
+ */
469
1316
  sendSMS?(phoneNumber: string, message: string): Promise<void>;
1317
+
1318
+ /**
1319
+ * Simulate triggering a phone call from a phone number and having the device take an action in
1320
+ * response
1321
+ *
1322
+ * @param phoneNumber - the number to pretend the call is from
1323
+ * @param action - the action to take in response (accept, reject, etc...)
1324
+ *
1325
+ * @deprecated
1326
+ */
470
1327
  gsmCall?(phoneNumber: string, action: string): Promise<void>;
1328
+
1329
+ /**
1330
+ * Simulate setting the GSM signal strength for a cell phone
1331
+ *
1332
+ * @param singalStrength - the strength in a driver-appropriate string
1333
+ *
1334
+ * @deprecated
1335
+ */
471
1336
  gsmSignal?(signalStrength: string): Promise<void>;
1337
+
1338
+ /**
1339
+ * Do something with GSM voice (unclear; this should not be implemented anywhere)
1340
+ *
1341
+ * @param state - the state
1342
+ *
1343
+ * @deprecated
1344
+ */
472
1345
  gsmVoice?(state: string): Promise<void>;
1346
+
1347
+ /**
1348
+ * Set the simulated power capacity of the device
1349
+ *
1350
+ * @param percent - how full the battery should become
1351
+ *
1352
+ * @deprecated
1353
+ */
473
1354
  powerCapacity?(percent: number): Promise<void>;
1355
+
1356
+ /**
1357
+ * Set the AC-connected power state of the device
1358
+ *
1359
+ * @param state - whether the device is connected to power or not
1360
+ *
1361
+ * @deprecated
1362
+ */
474
1363
  powerAC?(state: string): Promise<void>;
1364
+
1365
+ /**
1366
+ * Set the network speed of the device
1367
+ *
1368
+ * @param netspeed - the speed as a string, like '3G'
1369
+ *
1370
+ * @deprecated
1371
+ */
475
1372
  networkSpeed?(netspeed: string): Promise<void>;
1373
+
1374
+ /**
1375
+ * Simulate a keyevent on the device
1376
+ *
1377
+ * @param keycode - the manufacturer defined keycode
1378
+ * @param metastate - the combination of meta startUnexpectedShutdown
1379
+ *
1380
+ * @deprecated
1381
+ */
476
1382
  keyevent?(keycode: string, metastate?: string): Promise<void>;
1383
+
1384
+ /**
1385
+ * Construct a rotation gesture? Unclear what this command does and it does not appear to be used
1386
+ *
1387
+ * @param x - the x coordinate of the rotation center
1388
+ * @param y - the y coordinate of the rotation center
1389
+ * @param radius - the radius of the rotation circle
1390
+ * @param rotation - the rotation angle? idk
1391
+ * @param touchCount - how many fingers to rotate
1392
+ * @param elementId - if we're rotating around an element
1393
+ *
1394
+ * @deprecated Use setRotation instead
1395
+ */
477
1396
  mobileRotation?(
478
1397
  x: number,
479
1398
  y: number,
@@ -483,24 +1402,169 @@ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints
483
1402
  duration: string,
484
1403
  elementId?: string
485
1404
  ): Promise<void>;
1405
+
1406
+ /**
1407
+ * Get the current activity name
1408
+ *
1409
+ * @returns The activity name
1410
+ *
1411
+ * @deprecated
1412
+ */
486
1413
  getCurrentActivity?(): Promise<string>;
1414
+
1415
+ /**
1416
+ * Get the current active app package name/id
1417
+ *
1418
+ * @returns The package name
1419
+ *
1420
+ * @deprecated
1421
+ */
487
1422
  getCurrentPackage?(): Promise<string>;
1423
+
1424
+ /**
1425
+ * Install an app on a device
1426
+ *
1427
+ * @param appPath - the absolute path to a local app or a URL of a downloadable app bundle
1428
+ * @param options - driver-specific install options
1429
+ */
488
1430
  installApp?(appPath: string, options?: unknown): Promise<void>;
1431
+
1432
+ /**
1433
+ * Launch an app
1434
+ *
1435
+ * @param appId - the package or bundle ID of the application
1436
+ * @param options - driver-specific launch options
1437
+ */
489
1438
  activateApp?(appId: string, options?: unknown): Promise<void>;
1439
+
1440
+ /**
1441
+ * Remove / uninstall an app
1442
+ *
1443
+ * @param appId - the package or bundle ID of the application
1444
+ * @param options - driver-specific launch options
1445
+ */
490
1446
  removeApp?(appId: string, options?: unknown): Promise<void>;
1447
+
1448
+ /**
1449
+ * Quit / terminate / stop a running application
1450
+ *
1451
+ * @param appId - the package or bundle ID of the application
1452
+ * @param options - driver-specific launch options
1453
+ */
491
1454
  terminateApp?(appId: string, options?: unknown): Promise<void>;
1455
+
1456
+ /**
1457
+ * Determine whether an app is installed
1458
+ *
1459
+ * @param appId - the package or bundle ID of the application
1460
+ */
492
1461
  isAppInstalled?(appId: string): Promise<boolean>;
493
- queryAppState?(appId: string): Promise<number>;
1462
+
1463
+ /**
1464
+ * Get the running state of an app
1465
+ *
1466
+ * @param appId - the package or bundle ID of the application
1467
+ *
1468
+ * @returns A number representing the state. 0 means not installed, 1 means not running, 3 means
1469
+ * running in the background, and 4 means running in the foreground
1470
+ */
1471
+ queryAppState?(appId: string): Promise<0 | 1 | 3 | 4>;
1472
+
1473
+ /**
1474
+ * Attempt to hide a virtual keyboard
1475
+ *
1476
+ * @param strategy - the driver-specific name of a hiding strategy to follow
1477
+ * @param key - the text of a key to use to hide the keyboard
1478
+ * @param keyCode - a key code to trigger to hide the keyboard
1479
+ * @param keyName - the name of a key to use to hide the keyboard
1480
+ */
494
1481
  hideKeyboard?(strategy?: string, key?: string, keyCode?: string, keyName?: string): Promise<void>;
1482
+
1483
+ /**
1484
+ * Determine whether the keyboard is shown
1485
+ *
1486
+ * @returns Whether the keyboard is shown
1487
+ */
495
1488
  isKeyboardShown?(): Promise<boolean>;
1489
+
1490
+ /**
1491
+ * Push data to a file at a remote path on the device
1492
+ *
1493
+ * @param path - the remote path on the device to create the file at
1494
+ * @param data - the base64-encoded data which will be decoded and written to `path`
1495
+ */
496
1496
  pushFile?(path: string, data: string): Promise<void>;
1497
+
1498
+ /**
1499
+ * Retrieve the data from a file on the device at a given path
1500
+ *
1501
+ * @param path - the remote path on the device to pull file data from
1502
+ *
1503
+ * @returns The base64-encoded file data
1504
+ */
497
1505
  pullFile?(path: string): Promise<string>;
1506
+
1507
+ /**
1508
+ * Retrieve the data from a folder on the device at a given path
1509
+ *
1510
+ * @param path - the remote path of a directory on the device
1511
+ *
1512
+ * @returns The base64-encoded zip file of the directory contents
1513
+ */
498
1514
  pullFolder?(path: string): Promise<string>;
1515
+
1516
+ /**
1517
+ * Toggle airplane/flight mode for the device
1518
+ *
1519
+ * @deprecated
1520
+ */
499
1521
  toggleFlightMode?(): Promise<void>;
1522
+
1523
+ /**
1524
+ * Toggle cell network data
1525
+ *
1526
+ * @deprecated
1527
+ */
500
1528
  toggleData?(): Promise<void>;
1529
+
1530
+ /**
1531
+ * Toggle WiFi radio status
1532
+ *
1533
+ * @deprecated
1534
+ */
501
1535
  toggleWiFi?(): Promise<void>;
1536
+
1537
+ /**
1538
+ * Toggle location services for the device
1539
+ *
1540
+ * @deprecated
1541
+ */
502
1542
  toggleLocationServices?(): Promise<void>;
1543
+
1544
+ /**
1545
+ * Open the notifications shade/screen
1546
+ *
1547
+ * @deprecated
1548
+ */
503
1549
  openNotifications?(): Promise<void>;
1550
+
1551
+ /**
1552
+ * Start an Android activity within an app
1553
+ *
1554
+ * @param appPackage - the app package id
1555
+ * @param appActivity - the activity name
1556
+ * @param appWaitPackage - the package id to wait for if different from the app package
1557
+ * @param appWaitActivity - the activity name to wait for being active if different from
1558
+ * appActivity
1559
+ * @param intentAction - the action for the intent to use to start the activity
1560
+ * @param intentCategory - the category for the intent
1561
+ * @param flags - the flags for the intent
1562
+ * @param optionalIntentArguments - additional arguments to be passed to launching the intent
1563
+ * @param dontStopAppOnReset - set to true to not stop the current app before launching the
1564
+ * activity
1565
+ *
1566
+ * @deprecated
1567
+ */
504
1568
  startActivity?(
505
1569
  appPackage: string,
506
1570
  appActivity: string,
@@ -512,57 +1576,375 @@ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints
512
1576
  optionalIntentArguments?: string,
513
1577
  dontStopAppOnReset?: boolean
514
1578
  ): Promise<void>;
1579
+
1580
+ /**
1581
+ * Get information from the system bars of a device
1582
+ *
1583
+ * @returns An array of information objects of driver-specific shape
1584
+ *
1585
+ * @deprecated
1586
+ */
515
1587
  getSystemBars?(): Promise<unknown[]>;
1588
+
1589
+ /**
1590
+ * Get the display's pixel density
1591
+ *
1592
+ * @returns The density
1593
+ *
1594
+ * @deprecated
1595
+ */
516
1596
  getDisplayDensity?(): Promise<number>;
1597
+
1598
+ /**
1599
+ * Trigger a touch/fingerprint match or match failure
1600
+ *
1601
+ * @param match - whether the match should be a success or failure
1602
+ *
1603
+ * @deprecated
1604
+ */
517
1605
  touchId?(match: boolean): Promise<void>;
1606
+
1607
+ /**
1608
+ * Toggle whether the device is enrolled in the touch ID program
1609
+ *
1610
+ * @param enabled - whether to enable or disable the touch ID program
1611
+ *
1612
+ * @deprecated
1613
+ */
518
1614
  toggleEnrollTouchId?(enabled: boolean): Promise<void>;
1615
+
1616
+ /**
1617
+ * Start the session after it has been started.
1618
+ *
1619
+ * @deprecated Don't use this, it never made sense.
1620
+ */
519
1621
  launchApp?(): Promise<void>;
1622
+
1623
+ /**
1624
+ * Stop the session without stopping the session
1625
+ *
1626
+ * @deprecated Don't use this, it never made sense.
1627
+ */
520
1628
  closeApp?(): Promise<void>;
1629
+
1630
+ /**
1631
+ * Background (close) the app either permanently or for a certain amount of time
1632
+ *
1633
+ * @param seconds - the number of seconds to background the app for, or `null` for permanently
1634
+ *
1635
+ * @deprecated
1636
+ */
521
1637
  background?(seconds: null | number): Promise<void>;
1638
+
1639
+ /**
1640
+ * End platform-specific code coverage tracing
1641
+ *
1642
+ * @param intent - the Android intent for the coverage activity
1643
+ * @param path - the path to place the results
1644
+ *
1645
+ * @deprecated
1646
+ */
522
1647
  endCoverage?(intent: string, path: string): Promise<void>;
1648
+
1649
+ /**
1650
+ * Return the language-specific strings for an app
1651
+ *
1652
+ * @param language - the language to retrieve strings for
1653
+ * @param stringFile - the path to the localized strings file if not in the default location
1654
+ *
1655
+ * @returns A record of localized keys to localized text
1656
+ *
1657
+ * @deprecated
1658
+ */
523
1659
  getStrings?(language?: string, stringFile?: string): Promise<Record<string, unknown>>;
1660
+
1661
+ /**
1662
+ * Set the value, but like, now? Don't use this.
1663
+ *
1664
+ * @param value - the value to set
1665
+ * @param elementId - the element to set the value of
1666
+ *
1667
+ * @deprecated
1668
+ */
524
1669
  setValueImmediate?(value: string, elementId: string): Promise<void>;
1670
+
1671
+ /**
1672
+ * Set the value of a text field but ensure the current value is replace and not appended
1673
+ *
1674
+ * @param value - the text to set
1675
+ * @param elementId - the element to set it in
1676
+ *
1677
+ * @deprecated
1678
+ */
525
1679
  replaceValue?(value: string, elementId: string): Promise<void>;
1680
+
1681
+ /**
1682
+ * Collect the response of an async script execution? It's unclear what this is for. Don't use
1683
+ * it.
1684
+ *
1685
+ * @param response - idk
1686
+ *
1687
+ * @deprecated
1688
+ */
526
1689
  receiveAsyncResponse?(response: unknown): Promise<void>;
1690
+
1691
+ /**
1692
+ * Set the contents of the device clipboard
1693
+ *
1694
+ * @param content - the text to set
1695
+ * @param contentType - the media type if not text
1696
+ * @param label - the label if not text
1697
+ *
1698
+ * @deprecated
1699
+ */
527
1700
  setClipboard?(content: string, contentType?: string, label?: string): Promise<void>;
1701
+
1702
+ /**
1703
+ * Get the contents of the device clipboard, converted into an appropriate media type
1704
+ *
1705
+ * @param contentType - the media type if not text
1706
+ *
1707
+ * @returns The text or media content (base64-encoded) of the clipboard
1708
+ *
1709
+ * @deprecated
1710
+ */
528
1711
  getClipboard?(contentType?: string): Promise<string>;
529
1712
 
530
1713
  // JSONWP
1714
+ /**
1715
+ * Set the async execute script timeout
1716
+ *
1717
+ * @param ms - the timeout
1718
+ *
1719
+ * @deprecated Use the W3C timeouts command instead
1720
+ */
531
1721
  asyncScriptTimeout?(ms: number): Promise<void>;
1722
+
1723
+ /**
1724
+ * Get the window size
1725
+ *
1726
+ * @returns The size (width and height)
1727
+ *
1728
+ * @deprecated Use getWindowRect instead
1729
+ */
532
1730
  getWindowSize?(): Promise<Size>;
1731
+
1732
+ /**
1733
+ * Get the position of an element on screen
1734
+ *
1735
+ * @param elementId - the element ID
1736
+ *
1737
+ * @returns The position of the element
1738
+ *
1739
+ * @deprecated Use getElementRect instead
1740
+ */
533
1741
  getLocation?(elementId: string): Promise<Position>;
1742
+
1743
+ /**
1744
+ * Get the position of an element on screen within a certain other view
1745
+ *
1746
+ * @param elementId - the element ID
1747
+ *
1748
+ * @returns The position of the element
1749
+ *
1750
+ * @deprecated Use getElementRect instead
1751
+ */
534
1752
  getLocationInView?(elementId: string): Promise<Position>;
1753
+
1754
+ /**
1755
+ * Get the size of an element
1756
+ *
1757
+ * @param elementId - the element ID
1758
+ *
1759
+ * @returns The size of the element
1760
+ *
1761
+ * @deprecated Use getElementRect instead
1762
+ */
535
1763
  getSize?(elementId: string): Promise<Size>;
536
- elementShadowRoot?(elementId: string): Promise<Element>;
537
- findElementFromShadowRoot?(
538
- strategy: string,
539
- selector: string,
540
- shadowId: string
541
- ): Promise<Element>;
542
- findElementsFromShadowRoot?(
543
- strategy: string,
544
- selector: string,
545
- shadowId: string
546
- ): Promise<Element[]>;
1764
+
1765
+ /**
1766
+ * Check whether two elements are identical
1767
+ *
1768
+ * @param elementId - the first element's ID
1769
+ * @param otherElementId - the second element's ID
1770
+ *
1771
+ * @returns True if the elements are equal, false otherwise
1772
+ *
1773
+ * @deprecated
1774
+ */
547
1775
  equalsElement?(elementId: string, otherElementId: string): Promise<boolean>;
1776
+
1777
+ /**
1778
+ * Submit the form an element is in
1779
+ *
1780
+ * @param elementId - the element ID
1781
+ *
1782
+ * @deprecated
1783
+ */
548
1784
  submit?(elementId: string): Promise<void>;
1785
+
1786
+ /**
1787
+ * Send keys to the app
1788
+ *
1789
+ * @param value: the array of keys to send
1790
+ *
1791
+ * @deprecated Use the W3C send keys method instead
1792
+ */
549
1793
  keys?(value: string[]): Promise<void>;
1794
+
1795
+ /**
1796
+ * Get the list of IME engines
1797
+ *
1798
+ * @returns The list of IME engines
1799
+ *
1800
+ * @deprecated
1801
+ */
550
1802
  availableIMEEngines?(): Promise<string[]>;
1803
+
1804
+ /**
1805
+ * Get the active IME engine
1806
+ *
1807
+ * @returns The name of the active engine
1808
+ *
1809
+ * @deprecated
1810
+ */
551
1811
  getActiveIMEEngine?(): Promise<string>;
1812
+
1813
+ /**
1814
+ * Determine whether an IME is active
1815
+ *
1816
+ * @returns True if the IME is activated
1817
+ *
1818
+ * @deprecated
1819
+ */
552
1820
  isIMEActivated?(): Promise<boolean>;
1821
+
1822
+ /**
1823
+ * Deactivate an IME engine
1824
+ *
1825
+ * @deprecated
1826
+ */
553
1827
  deactivateIMEEngine?(): Promise<void>;
1828
+
1829
+ /**
1830
+ * Activate an IME engine
1831
+ *
1832
+ * @param engine - the name of the engine
1833
+ *
1834
+ * @deprecated
1835
+ */
554
1836
  activateIMEEngine?(engine: string): Promise<void>;
1837
+
1838
+ /**
1839
+ * Get the device orientation
1840
+ *
1841
+ * @returns The orientation string
1842
+ */
555
1843
  getOrientation?(): Promise<string>;
1844
+
1845
+ /**
1846
+ * Set the device orientation
1847
+ *
1848
+ * @param orientation - the orientation string
1849
+ */
556
1850
  setOrientation?(orientation: string): Promise<void>;
1851
+
1852
+ /**
1853
+ * Move the mouse pointer to a particular screen location
1854
+ *
1855
+ * @param element - the element ID if the move is relative to an element
1856
+ * @param xOffset - the x offset
1857
+ * @param yOffset - the y offset
1858
+ *
1859
+ * @deprecated Use the Actions API instead
1860
+ */
557
1861
  moveTo?(element?: null | string, xOffset?: number, yOffset?: number): Promise<void>;
1862
+
1863
+ /**
1864
+ * Trigger a mouse button down
1865
+ *
1866
+ * @param button - the button ID
1867
+ *
1868
+ * @deprecated Use the Actions API instead
1869
+ */
558
1870
  buttonDown?(button?: number): Promise<void>;
1871
+
1872
+ /**
1873
+ * Trigger a mouse button up
1874
+ *
1875
+ * @param button - the button ID
1876
+ *
1877
+ * @deprecated Use the Actions API instead
1878
+ */
559
1879
  buttonUp?(button?: number): Promise<void>;
1880
+
1881
+ /**
1882
+ * Click the current mouse location
1883
+ *
1884
+ * @param button - the button ID
1885
+ *
1886
+ * @deprecated Use the Actions API instead
1887
+ */
560
1888
  clickCurrent?(button?: number): Promise<void>;
1889
+
1890
+ /**
1891
+ * Double-click the current mouse location
1892
+ *
1893
+ * @deprecated Use the Actions API instead
1894
+ */
561
1895
  doubleClick?(): Promise<void>;
1896
+
1897
+ /**
1898
+ * Perform a touch down event at the location specified
1899
+ *
1900
+ * @param x - the x coordinate
1901
+ * @param y - the y coordinate
1902
+ *
1903
+ * @deprecated Use the Actions API instead
1904
+ */
562
1905
  touchDown?(x: number, y: number): Promise<void>;
1906
+
1907
+ /**
1908
+ * Perform a touch up event at the location specified
1909
+ *
1910
+ * @param x - the x coordinate
1911
+ * @param y - the y coordinate
1912
+ *
1913
+ * @deprecated Use the Actions API instead
1914
+ */
563
1915
  touchUp?(x: number, y: number): Promise<void>;
1916
+
1917
+ /**
1918
+ * Perform a touch move event at the location specified
1919
+ *
1920
+ * @param x - the x coordinate
1921
+ * @param y - the y coordinate
1922
+ *
1923
+ * @deprecated Use the Actions API instead
1924
+ */
564
1925
  touchMove?(x: number, y: number): Promise<void>;
1926
+
1927
+ /**
1928
+ * Perform a long touch down event at the location specified
1929
+ *
1930
+ * @param elementId - the id of the element to long touch
1931
+ *
1932
+ * @deprecated Use the Actions API instead
1933
+ */
565
1934
  touchLongClick?(elementId: string): Promise<void>;
1935
+
1936
+ /**
1937
+ * Perform a flick event at the location specified
1938
+ *
1939
+ * @param element - the element to make coordinates relative to
1940
+ * @param xSpeed - the horizontal flick speed (in driver-specific units)
1941
+ * @param ySpeed - the vertical flick speed (in driver-specific units)
1942
+ * @param xOffset - the x coordinate
1943
+ * @param yOffset - the y coordinate
1944
+ * @param speed - the speed (unclear how this relates to xSpeed and ySpeed)
1945
+ *
1946
+ * @deprecated Use the Actions API instead
1947
+ */
566
1948
  flick?(
567
1949
  element?: string,
568
1950
  xSpeed?: number,
@@ -571,46 +1953,219 @@ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints
571
1953
  yOffset?: number,
572
1954
  speed?: number
573
1955
  ): Promise<void>;
1956
+
1957
+ /**
1958
+ * Get the virtual or real geographical location of a device
1959
+ *
1960
+ * @returns The location
1961
+ */
574
1962
  getGeoLocation?(): Promise<Location>;
1963
+
1964
+ /**
1965
+ * Set the virtual geographical location of a device
1966
+ *
1967
+ * @param location - the location including latitude and longitude
1968
+ */
575
1969
  setGeoLocation?(location: Partial<Location>): Promise<void>;
576
1970
 
577
1971
  // MJSONWIRE
1972
+
1973
+ /**
1974
+ * Get the currently active context
1975
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
1976
+ *
1977
+ * @returns The context name
1978
+ */
578
1979
  getCurrentContext?(): Promise<string | null>;
1980
+
1981
+ /**
1982
+ * Switch to a context by name
1983
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
1984
+ *
1985
+ * @param name - the context name
1986
+ */
579
1987
  setContext?(name: string): Promise<void>;
1988
+
1989
+ /**
1990
+ * Get the list of available contexts
1991
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#webviews-and-other-contexts}
1992
+ *
1993
+ * @returns The list of context names
1994
+ */
580
1995
  getContexts?(): Promise<string[]>;
1996
+
1997
+ /**
1998
+ * Get the index of an element on the page
1999
+ *
2000
+ * @param elementId - the element id
2001
+ *
2002
+ * @returns The page index
2003
+ *
2004
+ * @deprecated
2005
+ */
581
2006
  getPageIndex?(elementId: string): Promise<string>;
2007
+
2008
+ /**
2009
+ * Get the network connection state of a device
2010
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes}
2011
+ *
2012
+ * @returns A number which is a bitmask representing categories like Data, Wifi, and Airplane
2013
+ * mode status
2014
+ */
582
2015
  getNetworkConnection?(): Promise<number>;
2016
+
2017
+ /**
2018
+ * Set the network connection of the device
2019
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes}
2020
+ *
2021
+ * @param type - the bitmask representing network state
2022
+ */
583
2023
  setNetworkConnection?(type: number): Promise<void>;
2024
+
2025
+ /**
2026
+ * Perform a set of touch actions
2027
+ *
2028
+ * @param actions - the old MJSONWP style touch action objects
2029
+ *
2030
+ * @deprecated Use the W3C Actions API instead
2031
+ */
584
2032
  performTouch?(actions: unknown): Promise<void>;
2033
+
2034
+ /**
2035
+ * Perform a set of touch actions
2036
+ *
2037
+ * @param actions - the old MJSONWP style touch action objects
2038
+ * @param elementId - the id of an element if actions are restricted to one element
2039
+ *
2040
+ * @deprecated Use the W3C Actions API instead
2041
+ */
585
2042
  performMultiAction?(actions: unknown, elementId: string): Promise<void>;
2043
+
2044
+ /**
2045
+ * Get the current rotation state of the device
2046
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-rotation}
2047
+ *
2048
+ * @returns The Rotation object consisting of x, y, and z rotation values (0 <= n <= 360)
2049
+ */
586
2050
  getRotation?(): Promise<Rotation>;
2051
+
2052
+ /**
2053
+ * Set the device rotation state
2054
+ * @see {@link https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-rotation}
2055
+ *
2056
+ * @param x - the degree to which the device is rotated around the x axis (0 <= x <= 360)
2057
+ * @param y - the degree to which the device is rotated around the y axis (0 <= y <= 360)
2058
+ * @param z - the degree to which the device is rotated around the z axis (0 <= z <= 360)
2059
+ */
587
2060
  setRotation?(x: number, y: number, z: number): Promise<void>;
588
2061
 
589
2062
  // Chromium DevTools
2063
+
2064
+ /**
2065
+ * Execute a devtools command
2066
+ *
2067
+ * @param cmd - the command
2068
+ * @param params - any command-specific command parameters
2069
+ *
2070
+ * @returns The result of the command execution
2071
+ */
590
2072
  executeCdp?(cmd: string, params: unknown): Promise<unknown>;
591
2073
 
592
2074
  // Web Authentication
2075
+
2076
+ /**
2077
+ * Add a virtual authenticator to a browser
2078
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-add-virtual-authenticator}
2079
+ *
2080
+ * @param protocol - the protocol
2081
+ * @param transport - a valid AuthenticatorTransport value
2082
+ * @param hasResidentKey - whether there is a resident key
2083
+ * @param hasUserVerification - whether the authenticator has user verification
2084
+ * @param isUserConsenting - whether it is a user consenting authenticator
2085
+ * @param isUserVerified - whether the user is verified
2086
+ *
2087
+ * @returns The authenticator ID
2088
+ */
593
2089
  addVirtualAuthenticator?(
594
- protocol: string,
2090
+ protocol: 'ctap/u2f' | 'ctap2' | 'ctap2_1',
595
2091
  transport: string,
596
2092
  hasResidentKey?: boolean,
597
2093
  hasUserVerification?: boolean,
598
2094
  isUserConsenting?: boolean,
599
2095
  isUserVerified?: boolean
600
- ): Promise<void>;
601
- removeVirtualAuthenticator?(): Promise<void>;
2096
+ ): Promise<string>;
2097
+
2098
+ /**
2099
+ * Remove a virtual authenticator
2100
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-remove-virtual-authenticator}
2101
+ *
2102
+ * @param authenticatorId - the ID returned in the call to add the authenticator
2103
+ */
2104
+ removeVirtualAuthenticator?(authenticatorId: string): Promise<void>;
2105
+
2106
+ /**
2107
+ * Inject a public key credential source into a virtual authenticator
2108
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-add-credential}
2109
+ *
2110
+ * @param credentialId - the base64 encoded credential ID
2111
+ * @param isResidentCredential - if true, a client-side credential, otherwise a server-side
2112
+ * credential
2113
+ * @param rpId - the relying party ID the credential is scoped to
2114
+ * @param privateKey - the base64 encoded private key package
2115
+ * @param userHandle - the base64 encoded user handle
2116
+ * @param signCount - the initial value for a signature counter
2117
+ */
602
2118
  addAuthCredential?(
603
2119
  credentialId: string,
604
2120
  isResidentCredential: boolean,
605
2121
  rpId: string,
606
2122
  privateKey: string,
607
- userHandle?: string,
608
- signCount?: number
2123
+ userHandle: string,
2124
+ signCount: number,
2125
+ authenticatorId: string
609
2126
  ): Promise<void>;
2127
+
2128
+ /**
2129
+ * Get the list of public key credential sources
2130
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-get-credentials}
2131
+ *
2132
+ * @returns The list of Credentials
2133
+ */
610
2134
  getAuthCredential?(): Promise<Credential[]>;
2135
+
2136
+ /**
2137
+ * Remove all auth credentials
2138
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-remove-all-credentials}
2139
+ */
611
2140
  removeAllAuthCredentials?(): Promise<void>;
612
- removeAuthCredential?(): Promise<void>;
613
- setUserAuthVerified?(isUserVerified: boolean): Promise<void>;
2141
+
2142
+ /**
2143
+ * Remove a specific auth credential
2144
+ *
2145
+ * @param credentialId - the credential ID
2146
+ * @param authenticatorId - the authenticator ID
2147
+ */
2148
+ removeAuthCredential?(credentialId: string, authenticatorId: string): Promise<void>;
2149
+
2150
+ /**
2151
+ * Set the isUserVerified property of an authenticator
2152
+ * @see {@link https://www.w3.org/TR/webauthn-2/#sctn-automation-set-user-verified}
2153
+ *
2154
+ * @param isUserVerified - the value of the isUserVerified property
2155
+ * @param authenticatorId - the authenticator id
2156
+ */
2157
+ setUserAuthVerified?(isUserVerified: boolean, authenticatorId: string): Promise<void>;
2158
+
2159
+ /**
2160
+ * Proxy a command to a connected WebDriver server
2161
+ *
2162
+ * @typeParam T - the type of the return value
2163
+ * @param url - the incoming URL
2164
+ * @param method - the incoming HTTP method
2165
+ * @param body - the incoming HTTP body
2166
+ *
2167
+ * @returns The return value of the proxied command
2168
+ */
614
2169
  proxyCommand?<T = any>(url: string, method: HTTPMethod, body?: string): Promise<T>;
615
2170
  }
616
2171