-
Notifications
You must be signed in to change notification settings - Fork 4
/
nightwatch.d.ts
2223 lines (1983 loc) · 88.5 KB
/
nightwatch.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 nightwatchjs
// Project: http://nightwatchjs.org/api
// Definitions by: Rahul Kavalapara
import {NightWatchCustomCommands} from "./custom-commands";
import {NightWatchCustomPageObjects} from "./page-objects";
export interface DesiredCapabilities {
/**
* The name of the browser being used; should be one of {android|chrome|firefox|htmlunit|internet explorer|iPhone|iPad|opera|safari}.
*/
browserName?: string;
/**
* The browser version, or the empty string if unknown.
*/
version?: string;
/**
* A key specifying which platform the browser should be running on. This value should be one of {WINDOWS|XP|VISTA|MAC|LINUX|UNIX|ANDROID}.
* When requesting a new session, the client may specify ANY to indicate any available platform may be used.
* For more information see [GridPlatforms (https://code.google.com/p/selenium/wiki/GridPlatforms)]
*/
platform?: string;
/**
* Whether the session supports taking screenshots of the current page.
*/
takesScreenShot?: boolean;
/**
* Whether the session can interact with modal popups, such as window.alert and window.confirm.
*/
handlesAlerts: boolean;
/**
* Whether the session supports CSS selectors when searching for elements.
*/
cssSelectorsEnabled?: boolean;
/**
* Whether the session supports executing user supplied JavaScript in the context of the current page (only on HTMLUnitDriver).
*/
javascriptEnabled?: boolean;
/**
* Whether the session can interact with database storage.
*/
databaseEnabled?: boolean;
/**
* Whether the session can set and query the browser's location context.
*/
locationContextEnabled?: boolean;
/**
* Whether the session can interact with the application cache.
*/
applicationCacheEnabled?: boolean;
/**
* Whether the session can query for the browser's connectivity and disable it if desired.
*/
browserConnectionEnabled?: boolean;
/**
* Whether the session supports interactions with storage objects (http://www.w3.org/TR/2009/WD-webstorage-20091029/).
*/
webStorageEnabled?: boolean;
/**
* Whether the session should accept all SSL certs by default.
*/
acceptSslCerts?: boolean;
/**
* Whether the session can rotate the current page's current layout between portrait and landscape orientations (only applies to mobile platforms).
*/
rotatable?: boolean;
/**
* Whether the session is capable of generating native events when simulating user input.
*/
nativeEvents?: boolean;
/**
* What the browser should do with an unhandled alert before throwing out the UnhandledAlertException. Possible values are "accept", "dismiss" and "ignore"
*/
unexpectedAlertBehaviour?: string;
/**
* Allows the user to specify whether elements are scrolled into the viewport for interaction to align with the top (0) or bottom (1) of the viewport.
* The default value is to align with the top of the viewport. Supported in IE and Firefox (since 2.36)
*/
elementScrollBehaviour?: number;
/**
* A JSON object describing the logging level of different components in the browser, the driver, or any intermediary WebDriver servers.
* Available values for most loggers are "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL".
* This produces a JSON object looking something like: {"loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "FINE"}}.
*/
loggingPrefs?: {
browser?: string;
driver?: string;
server?: string;
};
}
export interface ScreenshotOptions {
enabled?: boolean;
on_failure?: boolean;
on_error?: boolean;
path?: string;
}
export interface NightWatchTestRunner {
"type"?: string;
options?: {
ui?: string;
};
}
export interface NightWatchTestWorker {
enabled: boolean;
workers: string;
}
export interface NightWatchOptions {
/**
* An array of folders (excluding subfolders) where the tests are located.
*/
src_folders: string | string[];
/**
* The location where the JUnit XML report files will be saved.
*/
output_folder?: string;
/**
* Location(s) where custom commands will be loaded from.
*/
custom_commands_path?: string | string[];
/**
* Location(s) where custom assertions will be loaded from.
*/
custom_assertions_path?: string | string[];
/**
* Location(s) where page object files will be loaded from.
*/
page_object_path?: string | string[];
/**
* Location of an external globals module which will be loaded and made available to the test as a property globals on the main client instance.
* Globals can also be defined/overwritten inside a test_settings environment.
*/
globals_path?: string;
/**
* An object containing Selenium Server related configuration options. See below for details.
*/
selenium?: SeleniumOptions;
/**
* This object contains all the test related options. See below for details.
*/
test_settings: NightWatchTestSettings;
/**
* Whether or not to buffer the output in case of parallel running. See below for details.
*/
live_output?: boolean;
/**
* Controls whether or not to disable coloring of the cli output globally.
*/
disable_color?: boolean;
/**
* Specifies the delay(in milliseconds) between starting the child processes when running in parallel mode.
*/
parallel_process_delay?: number;
/**
* Whether or not to run individual test files in parallel. If set to true, runs the tests in parallel and determines the number of workers automatically.
* If set to an object, can specify specify the number of workers as "auto" or a number. Example: "test_workers" : {"enabled" : true, "workers" : "auto"}
*/
test_workers?: boolean | NightWatchTestWorker;
/**
* Specifies which test runner to use when running the tests. Values can be either default (built in nightwatch runner) or mocha.
* Example: "test_runner" : {"type" : "mocha", "options" : {"ui" : "tdd"}}
*/
test_runner?: string | NightWatchTestRunner;
}
export interface SeleniumOptions {
/**
* Whether or not to manage the selenium process automatically.
*/
start_process: boolean;
/**
* Whether or not to automatically start the Selenium session.
*/
start_session: boolean;
/**
* The location of the selenium jar file. This needs to be specified if start_process is enabled.E.g.: lib/selenium-server-standalone-2.43.0.jar
*/
server_path: string;
/**
* The location where the selenium Selenium-debug.log file will be placed. Defaults to current directory. To disable Selenium logging, set this to false
*/
log_path: string | boolean;
/**
* Usually not required and only used if start_process is true. Specify the IP address you wish Selenium to listen on.
*/
host: string;
/**
* The port number Selenium will listen on.
*/
port: number;
/**
* List of cli arguments to be passed to the Selenium process. Here you can set various options for browser drivers, such as:
*
* webdriver.firefox.profile: Selenium will be default create a new Firefox profile for each session.
* If you wish to use an existing Firefox profile you can specify its name here.
* Complete list of Firefox Driver arguments available https://code.google.com/p/selenium/wiki/FirefoxDriver.
*
* webdriver.chrome.driver: Nightwatch can run the tests using Chrome browser also. To enable this you have to download the ChromeDriver binary
* (http://chromedriver.storage.googleapis.com/index.html) and specify it's location here. Also don't forget to specify chrome as the browser name in the
* desiredCapabilities object.
* More information can be found on the ChromeDriver website (https://sites.google.com/a/chromium.org/chromedriver/).
*
* webdriver.ie.driver: Nightwatch has support for Internet Explorer also. To enable this you have to download the IE Driver binary
* (https://code.google.com/p/selenium/wiki/InternetExplorerDriver) and specify it's location here. Also don't forget to specify "internet explorer" as the browser
* name in the desiredCapabilities object.
*/
cli_args: any;
}
export interface NightWatchTestSettings {
/**
* A url which can be used later in the tests as the main url to load. Can be useful if your tests will run on different environments, each one with a different url.
*/
launch_url: string;
/**
* The hostname/IP on which the selenium server is accepting connections.
*/
selenium_host: string;
/**
* The port number on which the selenium server is accepting connections.
*/
selenium_port: number;
/**
* Whether to show extended Selenium command logs.
*/
silent: boolean;
/**
* Use to disable terminal output completely.
*/
output: boolean;
/**
* Use to disable colored output in the terminal.
*/
disable_colors: boolean;
/**
* Selenium generates screenshots when command errors occur. With on_failure set to true, also generates screenshots for failing or erroring tests. These are saved on the disk.
* Since v0.7.5 you can disable screenshots for command errors by setting "on_error" to false.
* Example:
* "screenshots" : {
* "enabled" : true,
* "on_failure" : true,
* "on_error" : false,
* "path" : ""
* }
*/
screenshots: ScreenshotOptions;
/**
* In case the selenium server requires credentials this username will be used to compute the Authorization header.
* The value can be also an environment variable, in which case it will look like this: "username" : "${SAUCE_USERNAME}"
*/
username: string;
/**
* This field will be used together with username to compute the Authorization header.
* Like username, the value can be also an environment variable: "access_key" : "${SAUCE_ACCESS_KEY}"
*/
access_key: string;
/**
* Proxy requests to the selenium server. http, https, socks(v5), socks5, sock4, and pac are accepted. Uses node-proxy-agent. Example: http://user:pass@host:port
*/
proxy: string;
/**
* An object which will be passed to the Selenium WebDriver when a new session will be created. You can specify browser name for instance along with other capabilities.
* Example:
* "desiredCapabilities" : {
* "browserName" : "firefox",
* "acceptSslCerts" : true
* }
* You can view the complete list of capabilities https://code.google.com/p/selenium/wiki/DesiredCapabilities.
*/
desiredCapabilities: DesiredCapabilities;
/**
* An object which will be made available within the test and can be overwritten per environment. Example:"globals" : { "myGlobal" : "some_global" }
*/
globals: any;
/**
* An array of folders or file patterns to be skipped (relative to the main source folder).
* Example: "exclude" : ["excluded-folder"] or: "exclude" : ["test-folder/*-smoke.js"]
*/
exclude: string[];
/**
* Folder or file pattern to be used when loading the tests. Files that don't match this patter will be ignored.
* Example: "filter" : "tests/*-smoke.js"
*/
filter: string;
/**
* Do not show the Base64 image data in the (verbose) log when taking screenshots.
*/
log_screenshot_data: boolean;
/**
* Use xpath as the default locator strategy
*/
use_xpath: boolean;
/**
* Same as Selenium settings cli_args. You can override the global cli_args on a per-environment basis.
*/
cli_args: any;
/**
* End the session automatically when the test is being terminated, usually after a failed assertion.
*/
end_session_on_fail: boolean;
/**
* Skip the rest of testcases (if any) when one testcase fails..
*/
skip_testcases_on_fail: boolean;
}
export interface TestSuite {
name: string;
"module": string;
group: string;
results: any;
}
export interface AssertionError {
name: string;
message: string;
showDiff: boolean;
stack: string;
}
export interface LanguageChains {
to: Expect;
be: Expect;
been: Expect;
is: Expect;
that: Expect;
which: Expect;
and: Expect;
has: Expect;
have: Expect;
with: Expect;
at: Expect;
of: Expect;
}
export interface Expect extends LanguageChains, NightWatchBrowser {
/**
* Returns the DOM Element
* @param property: Css / Id property of the DOM element
* @returns {}
*/
element: (property: string) => NightWatchBrowser;
/**
* These methods will perform assertions on the specified target on the current element.
* The targets can be an attribute value, the element's inner text and a css property.
* @param value
* @param message
* @returns {}
*/
equal: (value: string) => NightWatchBrowser;
contain: (value: string) => NightWatchBrowser;
match: (value: string) => NightWatchBrowser;
/**
* Negates any of assertions following in the chain.
*/
not: NightWatchBrowser;
/**
* These methods perform the same thing which is essentially retrying the assertion for the given amount of time (in milliseconds).
* before or after can be chained to any assertion and thus adding retry capability. You can change the polling interval by defining
* a waitForConditionPollInterval property (in milliseconds) as a global property in your nightwatch.json or in
* your external globals file. Similarly, a default timeout can be specified as a global waitForConditionTimeout property (in milliseconds).
* @param value: Number of milliseconds to wait to perform and operation of check
* @returns {}
*/
before: (value: number) => NightWatchBrowser;
after: (value: number) => NightWatchBrowser;
/**
* Checks if the type (i.e. tag name) of a specified element is of an expected value.
* @param value: The expected type
* @param message: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
a: (value: string, message?: string) => NightWatchBrowser;
an: (value: string, message?: string) => NightWatchBrowser;
/**
* Checks if a given attribute of an element exists and optionally if it has the expected value.
* @param attribute: The attribute name
* @param message: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
attribute: (name: string, message?: string) => NightWatchBrowser;
/**
* Checks a given css property of an element exists and optionally if it has the expected value.
* @param property: The css property name
* @param message: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
css: (property: string, message?: string) => NightWatchBrowser;
/**
* Property that checks if an element is currently enabled.
*/
enabled: NightWatchBrowser;
/**
* Property that checks if an element is present in the DOM.
*/
present: NightWatchBrowser;
/**
* Property that checks if an OPTION element, or an INPUT element of type checkbox or radio button is currently selected.
*/
selected: NightWatchBrowser;
/**
* Property that retrieves the text contained by an element. Can be chained to check if contains/equals/matches the specified text or regex.
*/
text: NightWatchBrowser;
/**
* Property that retrieves the value (i.e. the value attributed) of an element. Can be chained to check if contains/equals/matches the specified text or regex.
*/
value: NightWatchBrowser;
/**
* Property that asserts the visibility of a specified element.
*/
visible: NightWatchBrowser;
}
export interface Assertion extends NightWatchBrowser {
/**
* Checks if the given attribute of an element contains the expected value.
* @param selector: The selector (CSS / Xpath) used to locate the element.
* @param attribute: The attribute name
* @param expected: The expected contained value of the attribute to check.
* @param message: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
attributeContains: (selector: string, attribute: string, expected: string, message?: string) => NightWatchBrowser;
/**
* Checks if the given attribute of an element has the expected value.
* @param cssSelector: The CSS selector used to locate the element.
* @param attribute: The attribute name
* @param expected: The expected value of the attribute to check.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
attributeEquals: (cssSelector: string, attribute: string, expected: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given element contains the specified text.
* @param cssSelector: The CSS selector used to locate the element.
* @param expectedText: The text to look for.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
containsText: (cssSelector: string, expectedText: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given element has the specified CSS class.
* @param cssSelector: The CSS selector used to locate the element.
* @param className: The CSS class to look for.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
cssClassPresent: (cssSelector: string, className: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given element does not have the specified CSS class.
* @param cssSelector: The CSS selector used to locate the element.
* @param className: The CSS class to look for.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
cssClassNotPresent: (cssSelector: string, className: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the specified css property of a given element has the expected value.
* @param cssSelector: The CSS selector used to locate the element.
* @param cssProperty: The CSS property.
* @param expected: The expected value of the css property to check.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
cssProperty: (cssSelector: string, cssProperty: string, expected: string | number, msg?: string) => NightWatchBrowser;
deepEqual: (value: any, expected: any, message?: string) => NightWatchBrowser;
deepStrictEqual: (value: any, expected: any, message?: string) => NightWatchBrowser;
doesNotThrow: (value: any, expected: any, message?: string) => NightWatchBrowser;
/**
* Checks if the given element exists in the DOM.
* @param cssSelector: The CSS selector used to locate the element.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
elementPresent: (cssSelector: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given element does not exist in the DOM.
* @param cssSelector: The CSS selector used to locate the element.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
elementNotPresent: (cssSelector: string, msg?: string) => NightWatchBrowser;
equal: (value: any, expected: any, message?: string) => NightWatchBrowser;
fail: (actual?: any, expected?: any, message?: string, operator?: string) => NightWatchBrowser;
/**
* Checks if the given element is not visible on the page.
* @param cssSelector: The CSS selector used to locate the element.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
hidden: (cssSelector: string, msg?: string) => NightWatchBrowser;
ifError: (value: any, message?: string) => NightWatchBrowser;
notDeepEqual: (actual: any, expected: any, message?: string) => NightWatchBrowser;
notDeepStrictEqual: (value: any, message?: string) => NightWatchBrowser;
notEqual: (actual: any, expected: any, message?: string) => NightWatchBrowser;
notStrictEqual: (value: any, expected: any, message?: string) => NightWatchBrowser;
ok: (actual: boolean, message?: string) => NightWatchBrowser;
strictEqual: (value: any, expected: any, message?: string) => NightWatchBrowser;
throws: (fn: Function, msg?: string) => NightWatchBrowser;
/**
* Checks if the page title equals the given value.
* @param expected: The expected page title.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*
* Defined in base class.
*/
//title: (expected: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the current URL contains the given value.
* @param expectedText: The value expected to exist within the current URL.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
urlContains: (expectedText: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the current url equals the given value.
* @param expected: The expected url.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
urlEquals: (expected: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given form element's value equals the expected value.
* @param cssSelector: The CSS selector used to locate the element.
* @param expectedText: The expected text.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
value: (cssSelector: string, expectedText: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given form element's value contains the expected value.
* @param cssSelector: The CSS selector used to locate the element.
* @param expectedText: The expected text.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
valueContains: (cssSelector: string, expectedText: string, msg?: string) => NightWatchBrowser;
/**
* Checks if the given element is visible on the page.
* @param cssSelector: The CSS selector used to locate the element.
* @param msg: Optional log message to display in the output. If missing, one is displayed by default.
* @returns {}
*/
visible: (cssSelector: string, msg?: string) => NightWatchBrowser;
AssertionError: AssertionError;
}
export interface TypedCallbackResult<T> {
status: number;
value: T;
}
export interface CallbackResult extends TypedCallbackResult<string | any> {
}
export interface LogEntry {
/**
* The log entry message.
*/
message: string;
/**
* The time stamp of log entry in seconds.
*/
timestamp: number;
/**
* Severity level
*/
level: string;
}
export interface Keys {
/** Releases all held modifier keys. */
"NULL": string;
/** OS-specific keystroke sequence that performs a cancel action. */
"CANCEL": string;
/** The help key. This key only appears on older Apple keyboards in place of the Insert key. */
"HELP": string;
/** The backspace key. */
"BACK_SPACE": string;
/** The tab key. */
"TAB": string;
/** The clear key. This key only appears on full-size Apple keyboards in place of Num Lock key. */
"CLEAR": string;
/** The return key. */
"RETURN": string;
/** The enter (numpad) key. */
"ENTER": string;
/** The shift key. */
"SHIFT": string;
/** The control key. */
"CONTROL": string;
/** The alt key. */
"ALT": string;
/** The pause key. */
"PAUSE": string;
/** The escape key. */
"ESCAPE": string;
/** The space bar. */
"SPACE": string;
/** The page up key. */
"PAGEUP": string;
/** The page down key. */
"PAGEDOWN": string;
/** The end key. */
"END": string;
/** The home key. */
"HOME": string;
/** The left arrow. */
"ARROW_LEFT": string;
"LEFT_ARROW": string;
/** The up arrow. */
"ARROW_UP": string;
"UP_ARROW": string;
/** The right arrow. */
"ARROW_RIGHT": string;
"RIGHT_ARROW": string;
/** The down arrow. */
"ARROW_DOWN": string;
"DOWN_ARROW": string;
/** The insert key. */
"INSERT": string;
/** The delete key. */
"DELETE": string;
/** The semicolon key. */
"SEMICOLON": string;
/** The equals key. */
"EQUALS": string;
/** The numpad zero key. */
"NUMPAD0": string;
/** The numpad one key. */
"NUMPAD1": string;
/** The numpad two key. */
"NUMPAD2": string;
/** The numpad three key. */
"NUMPAD3": string;
/** The numpad four key. */
"NUMPAD4": string;
/** The numpad five key. */
"NUMPAD5": string;
/** The numpad six key. */
"NUMPAD6": string;
/** The numpad seven key. */
"NUMPAD7": string;
/** The numpad eight key. */
"NUMPAD8": string;
/** The numpad nine key. */
"NUMPAD9": string;
/** The numpad multiply (*) key. */
"MULTIPLY": string;
/** The numpad add (+) key. */
"ADD": string;
/** The numpad separator (=) key. */
"SEPARATOR": string;
/** The numpad subtract (-) key. */
"SUBTRACT": string;
/** The numpad decimal (.) key. */
"DECIMAL": string;
/** The numpad divide (/) key. */
"DIVIDE": string;
/** The F1 key. */
"F1": string;
/** The F2 key. */
"F2": string;
/** The F3 key. */
"F3": string;
/** The F4 key. */
"F4": string;
/** The F5 key. */
"F5": string;
/** The F6 key. */
"F6": string;
/** The F7 key. */
"F7": string;
/** The F8 key. */
"F8": string;
/** The F9 key. */
"F9": string;
/** The F10 key. */
"F10": string;
/** The F11 key. */
"F11": string;
/** The F12 key. */
"F12": string;
/** The meta (Windows) key. */
"META": string;
/** The command (⌘) key. */
"COMMAND": string;
}
export interface NightWatchClient {
assert: Assertion;
expect: Expect;
verify: Assertion;
/**
* Clear a textarea or a text input element's value. Uses elementIdValue protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.clearValue('input[type=text]');
* };
* ```
* @param selector: The CSS/Xpath selector used to locate the element.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
clearValue: (selector: string, callback?: () => void) => NightWatchBrowser;
/**
* Simulates a click event on the given DOM element. Uses elementIdClick protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.click("#main ul li a.first");
* };
* ```
* @param selector: The CSS/Xpath selector used to locate the element.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
click: (selector: string, callback?: () => void) => NightWatchBrowser;
/**
* Close the current window. This can be useful when you're working with multiple windows open (e.g. an OAuth login). Uses window protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.closeWindow();
* };
* ```
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
closeWindow: (callback?: () => void) => NightWatchBrowser;
/**
* Delete the cookie with the given name. This command is a no-op if there is no such cookie visible to the current page.
*
* Usage:
* ```
* this.demoTest = function(browser) {
* browser.deleteCookie("test_cookie", function() {
* // do something more in here
* });
* }
* ```
* @param The: name of the cookie to delete.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
deleteCookie: (The: string, callback?: () => void) => NightWatchBrowser;
/**
* Delete all cookies visible to the current page.
*
* Usage:
* ```
* this.demoTest = function(browser) {
* browser.deleteCookies(function() {
* // do something more in here
* });
* }
* ```
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
deleteCookies: (callback?: () => void) => NightWatchBrowser;
/**
* Ends the session. Uses session protocol command.
*
* Usage:
* ```
* this.demoTest = function (browser) {
* browser.end();
* };
* ```
* @param callback: Optional callback function to be called when the command finishes.
* @returns {}
*/
end: (callback?: () => void) => NightWatchBrowser;
/**
* Retrieve the value of an attribute for a given DOM element. Uses elementIdAttribute protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.getAttribute("#main ul li a.first", "href", function(result) {
* this.assert.equal(typeof result, "object");
* this.assert.equal(result.status, 0);
* this.assert.equal(result.value, "#home");
* });
* };
* ```
* @param selector: The CSS/Xpath selector used to locate the element.
* @param attribute: The attribute name to inspect.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {The value of the attribute}
*/
getAttribute: (selector: string, attribute: string, callback?: (result: CallbackResult) => void) => NightWatchBrowser;
/**
* Retrieve a single cookie visible to the current page. The cookie is returned as a cookie JSON object, as defined here.
* Uses cookie protocol command.
*
* Usage:
* ```
* this.demoTest = function(browser) {
* browser.getCookie(name, function callback(result) {
* this.assert.equal(result.value, '123456');
* this.assert.equals(result.name, 'test_cookie');
* });
* }
* ```
* @param name: The cookie name
* @param callback: The callback function which will receive the response as an argument.
* @returns {The cookie object as a selenium cookie JSON object or null if the cookie wasn't found.}
*/
getCookie: (name: string, callback?: (result: CallbackResult) => void) => NightWatchBrowser;
/**
* Retrieve all cookies visible to the current page. The cookies are returned as an array of cookie JSON object,
* as defined here. Uses cookie protocol command.
*
* Usage:
* ```
* this.demoTest = function(browser) {
* browser.getCookies(function callback(result) {
* this.assert.equal(result.value.length, 1);
* this.assert.equals(result.value[0].name, 'test_cookie');
* });
* }
* ```
* @param callback: The callback function which will receive the response as an argument.
* @returns {A list of cookies}
*/
getCookies: (callback?: (result: CallbackResult) => void) => NightWatchBrowser;
/**
* Retrieve the value of a css property for a given DOM element. Uses elementIdCssProperty protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.getCssProperty("#main ul li a.first", "display", function(result) {
* this.assert.equal(typeof result, "object");
* this.assert.equal(result.status, 0);
* this.assert.equal(result.value, 'inline');
* });
* };
* ```
* @param selector: The CSS/Xpath selector used to locate the element.
* @param cssProperty: The CSS property to inspect.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {The value of the css property}
*/
getCssProperty: (selector: string, cssProperty: string, callback?: (result: CallbackResult) => void) => NightWatchBrowser;
/**
* Determine an element's size in pixels. Uses elementIdSize protocol command.
*
* Usage:
* ```
* this.demoTest = function (client) {
* client.getElementSize("#main ul li a.first", function(result) {
* this.assert.equal(typeof result, "object");
* this.assert.equal(result.status, 0);
* this.assert.equal(result.value.width, 500);
* this.assert.equal(result.value.height, 20);
* });
* };
* ```
* @param selector: The CSS/Xpath selector used to locate the element.
* @param callback: Optional callback function to be called when the command finishes.
* @returns {The width and height of the element in pixels}
*/
getElementSize: (selector: string, callback?: (result: CallbackResult) => void) => NightWatchBrowser;
/**
* Determine an element's location on the page. The point (0, 0) refers to the upper-left corner of the page.
* The element's coordinates are returned as a JSON object with x and y properties. Uses elementIdLocation protocol command.
*
* Usage:
* ```