-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
index.d.ts
3031 lines (2722 loc) · 102 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Selenium WebDriverJS 4.0
// Project: https://github.com/SeleniumHQ/selenium
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>,
// Yuki Kokubun <https://github.com/Kuniwak>,
// Craig Nishina <https://github.com/cnishina>,
// Simon Gellis <https://github.com/SupernaviX>,
// Ben Dixon <https://github.com/bendxn>,
// Ziyu <https://github.com/oddui>
// Johann Wolf <https://github.com/beta-vulgaris>
// Aleksey Chemakin <https://github.com/Dzenly>
// thislooksfun <https://github.com/thislooksfun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import * as chrome from './chrome';
import * as edge from './edge';
import * as firefox from './firefox';
import * as ie from './ie';
import { By, ByHash } from './lib/by';
import { Browser, Capability, Capabilities, ITimeouts } from './lib/capabilities';
import * as command from './lib/command';
import * as http from './http';
import { Actions, Button, Key, Origin } from './lib/input';
import { promise } from './lib/promise';
import * as until from './lib/until';
import * as safari from './safari';
export { By, ByHash } from './lib/by';
export { Browser, Capability, Capabilities, ITimeouts } from './lib/capabilities';
export { Actions, Button, Key, Origin } from './lib/input';
export { promise } from './lib/promise';
export { until as until };
/**
* Typings for lib/error
*/
export namespace error {
class IError extends Error {
constructor(message?: string);
message: string;
}
/**
* The base WebDriver error type. This error type is only used directly when a
* more appropriate category is not defined for the offending error.
*/
class WebDriverError extends IError {
constructor(message?: string);
remoteStacktrace?: string;
}
/**
* Indicates a {@linkplain ./webdriver.WebElement#click click command} could
* not completed because the click target is obscured by other elements on the
* page.
*/
class ElementClickInterceptedError extends WebDriverError {
constructor(message?: string);
}
/**
* An attempt was made to select an element that cannot be selected.
*/
class ElementNotSelectableError extends WebDriverError {
constructor(message?: string);
}
/**
* Indicates a command could not be completed because the target element is
* not pointer or keyboard interactable. This will often occur if an element
* is present in the DOM, but not rendered (i.e. its CSS style has
* "display: none").
*/
class ElementNotInteractableError extends WebDriverError {
constructor(message?: string);
}
/**
* Indicates a navigation event caused the browser to generate a certificate
* warning. This is usually caused by an expired or invalid TLS certificate.
*/
class InsecureCertificateError extends WebDriverError {
constructor(message?: string);
}
/**
* The arguments passed to a command are either invalid or malformed.
*/
class InvalidArgumentError extends WebDriverError {
constructor(message?: string);
}
/**
* An illegal attempt was made to set a cookie under a different domain than
* the current page.
*/
class InvalidCookieDomainError extends WebDriverError {
constructor(message?: string);
}
/**
* The coordinates provided to an interactions operation are invalid.
*/
class InvalidCoordinatesError extends WebDriverError {
constructor(message?: string);
}
/**
* An element command could not be completed because the element is in an
* invalid state, e.g. attempting to click an element that is no longer
* attached to the document.
*/
class InvalidElementStateError extends WebDriverError {
constructor(message?: string);
}
/**
* Argument was an invalid selector.
*/
class InvalidSelectorError extends WebDriverError {
constructor(message?: string);
}
/**
* Occurs when a command is directed to a session that does not exist.
*/
class NoSuchSessionError extends WebDriverError {
constructor(message?: string);
}
/**
* An error occurred while executing JavaScript supplied by the user.
*/
class JavascriptError extends WebDriverError {
constructor(message?: string);
}
/**
* The target for mouse interaction is not in the browser’s viewport and
* cannot be brought into that viewport.
*/
class MoveTargetOutOfBoundsError extends WebDriverError {
constructor(message?: string);
}
/**
* An attempt was made to operate on a modal dialog when one was not open.
*/
class NoSuchAlertError extends WebDriverError {
constructor(message?: string);
}
/**
* Indicates a named cookie could not be found in the cookie jar for the
* currently selected document.
*/
class NoSuchCookieError extends WebDriverError {
constructor(message?: string);
}
/**
* An element could not be located on the page using the given search
* parameters.
*/
class NoSuchElementError extends WebDriverError {
constructor(message?: string);
}
/**
* A request to switch to a frame could not be satisfied because the frame
* could not be found.
*/
class NoSuchFrameError extends WebDriverError {
constructor(message?: string);
}
/**
* A request to switch to a window could not be satisfied because the window
* could not be found.
*/
class NoSuchWindowError extends WebDriverError {
constructor(message?: string);
}
/**
* A script did not complete before its timeout expired.
*/
class ScriptTimeoutError extends WebDriverError {
constructor(message?: string);
}
/**
* A new session could not be created.
*/
class SessionNotCreatedError extends WebDriverError {
constructor(message?: string);
}
/**
* An element command failed because the referenced element is no longer
* attached to the DOM.
*/
class StaleElementReferenceError extends WebDriverError {
constructor(message?: string);
}
/**
* An operation did not completErrorCodee before its timeout expired.
*/
class TimeoutError extends WebDriverError {
constructor(message?: string);
}
/**
* A request to set a cookie’s value could not be satisfied.
*/
class UnableToSetCookieError extends WebDriverError {
constructor(message?: string);
}
/**
* A screen capture operation was not possible.
*/
class UnableToCaptureScreenError extends WebDriverError {
constructor(message?: string);
}
/**
* A modal dialog was open, blocking this operation.
*/
class UnexpectedAlertOpenError extends WebDriverError {
constructor(message?: string, openAlertText?: string);
/**
* @return {(string|undefined)} The text displayed with the unhandled alert,
* if available.
*/
getAlertText(): string;
}
/**
* A command could not be executed because the remote end is not aware of it.
*/
class UnknownCommandError extends WebDriverError {
constructor(message?: string);
}
/**
* The requested command matched a known URL but did not match an method for
* that URL.
*/
class UnknownMethodError extends WebDriverError {
constructor(message?: string);
}
/**
* Reports an unsupport operation.
*/
class UnsupportedOperationError extends WebDriverError {
constructor(message?: string);
}
interface Response {
error: string|number;
message: string;
}
/**
* Checks a response object from a server that adheres to the W3C WebDriver
* protocol.
*/
function checkResponse(data: Response): Response;
interface MaybeLegacyResponse {
status?: number;
value?: {message: string};
message?: string;
getAlertText?(): string;
}
/**
* Checks a legacy response from the Selenium 2.0 wire protocol for an error.
*/
function checkLegacyResponse(response: MaybeLegacyResponse): MaybeLegacyResponse;
interface ErrorData {
error: string|number;
message: string;
[key: string]: string|number;
}
/**
* Throws an error coded from the W3C protocol. A generic error will be thrown
* if the provided `data` is not a valid encoded error.
*/
function throwDecodedError(data: ErrorData|string): never;
interface ErrorCodeType {
[key: string]: number;
}
const ErrorCode: ErrorCodeType;
/**
* Lookup the err in table of errors.
*/
function encodeError(err: any): {error: string, message: string};
}
export namespace logging {
/**
* A hash describing log preferences.
* @typedef {Object.<logging.Type, logging.LevelName>}
*/
class Preferences {
setLevel(type: string, level: Level | string | number): void;
toJSON(): { [key: string]: string };
}
interface IType {
/** Logs originating from the browser. */
BROWSER: string;
/** Logs from a WebDriver client. */
CLIENT: string;
/** Logs from a WebDriver implementation. */
DRIVER: string;
/** Logs related to performance. */
PERFORMANCE: string;
/** Logs from the remote server. */
SERVER: string;
}
/**
* Common log types.
* @enum {string}
*/
const Type: IType;
/**
* Defines a message level that may be used to control logging output.
*
* @final
*/
class Level {
name_: string;
value_: number;
/**
* @param {string} name the level's name.
* @param {number} level the level's numeric value.
*/
constructor(name: string, level: number);
/** @override */
toString(): string;
/** This logger's name. */
name: string;
/** The numeric log level. */
value: number;
/**
* Indicates no log messages should be recorded.
* @const
*/
static OFF: Level;
/**
* Log messages with a level of `1000` or higher.
* @const
*/
static SEVERE: Level;
/**
* Log messages with a level of `900` or higher.
* @const
*/
static WARNING: Level;
/**
* Log messages with a level of `800` or higher.
* @const
*/
static INFO: Level;
/**
* Log messages with a level of `700` or higher.
* @const
*/
static DEBUG: Level;
/**
* Log messages with a level of `500` or higher.
* @const
*/
static FINE: Level;
/**
* Log messages with a level of `400` or higher.
* @const
*/
static FINER: Level;
/**
* Log messages with a level of `300` or higher.
* @const
*/
static FINEST: Level;
/**
* Indicates all log messages should be recorded.
* @const
*/
static ALL: Level;
}
/**
* Converts a level name or value to a {@link logging.Level} value.
* If the name/value is not recognized, {@link logging.Level.ALL}
* will be returned.
* @param {(number|string)} nameOrValue The log level name, or value, to
* convert .
* @return {!logging.Level} The converted level.
*/
function getLevel(nameOrValue: string | number): Level;
interface IEntryJSON {
level: string;
message: string;
timestamp: number;
type: string;
}
/**
* A single log entry.
*/
class Entry {
/**
* @param {(!logging.Level|string)} level The entry level.
* @param {string} message The log message.
* @param {number=} opt_timestamp The time this entry was generated, in
* milliseconds since 0:00:00, January 1, 1970 UTC. If omitted, the
* current time will be used.
* @param {string=} opt_type The log type, if known.
* @constructor
*/
constructor(level: Level | string | number, message: string, opt_timestamp?: number, opt_type?: string | IType);
/** @type {!logging.Level} */
level: Level;
/** @type {string} */
message: string;
/** @type {number} */
timestamp: number;
/** @type {string} */
type: string;
/**
* @return {{level: string, message: string, timestamp: number,
* type: string}} The JSON representation of this entry.
*/
toJSON(): IEntryJSON;
}
/**
* An object used to log debugging messages. Loggers use a hierarchical,
* dot-separated naming scheme. For instance, 'foo' is considered the parent of
* the 'foo.bar' and an ancestor of 'foo.bar.baz'.
*
* Each logger may be assigned a {@linkplain #setLevel log level}, which
* controls which level of messages will be reported to the
* {@linkplain #addHandler handlers} attached to this instance. If a log level
* is not explicitly set on a logger, it will inherit its parent.
*
* This class should never be directly instantiated. Instead, users should
* obtain logger references using the {@linkplain ./logging.getLogger()
* getLogger()} function.
*
* @final
*/
class Logger {
/**
* @param {string} name the name of this logger.
* @param {Level=} opt_level the initial level for this logger.
*/
constructor(name: string, opt_level?: Level);
/** @private {string} */
name_: string;
/** @private {Level} */
level_: Level;
/** @private {Logger} */
parent_: Logger;
/** @private {Set<function(!Entry)>} */
handlers_: any;
/** @return {string} the name of this logger. */
getName(): string;
/**
* @param {Level} level the new level for this logger, or `null` if the logger
* should inherit its level from its parent logger.
*/
setLevel(level: Level): void;
/** @return {Level} the log level for this logger. */
getLevel(): Level;
/**
* @return {!Level} the effective level for this logger.
*/
getEffectiveLevel(): Level;
/**
* @param {!Level} level the level to check.
* @return {boolean} whether messages recorded at the given level are loggable
* by this instance.
*/
isLoggable(level: Level): boolean;
/**
* Adds a handler to this logger. The handler will be invoked for each message
* logged with this instance, or any of its descendants.
*
* @param {function(!Entry)} handler the handler to add.
*/
addHandler(handler: any): void;
/**
* Removes a handler from this logger.
*
* @param {function(!Entry)} handler the handler to remove.
* @return {boolean} whether a handler was successfully removed.
*/
removeHandler(handler: any): void;
/**
* Logs a message at the given level. The message may be defined as a string
* or as a function that will return the message. If a function is provided,
* it will only be invoked if this logger's
* {@linkplain #getEffectiveLevel() effective log level} includes the given
* `level`.
*
* @param {!Level} level the level at which to log the message.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
log(level: Level, loggable: string | Function): void;
/**
* Logs a message at the {@link Level.SEVERE} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
severe(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.WARNING} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
warning(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.INFO} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
info(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.DEBUG} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
debug(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.FINE} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
fine(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.FINER} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
finer(loggable: string | Function): void;
/**
* Logs a message at the {@link Level.FINEST} log level.
* @param {(string|function(): string)} loggable the message to log, or a
* function that will return the message.
*/
finest(loggable: string | Function): void;
}
/**
* Maintains a collection of loggers.
*
* @final
*/
class LogManager {
/**
* Retrieves a named logger, creating it in the process. This function will
* implicitly create the requested logger, and any of its parents, if they
* do not yet exist.
*
* @param {string} name the logger's name.
* @return {!Logger} the requested logger.
*/
getLogger(name?: string): Logger;
/**
* Creates a new logger.
*
* @param {string} name the logger's name.
* @param {!Logger} parent the logger's parent.
* @return {!Logger} the new logger.
* @private
*/
createLogger_(name: string, parent: Logger): Logger;
}
/**
* Retrieves a named logger, creating it in the process. This function will
* implicitly create the requested logger, and any of its parents, if they
* do not yet exist.
*
* @param {string} name the logger's name.
* @return {!Logger} the requested logger.
*/
function getLogger(name?: string): Logger;
/**
* Adds the console handler to the given logger. The console handler will log
* all messages using the JavaScript Console API.
*
* @param {Logger=} opt_logger The logger to add the handler to; defaults
* to the root logger.
*/
function addConsoleHandler(opt_logger?: Logger): void;
/**
* Removes the console log handler from the given logger.
*
* @param {Logger=} opt_logger The logger to remove the handler from; defaults
* to the root logger.
* @see exports.addConsoleHandler
*/
function removeConsoleHandler(opt_logger?: Logger): void;
}
/**
* Defines a condition for use with WebDriver's WebDriver#wait wait command.
*/
export class Condition<T> {
/**
* @param {string} message A descriptive error message. Should complete the
* sentence 'Waiting [...]'
* @param {function(!WebDriver): OUT} fn The condition function to
* evaluate on each iteration of the wait loop.
* @constructor
*/
constructor(message: string, fn: (webdriver: WebDriver) => T);
/** @return {string} A description of this condition. */
description(): string;
/** @type {function(!WebDriver): OUT} */
fn(webdriver: WebDriver): T;
}
/**
* Defines a condition that will result in a {@link WebElement}.
*
* @extends {Condition<!(WebElement|IThenable<!WebElement>)>}
*/
export class WebElementCondition extends Condition<WebElement> {
// add an unused private member so the compiler treats this
// class distinct from other Conditions
private _nominal: undefined;
}
/**
* x,y
*/
export interface ILocation {
x: number;
y: number;
}
/**
* width, height
*/
export interface ISize {
width: number;
height: number;
}
/**
* x,y,w,h
*/
export interface IRectangle {
x: number;
y: number;
width: number;
height: number;
}
/**
* Class for defining sequences of user touch interactions. Each sequence
* will not be executed until {@link #perform} is called.
*
* Example:
*
* new TouchSequence(driver).
* tapAndHold({x: 0, y: 0}).
* move({x: 3, y: 4}).
* release({x: 10, y: 10}).
* perform();
*/
export class TouchSequence {
/*
* @param {!WebDriver} driver The driver instance to use.
* @constructor
*/
constructor(driver: WebDriver);
/**
* Executes this action sequence.
* @return {!Promise} A promise that will be resolved once
* this sequence has completed.
*/
perform(): Promise<void>;
/**
* Taps an element.
*
* @param {!WebElement} elem The element to tap.
* @return {!TouchSequence} A self reference.
*/
tap(elem: WebElement): TouchSequence;
/**
* Double taps an element.
*
* @param {!WebElement} elem The element to double tap.
* @return {!TouchSequence} A self reference.
*/
doubleTap(elem: WebElement): TouchSequence;
/**
* Long press on an element.
*
* @param {!WebElement} elem The element to long press.
* @return {!TouchSequence} A self reference.
*/
longPress(elem: WebElement): TouchSequence;
/**
* Touch down at the given location.
*
* @param {{ x: number, y: number }} location The location to touch down at.
* @return {!TouchSequence} A self reference.
*/
tapAndHold(location: ILocation): TouchSequence;
/**
* Move a held {@linkplain #tapAndHold touch} to the specified location.
*
* @param {{x: number, y: number}} location The location to move to.
* @return {!TouchSequence} A self reference.
*/
move(location: ILocation): TouchSequence;
/**
* Release a held {@linkplain #tapAndHold touch} at the specified location.
*
* @param {{x: number, y: number}} location The location to release at.
* @return {!TouchSequence} A self reference.
*/
release(location: ILocation): TouchSequence;
/**
* Scrolls the touch screen by the given offset.
*
* @param {{x: number, y: number}} offset The offset to scroll to.
* @return {!TouchSequence} A self reference.
*/
scroll(offset: IOffset): TouchSequence;
/**
* Scrolls the touch screen, starting on `elem` and moving by the specified
* offset.
*
* @param {!WebElement} elem The element where scroll starts.
* @param {{x: number, y: number}} offset The offset to scroll to.
* @return {!TouchSequence} A self reference.
*/
scrollFromElement(elem: WebElement, offset: IOffset): TouchSequence;
/**
* Flick, starting anywhere on the screen, at speed xspeed and yspeed.
*
* @param {{xspeed: number, yspeed: number}} speed The speed to flick in each
* direction, in pixels per second.
* @return {!TouchSequence} A self reference.
*/
flick(speed: ISpeed): TouchSequence;
/**
* Flick starting at elem and moving by x and y at specified speed.
*
* @param {!WebElement} elem The element where flick starts.
* @param {{x: number, y: number}} offset The offset to flick to.
* @param {number} speed The speed to flick at in pixels per second.
* @return {!TouchSequence} A self reference.
*/
flickElement(elem: WebElement, offset: IOffset, speed: number): TouchSequence;
}
/**
* x.y again
*/
export interface IOffset {
x: number;
y: number;
}
/**
* delta x,y
*/
export interface ISpeed {
xspeed: number;
yspeed: number;
}
/**
* Represents a modal dialog such as {@code alert}, {@code confirm}, or
* {@code prompt}. Provides functions to retrieve the message displayed with
* the alert, accept or dismiss the alert, and set the response text (in the
* case of {@code prompt}).
*/
export class Alert {
/**
* @param {!WebDriver} driver The driver controlling the browser this alert
* is attached to.
* @param {string} text The message text displayed with this alert.
*/
constructor(driver: WebDriver, text: string);
// region Methods
/**
* Retrieves the message text displayed with this alert. For instance, if the
* alert were opened with alert('hello'), then this would return 'hello'.
* @return {!Promise} A promise that will be resolved to the
* text displayed with this alert.
*/
getText(): Promise<string>;
/**
* Sets the username and password in an alert prompting for credentials (such
* as a Basic HTTP Auth prompt). This method will implicitly
* {@linkplain #accept() submit} the dialog.
*
* @param {string} username The username to send.
* @param {string} password The password to send.
* @return {!Promise<void>} A promise that will be resolved when this
* command has completed.
*/
authenticateAs(username: string, password: string): Promise<void>;
/**
* Accepts this alert.
* @return {!Promise} A promise that will be resolved when
* this command has completed.
*/
accept(): Promise<void>;
/**
* Dismisses this alert.
* @return {!Promise} A promise that will be resolved when
* this command has completed.
*/
dismiss(): Promise<void>;
/**
* Sets the response text on this alert. This command will return an error if
* the underlying alert does not support response text (e.g. window.alert and
* window.confirm).
* @param {string} text The text to set.
* @return {!Promise} A promise that will be resolved when
* this command has completed.
*/
sendKeys(text: string): Promise<void>;
// endregion
}
/**
* AlertPromise is a promise that will be fulfilled with an Alert. This promise
* serves as a forward proxy on an Alert, allowing calls to be scheduled
* directly on this instance before the underlying Alert has been fulfilled. In
* other words, the following two statements are equivalent:
*
* driver.switchTo().alert().dismiss();
* driver.switchTo().alert().then(function(alert) {
* return alert.dismiss();
* });
*
* @implements {promise.Thenable.<!Alert>}
* @final
*/
export interface AlertPromise extends Promise<Alert> {}
/**
* Implement AlertPromise
*/
export class AlertPromise extends Alert {
/**
* @param {!WebDriver} driver The driver controlling the browser this
* alert is attached to.
* @param {!promise.Thenable<!Alert>} alert A thenable
* that will be fulfilled with the promised alert.
*/
constructor(driver: WebDriver, alert: Promise<Alert>);
}
/**
* ProxyConfig
*/
export interface ProxyConfig {
proxyType: string;
proxyAutoconfigUrl?: string;
ftpProxy?: string;
httpProxy?: string;
sslProxy?: string;
noProxy?: string;
socksProxy?: string;
socksUsername?: string;
socksPassword?: string;
}
/**
* Creates new {@link WebDriver WebDriver} instances. The environment
* variables listed below may be used to override a builder's configuration,
* allowing quick runtime changes.
*
* - {@code SELENIUM_BROWSER}: defines the target browser in the form
* {@code browser[:version][:platform]}.
*
* - {@code SELENIUM_REMOTE_URL}: defines the remote URL for all builder
* instances. This environment variable should be set to a fully qualified
* URL for a WebDriver server (e.g. http://localhost:4444/wd/hub). This
* option always takes precedence over {@code SELENIUM_SERVER_JAR}.
*
* - {@code SELENIUM_SERVER_JAR}: defines the path to the
* <a href='http://selenium-release.storage.googleapis.com/index.html'>
* standalone Selenium server</a> jar to use. The server will be started the
* first time a WebDriver instance and be killed when the process exits.
*
* Suppose you had mytest.js that created WebDriver with
*
* var driver = new Builder()
* .forBrowser('chrome')
* .build();
*
* This test could be made to use Firefox on the local machine by running with
* `SELENIUM_BROWSER=firefox node mytest.js`. Rather than change the code to
* target Google Chrome on a remote machine, you can simply set the
* `SELENIUM_BROWSER` and `SELENIUM_REMOTE_URL` environment variables:
*
* SELENIUM_BROWSER=chrome:36:LINUX \
* SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
* node mytest.js
*
* You could also use a local copy of the standalone Selenium server:
*
* SELENIUM_BROWSER=chrome:36:LINUX \
* SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
* node mytest.js
*/
export class Builder {
// region Constructors
/**
* @constructor
*/
constructor();
// endregion
// region Methods
/**
* Configures this builder to ignore any environment variable overrides and to
* only use the configuration specified through this instance's API.
*
* @return {!Builder} A self reference.
*/
disableEnvironmentOverrides(): Builder;