@appium/types 0.7.0 → 0.8.3

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