@testspectra/matchers 1.1.0 → 1.1.8-rc.2
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/dist/__tests__/matchers.test.js +0 -8
- package/dist/contract.d.ts +173 -0
- package/dist/contract.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/proto.d.ts +8 -0
- package/dist/runner/collection.d.ts +16 -4
- package/dist/runner/collection.js +24 -12
- package/dist/runner/single.d.ts +28 -2
- package/dist/runner/single.js +55 -36
- package/dist/semantic.d.ts +11 -0
- package/dist/semantic.js +141 -0
- package/dist/spectra.d.ts +3 -3
- package/dist/spectra.js +3 -3
- package/dist/types.d.ts +246 -115
- package/package.json +11 -10
- package/src/contract.ts +223 -0
- package/src/index.ts +1 -0
- package/src/proto.ts +35 -27
- package/src/runtime/assertions.ts +453 -0
- package/src/runtime/element_actions.ts +178 -0
- package/src/runtime/element_proxy.ts +200 -0
- package/src/runtime/element_state.ts +94 -0
- package/src/runtime/spectra.ts +110 -0
- package/src/types.ts +1648 -1521
- package/tsconfig.json +17 -17
package/src/types.ts
CHANGED
|
@@ -1,1521 +1,1648 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical action keys supported across TestSpectra runner and database models.
|
|
3
|
-
* @see backend/src/models/test_step.rs
|
|
4
|
-
*/
|
|
5
|
-
export type ActionKey =
|
|
6
|
-
| 'navigate'
|
|
7
|
-
| 'click'
|
|
8
|
-
| 'type'
|
|
9
|
-
| 'clear'
|
|
10
|
-
| 'select'
|
|
11
|
-
| 'scroll'
|
|
12
|
-
| 'swipe'
|
|
13
|
-
| 'wait'
|
|
14
|
-
| 'waitForElement'
|
|
15
|
-
| 'pressKey'
|
|
16
|
-
| 'longPress'
|
|
17
|
-
| 'doubleClick'
|
|
18
|
-
| 'hover'
|
|
19
|
-
| 'dragDrop'
|
|
20
|
-
| 'back'
|
|
21
|
-
| 'refresh';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Canonical assertion keys supported across TestSpectra runner and database models.
|
|
25
|
-
* @see backend/src/models/test_step.rs
|
|
26
|
-
*/
|
|
27
|
-
export type AssertionKey =
|
|
28
|
-
| 'elementDisplayed'
|
|
29
|
-
| 'elementNotDisplayed'
|
|
30
|
-
| 'elementExists'
|
|
31
|
-
| 'elementNotExists'
|
|
32
|
-
| 'elementClickable'
|
|
33
|
-
| 'elementNotClickable'
|
|
34
|
-
| 'elementEnabled'
|
|
35
|
-
| 'elementDisabled'
|
|
36
|
-
| 'elementChecked'
|
|
37
|
-
| 'elementNotChecked'
|
|
38
|
-
| 'elementFocused'
|
|
39
|
-
| 'elementNotFocused'
|
|
40
|
-
| 'textEquals'
|
|
41
|
-
| 'textNotEquals'
|
|
42
|
-
| 'textContains'
|
|
43
|
-
| 'textNotContains'
|
|
44
|
-
| 'valueEquals'
|
|
45
|
-
| 'valueNotEquals'
|
|
46
|
-
| 'valueContains'
|
|
47
|
-
| 'valueNotContains'
|
|
48
|
-
| 'attributeEquals'
|
|
49
|
-
| 'attributeNotEquals'
|
|
50
|
-
| 'hasClass'
|
|
51
|
-
| 'notHasClass'
|
|
52
|
-
| 'hasCss'
|
|
53
|
-
| 'notHasCss'
|
|
54
|
-
| 'collectionLengthEquals'
|
|
55
|
-
| 'collectionLengthNotEquals'
|
|
56
|
-
| 'collectionLengthGreaterThan'
|
|
57
|
-
| 'collectionLengthLessThan'
|
|
58
|
-
| 'collectionEmpty'
|
|
59
|
-
| 'collectionNotEmpty'
|
|
60
|
-
| 'urlEquals'
|
|
61
|
-
| 'urlContains'
|
|
62
|
-
| 'titleEquals'
|
|
63
|
-
| 'titleContains'
|
|
64
|
-
| 'pageLoaded'
|
|
65
|
-
| 'noConsoleErrors';
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Supported keyboard key names for `Spectra.pressKey(key)`.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* await Spectra.pressKey("Enter");
|
|
73
|
-
* await Spectra.pressKey("Tab");
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
export type KeyOption =
|
|
77
|
-
| 'Enter'
|
|
78
|
-
| 'Tab'
|
|
79
|
-
| 'Escape'
|
|
80
|
-
| 'Backspace'
|
|
81
|
-
| 'Delete'
|
|
82
|
-
| 'ArrowUp'
|
|
83
|
-
| 'ArrowDown'
|
|
84
|
-
| 'ArrowLeft'
|
|
85
|
-
| 'ArrowRight'
|
|
86
|
-
| 'Space';
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Cardinal directions for gestures such as swipe and scroll.
|
|
90
|
-
*/
|
|
91
|
-
export type Direction = 'up' | 'down' | 'left' | 'right';
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Target reference for locating an element.
|
|
95
|
-
* Can be a CSS/XPath selector string, a resolved `SpectraElement` proxy,
|
|
96
|
-
* or a chainable element promise `Promise<SpectraElement>`.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* // Selector string
|
|
101
|
-
* Spectra.get("#submit-btn");
|
|
102
|
-
*
|
|
103
|
-
* // Page Object property
|
|
104
|
-
* Spectra.get(LoginPage.submitButton);
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export type ElementTarget = string | SingleElementProxy | Promise<SingleElementProxy>;
|
|
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
|
-
| 'not.
|
|
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
|
-
* await
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Asserts that the target element is
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* ```ts
|
|
294
|
-
* await Spectra.get('
|
|
295
|
-
* ```
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Asserts that the target
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```ts
|
|
304
|
-
* await Spectra.get('#
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Asserts that the target
|
|
311
|
-
*
|
|
312
|
-
* @example
|
|
313
|
-
* ```ts
|
|
314
|
-
* await Spectra.get('#
|
|
315
|
-
* ```
|
|
316
|
-
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Asserts that the target
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* await Spectra.get('
|
|
325
|
-
* ```
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Asserts that the target
|
|
331
|
-
*
|
|
332
|
-
* @example
|
|
333
|
-
* ```ts
|
|
334
|
-
* await Spectra.get('
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Asserts that the target
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* ```ts
|
|
344
|
-
* await Spectra.get('#
|
|
345
|
-
* ```
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Asserts that the target
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```ts
|
|
354
|
-
* await Spectra.get('#
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Asserts that the target
|
|
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
|
-
* @param
|
|
539
|
-
* @example
|
|
540
|
-
* ```ts
|
|
541
|
-
* await Spectra.
|
|
542
|
-
* ```
|
|
543
|
-
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Asserts that the
|
|
548
|
-
*
|
|
549
|
-
* @param
|
|
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
|
-
* @example
|
|
672
|
-
* ```ts
|
|
673
|
-
* await Spectra.browser.
|
|
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
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
* ```
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
*
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
*
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1078
|
-
* @
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
* @example
|
|
1116
|
-
* ```ts
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
*/
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
* @param
|
|
1136
|
-
* @param
|
|
1137
|
-
* @
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
* ```
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
/**
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
|
|
1215
|
-
/**
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
|
|
1225
|
-
*/
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
* @
|
|
1256
|
-
*
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1266
|
-
*
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
*
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
*
|
|
1279
|
-
*/
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
*
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
/**
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
/**
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
*
|
|
1330
|
-
*
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
*
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
*
|
|
1348
|
-
*
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1357
|
-
* ```
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
*
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
*
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
* ```
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
1481
|
-
*
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
*
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
* @param
|
|
1500
|
-
* @
|
|
1501
|
-
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
*
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Canonical action keys supported across TestSpectra runner and database models.
|
|
3
|
+
* @see backend/src/models/test_step.rs
|
|
4
|
+
*/
|
|
5
|
+
export type ActionKey =
|
|
6
|
+
| 'navigate'
|
|
7
|
+
| 'click'
|
|
8
|
+
| 'type'
|
|
9
|
+
| 'clear'
|
|
10
|
+
| 'select'
|
|
11
|
+
| 'scroll'
|
|
12
|
+
| 'swipe'
|
|
13
|
+
| 'wait'
|
|
14
|
+
| 'waitForElement'
|
|
15
|
+
| 'pressKey'
|
|
16
|
+
| 'longPress'
|
|
17
|
+
| 'doubleClick'
|
|
18
|
+
| 'hover'
|
|
19
|
+
| 'dragDrop'
|
|
20
|
+
| 'back'
|
|
21
|
+
| 'refresh';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Canonical assertion keys supported across TestSpectra runner and database models.
|
|
25
|
+
* @see backend/src/models/test_step.rs
|
|
26
|
+
*/
|
|
27
|
+
export type AssertionKey =
|
|
28
|
+
| 'elementDisplayed'
|
|
29
|
+
| 'elementNotDisplayed'
|
|
30
|
+
| 'elementExists'
|
|
31
|
+
| 'elementNotExists'
|
|
32
|
+
| 'elementClickable'
|
|
33
|
+
| 'elementNotClickable'
|
|
34
|
+
| 'elementEnabled'
|
|
35
|
+
| 'elementDisabled'
|
|
36
|
+
| 'elementChecked'
|
|
37
|
+
| 'elementNotChecked'
|
|
38
|
+
| 'elementFocused'
|
|
39
|
+
| 'elementNotFocused'
|
|
40
|
+
| 'textEquals'
|
|
41
|
+
| 'textNotEquals'
|
|
42
|
+
| 'textContains'
|
|
43
|
+
| 'textNotContains'
|
|
44
|
+
| 'valueEquals'
|
|
45
|
+
| 'valueNotEquals'
|
|
46
|
+
| 'valueContains'
|
|
47
|
+
| 'valueNotContains'
|
|
48
|
+
| 'attributeEquals'
|
|
49
|
+
| 'attributeNotEquals'
|
|
50
|
+
| 'hasClass'
|
|
51
|
+
| 'notHasClass'
|
|
52
|
+
| 'hasCss'
|
|
53
|
+
| 'notHasCss'
|
|
54
|
+
| 'collectionLengthEquals'
|
|
55
|
+
| 'collectionLengthNotEquals'
|
|
56
|
+
| 'collectionLengthGreaterThan'
|
|
57
|
+
| 'collectionLengthLessThan'
|
|
58
|
+
| 'collectionEmpty'
|
|
59
|
+
| 'collectionNotEmpty'
|
|
60
|
+
| 'urlEquals'
|
|
61
|
+
| 'urlContains'
|
|
62
|
+
| 'titleEquals'
|
|
63
|
+
| 'titleContains'
|
|
64
|
+
| 'pageLoaded'
|
|
65
|
+
| 'noConsoleErrors';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Supported keyboard key names for `Spectra.pressKey(key)`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* await Spectra.pressKey("Enter");
|
|
73
|
+
* await Spectra.pressKey("Tab");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export type KeyOption =
|
|
77
|
+
| 'Enter'
|
|
78
|
+
| 'Tab'
|
|
79
|
+
| 'Escape'
|
|
80
|
+
| 'Backspace'
|
|
81
|
+
| 'Delete'
|
|
82
|
+
| 'ArrowUp'
|
|
83
|
+
| 'ArrowDown'
|
|
84
|
+
| 'ArrowLeft'
|
|
85
|
+
| 'ArrowRight'
|
|
86
|
+
| 'Space';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Cardinal directions for gestures such as swipe and scroll.
|
|
90
|
+
*/
|
|
91
|
+
export type Direction = 'up' | 'down' | 'left' | 'right';
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Target reference for locating an element.
|
|
95
|
+
* Can be a CSS/XPath selector string, a resolved `SpectraElement` proxy,
|
|
96
|
+
* or a chainable element promise `Promise<SpectraElement>`.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* // Selector string
|
|
101
|
+
* Spectra.get("#submit-btn");
|
|
102
|
+
*
|
|
103
|
+
* // Page Object property
|
|
104
|
+
* Spectra.get(LoginPage.submitButton);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export type ElementTarget = string | SingleElementProxy | Promise<SingleElementProxy>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Internal descriptor for a selector resolved relative to a parent element, produced by
|
|
111
|
+
* `element.get()` / `element.getAll()` chaining (see `SingleElementProxy.get`). Recursive so
|
|
112
|
+
* arbitrarily deep chains (e.g. `Spectra.getAll('.card').nth(2).get('.buy-btn')`) carry their
|
|
113
|
+
* full ancestry down to the driver.
|
|
114
|
+
*
|
|
115
|
+
* Resolution differs per platform: web (CDP) nests real DOM `.querySelector()` calls against the
|
|
116
|
+
* resolved parent; Android has no ancestor/descendant API, so the parent's bounds rectangle is
|
|
117
|
+
* used to filter candidates via containment (a child is "within" the parent if its bounds sit
|
|
118
|
+
* inside the parent's).
|
|
119
|
+
*/
|
|
120
|
+
export interface ScopedSelector {
|
|
121
|
+
/** This level's own selector string (`~`/`#` shorthand or raw CSS/xpath), not the full chain. */
|
|
122
|
+
selector: string;
|
|
123
|
+
/** Positional index at this level, or null. */
|
|
124
|
+
index: number | null;
|
|
125
|
+
/** The element this selector is scoped within, or undefined for a root-level selector. */
|
|
126
|
+
parent?: ScopedSelector;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Configuration options for scroll actions.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* await Spectra.scroll({ direction: "down", pixels: 300 });
|
|
135
|
+
* await Spectra.scroll({ selector: "#footer" });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export interface ScrollOptions {
|
|
139
|
+
/** Direction to scroll (default: "down") */
|
|
140
|
+
direction?: Direction;
|
|
141
|
+
/** Distance in pixels to scroll (default: 500) */
|
|
142
|
+
pixels?: number;
|
|
143
|
+
/** Optional target element selector to scroll directly into view */
|
|
144
|
+
selector?: ElementTarget;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Configuration options for touch swipe gestures (mobile & web).
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* await Spectra.swipe({ direction: "left", distance: 400 });
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export interface SwipeOptions {
|
|
156
|
+
/** Direction of the swipe gesture */
|
|
157
|
+
direction: Direction;
|
|
158
|
+
/** Distance in pixels to swipe (default: 300) */
|
|
159
|
+
distance?: number;
|
|
160
|
+
/** Optional element target to anchor the swipe gesture */
|
|
161
|
+
selector?: ElementTarget;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Configuration options for long-press gestures.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* await Spectra.longPress("#draggable-card", { duration: 1500 });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export interface LongPressOptions {
|
|
173
|
+
/** Optional label or text associated with the element */
|
|
174
|
+
text?: string;
|
|
175
|
+
/** Duration in milliseconds to hold the press (default: 1000) */
|
|
176
|
+
duration?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Configuration options for click interactions.
|
|
181
|
+
*/
|
|
182
|
+
export interface ClickOptions {
|
|
183
|
+
/** Optional inner text filter */
|
|
184
|
+
text?: string;
|
|
185
|
+
/** Click type: standard single click or double click */
|
|
186
|
+
clickType?: 'single' | 'double';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Configuration options for typing input into form elements.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* await Spectra.type("#username", "john_doe", { clearFirst: true });
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export interface TypeOptions {
|
|
198
|
+
/** Whether to clear existing input value before typing new text (default: false) */
|
|
199
|
+
clearFirst?: boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Per-call override for how long an assertion polls before failing, mirroring Playwright's
|
|
204
|
+
* `{ timeout }` option on web-first assertions (`expect(locator).toHaveText(x, { timeout })`).
|
|
205
|
+
*
|
|
206
|
+
* Defaults to the adaptive assertion timeout (`Spectra`'s fail-fast cap, distinct from
|
|
207
|
+
* `implicitWait`) when omitted — pass this when a specific assertion is known to need longer,
|
|
208
|
+
* e.g. right after a deliberately delayed `Spectra.intercept(..., { delayMs })` mock, without
|
|
209
|
+
* raising the timeout for every other assertion in the test.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const mock = await Spectra.intercept('/api/report', { response: { delayMs: 4000, body } });
|
|
214
|
+
* await ReportPage.statusBadge.shouldHaveText('Ready', { timeoutMs: 5000 });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export interface AssertionOptions {
|
|
218
|
+
/** Maximum time (in milliseconds) to keep polling before the assertion fails. */
|
|
219
|
+
timeoutMs?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Canonical assertion matcher keys for single element verification.
|
|
224
|
+
* Dispatched internally by semantic receiver methods (`.shouldBeVisible()`, `.shouldHaveText()`, etc.).
|
|
225
|
+
*/
|
|
226
|
+
export type SingleElementMatcher =
|
|
227
|
+
| 'be.visible'
|
|
228
|
+
| 'not.be.visible'
|
|
229
|
+
| 'exist'
|
|
230
|
+
| 'not.exist'
|
|
231
|
+
| 'be.clickable'
|
|
232
|
+
| 'not.be.clickable'
|
|
233
|
+
| 'be.enabled'
|
|
234
|
+
| 'be.disabled'
|
|
235
|
+
| 'be.checked'
|
|
236
|
+
| 'not.be.checked'
|
|
237
|
+
| 'be.selected'
|
|
238
|
+
| 'not.be.selected'
|
|
239
|
+
| 'be.focused'
|
|
240
|
+
| 'not.be.focused'
|
|
241
|
+
| 'have.value'
|
|
242
|
+
| 'not.have.value'
|
|
243
|
+
| 'contain.value'
|
|
244
|
+
| 'not.contain.value'
|
|
245
|
+
| 'have.text'
|
|
246
|
+
| 'not.have.text'
|
|
247
|
+
| 'contain.text'
|
|
248
|
+
| 'not.contain.text'
|
|
249
|
+
| 'have.class'
|
|
250
|
+
| 'not.have.class'
|
|
251
|
+
| 'have.attr'
|
|
252
|
+
| 'not.have.attr'
|
|
253
|
+
| 'have.css'
|
|
254
|
+
| 'not.have.css'
|
|
255
|
+
| 'have.url'
|
|
256
|
+
| 'contain.url'
|
|
257
|
+
| 'have.title'
|
|
258
|
+
| 'contain.title';
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Canonical assertion matcher keys for multi-element collections.
|
|
262
|
+
* Dispatched internally by semantic collection methods (`.shouldHaveLength()`, `.shouldBeEmpty()`, etc.).
|
|
263
|
+
*/
|
|
264
|
+
export type MultiElementMatcher =
|
|
265
|
+
| 'have.length'
|
|
266
|
+
| 'not.have.length'
|
|
267
|
+
| 'have.length.greaterThan'
|
|
268
|
+
| 'have.length.lessThan'
|
|
269
|
+
| 'be.empty'
|
|
270
|
+
| 'not.be.empty'
|
|
271
|
+
| 'exist';
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Receiver-oriented element assertion methods.
|
|
275
|
+
* Attached directly to SingleElementProxy instances.
|
|
276
|
+
*/
|
|
277
|
+
export interface ElementReceiverAssertions<TReturn = Promise<void>> {
|
|
278
|
+
/**
|
|
279
|
+
* Asserts that the target element is visible and displayed on the page.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* await Spectra.get('#submit-btn').shouldBeVisible();
|
|
284
|
+
* await LoginPage.submitButton.shouldBeVisible();
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
shouldBeVisible(options?: AssertionOptions): TReturn;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Asserts that the target element is hidden, detached, or not displayed on the page.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* await Spectra.get('.loading-spinner').shouldNotBeVisible();
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
shouldNotBeVisible(options?: AssertionOptions): TReturn;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Asserts that the target element exists in the DOM.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* await Spectra.get('#cookie-consent-modal').shouldExist();
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
shouldExist(options?: AssertionOptions): TReturn;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Asserts that the target element does not exist in the DOM.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* await Spectra.get('#deleted-record-row').shouldNotExist();
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
shouldNotExist(options?: AssertionOptions): TReturn;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Asserts that the target element is visible, enabled, and clickable.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* await Spectra.get('button[type="submit"]').shouldBeClickable();
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
shouldBeClickable(options?: AssertionOptions): TReturn;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Asserts that the target element is disabled, covered, or not clickable.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* await Spectra.get('button.disabled-action').shouldNotBeClickable();
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
shouldNotBeClickable(options?: AssertionOptions): TReturn;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Asserts that the target form input/button is enabled (not disabled).
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* await Spectra.get('#username-field').shouldBeEnabled();
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
shouldBeEnabled(options?: AssertionOptions): TReturn;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Asserts that the target form input/button has the disabled state/attribute.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* await Spectra.get('#submit-order-btn').shouldBeDisabled();
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
shouldBeDisabled(options?: AssertionOptions): TReturn;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Asserts that the target checkbox or radio input is checked/selected.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```ts
|
|
364
|
+
* await Spectra.get('#terms-checkbox').shouldBeChecked();
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
shouldBeChecked(options?: AssertionOptions): TReturn;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Asserts that the target checkbox or radio input is unchecked/deselected.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* await Spectra.get('#subscribe-newsletter').shouldNotBeChecked();
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
shouldNotBeChecked(options?: AssertionOptions): TReturn;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Asserts that the target element currently holds active document focus.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```ts
|
|
384
|
+
* await Spectra.get('#search-input').shouldBeFocused();
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
shouldBeFocused(options?: AssertionOptions): TReturn;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Asserts that the target element does not hold active document focus.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* await Spectra.get('#blur-input').shouldNotBeFocused();
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
shouldNotBeFocused(options?: AssertionOptions): TReturn;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Asserts that the target element's text content matches the expected string or regular expression.
|
|
401
|
+
*
|
|
402
|
+
* @param expected Exact string or RegExp pattern to match against element text.
|
|
403
|
+
* @example
|
|
404
|
+
* ```ts
|
|
405
|
+
* await Spectra.get('h1.page-title').shouldHaveText('Dashboard Overview');
|
|
406
|
+
* await Spectra.get('.badge').shouldHaveText(/Active|Pending/);
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
shouldHaveText(expected: string | RegExp, options?: AssertionOptions): TReturn;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Asserts that the target element's text content does not match the expected string or regular expression.
|
|
413
|
+
*
|
|
414
|
+
* @param expected String or RegExp pattern that the element text must NOT match.
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* await Spectra.get('.status-label').shouldNotHaveText('Error');
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
shouldNotHaveText(expected: string | RegExp, options?: AssertionOptions): TReturn;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Asserts that the target element's text content contains the specified substring.
|
|
424
|
+
*
|
|
425
|
+
* @param substring Substring expected to be present within the element text.
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* await Spectra.get('.toast-message').shouldContainText('Successfully saved');
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
shouldContainText(substring: string, options?: AssertionOptions): TReturn;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Asserts that the target element's text content does not contain the specified substring.
|
|
435
|
+
*
|
|
436
|
+
* @param substring Substring that must NOT be present within the element text.
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* await Spectra.get('.log-output').shouldNotContainText('Fatal Exception');
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
shouldNotContainText(substring: string, options?: AssertionOptions): TReturn;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Asserts that the form input or textarea element's value exactly equals the specified string.
|
|
446
|
+
*
|
|
447
|
+
* @param value Expected input field value.
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* await Spectra.get('input[name="email"]').shouldHaveValue('admin@testspectra.dev');
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
shouldHaveValue(value: string, options?: AssertionOptions): TReturn;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Asserts that the form input or textarea element's value does not equal the specified string.
|
|
457
|
+
*
|
|
458
|
+
* @param value Value that the input field must NOT equal.
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* await Spectra.get('input[name="role"]').shouldNotHaveValue('guest');
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
shouldNotHaveValue(value: string, options?: AssertionOptions): TReturn;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Asserts that the form input or textarea element's value contains the specified substring.
|
|
468
|
+
*
|
|
469
|
+
* @param substring Substring expected to be contained within the input value.
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* await Spectra.get('input[name="email"]').shouldContainValue('@testspectra.dev');
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
shouldContainValue(substring: string, options?: AssertionOptions): TReturn;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Asserts that the form input or textarea element's value does not contain the specified substring.
|
|
479
|
+
*
|
|
480
|
+
* @param substring Substring that must NOT be contained within the input value.
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* await Spectra.get('input[name="url"]').shouldNotContainValue('http://');
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
shouldNotContainValue(substring: string, options?: AssertionOptions): TReturn;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Asserts that the element has the specified attribute, and optionally that its value matches.
|
|
490
|
+
*
|
|
491
|
+
* @param name Attribute name to inspect.
|
|
492
|
+
* @param value Optional expected attribute value string.
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* await Spectra.get('a.external-link').shouldHaveAttribute('target', '_blank');
|
|
496
|
+
* await Spectra.get('input.required-field').shouldHaveAttribute('required');
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
shouldHaveAttribute(name: string, value?: string, options?: AssertionOptions): TReturn;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Asserts that the element does not have the specified attribute.
|
|
503
|
+
*
|
|
504
|
+
* @param name Attribute name that must NOT exist on the element.
|
|
505
|
+
* @example
|
|
506
|
+
* ```ts
|
|
507
|
+
* await Spectra.get('button#action-btn').shouldNotHaveAttribute('disabled');
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
shouldNotHaveAttribute(name: string, options?: AssertionOptions): TReturn;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Asserts that the element contains the specified CSS class name.
|
|
514
|
+
*
|
|
515
|
+
* @param className CSS class name expected in the element's classList.
|
|
516
|
+
* @example
|
|
517
|
+
* ```ts
|
|
518
|
+
* await Spectra.get('.nav-tab').shouldHaveClass('active');
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
shouldHaveClass(className: string, options?: AssertionOptions): TReturn;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Asserts that the element does not contain the specified CSS class name.
|
|
525
|
+
*
|
|
526
|
+
* @param className CSS class name that must NOT be in the element's classList.
|
|
527
|
+
* @example
|
|
528
|
+
* ```ts
|
|
529
|
+
* await Spectra.get('.modal-backdrop').shouldNotHaveClass('hidden');
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
shouldNotHaveClass(className: string, options?: AssertionOptions): TReturn;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Asserts that the computed CSS style property of the element equals the specified value.
|
|
536
|
+
*
|
|
537
|
+
* @param property CSS style property name (e.g. 'color', 'display', 'opacity').
|
|
538
|
+
* @param value Expected computed CSS property value.
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* await Spectra.get('.badge-success').shouldHaveCss('color', 'rgb(0, 128, 0)');
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
shouldHaveCss(property: string, value: string, options?: AssertionOptions): TReturn;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Asserts that the computed CSS style property of the element does not equal the specified value.
|
|
548
|
+
*
|
|
549
|
+
* @param property CSS style property name.
|
|
550
|
+
* @param value Value that the computed CSS property must NOT equal.
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* await Spectra.get('.main-content').shouldNotHaveCss('display', 'none');
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
shouldNotHaveCss(property: string, value: string, options?: AssertionOptions): TReturn;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Receiver-oriented collection assertion methods.
|
|
561
|
+
* Attached directly to CollectionProxy and collection prototypes.
|
|
562
|
+
*/
|
|
563
|
+
export interface CollectionReceiverAssertions<TReturn = Promise<void>> {
|
|
564
|
+
/**
|
|
565
|
+
* Asserts that the collection contains exactly the specified number of matching elements.
|
|
566
|
+
*
|
|
567
|
+
* @param count Expected exact count of elements.
|
|
568
|
+
* @example
|
|
569
|
+
* ```ts
|
|
570
|
+
* await Spectra.getAll('.user-table-row').shouldHaveLength(10);
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
shouldHaveLength(count: number, options?: AssertionOptions): TReturn;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Asserts that the collection does not contain the specified number of matching elements.
|
|
577
|
+
*
|
|
578
|
+
* @param count Count that the element collection must NOT equal.
|
|
579
|
+
* @example
|
|
580
|
+
* ```ts
|
|
581
|
+
* await Spectra.getAll('.error-item').shouldNotHaveLength(0);
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
shouldNotHaveLength(count: number, options?: AssertionOptions): TReturn;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Asserts that the collection contains strictly more than `min` matching elements.
|
|
588
|
+
*
|
|
589
|
+
* @param min Minimum threshold (exclusive).
|
|
590
|
+
* @example
|
|
591
|
+
* ```ts
|
|
592
|
+
* await Spectra.getAll('.search-result-card').shouldHaveLengthGreaterThan(0);
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
shouldHaveLengthGreaterThan(min: number, options?: AssertionOptions): TReturn;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Asserts that the collection contains strictly fewer than `max` matching elements.
|
|
599
|
+
*
|
|
600
|
+
* @param max Maximum threshold (exclusive).
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* await Spectra.getAll('.warning-banner').shouldHaveLengthLessThan(5);
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
shouldHaveLengthLessThan(max: number, options?: AssertionOptions): TReturn;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Asserts that the collection contains zero matching elements.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```ts
|
|
613
|
+
* await Spectra.getAll('.unread-notification-badge').shouldBeEmpty();
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
616
|
+
shouldBeEmpty(options?: AssertionOptions): TReturn;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Asserts that the collection contains at least one matching element.
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```ts
|
|
623
|
+
* await Spectra.getAll('.product-card').shouldNotBeEmpty();
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
shouldNotBeEmpty(options?: AssertionOptions): TReturn;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Browser-level context assertion methods.
|
|
631
|
+
* Hosted on Spectra.browser and the global browser object.
|
|
632
|
+
*/
|
|
633
|
+
export interface BrowserReceiverAssertions {
|
|
634
|
+
/**
|
|
635
|
+
* Asserts that current browser URL exactly matches the expected URL.
|
|
636
|
+
*
|
|
637
|
+
* @param expectedUrl Full expected URL string.
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* await Spectra.browser.shouldHaveUrl('https://app.testspectra.dev/dashboard');
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
shouldHaveUrl(expectedUrl: string, options?: AssertionOptions): Promise<void>;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Asserts that current browser URL contains the specified substring.
|
|
647
|
+
*
|
|
648
|
+
* @param expectedSubstr Substring expected in browser URL.
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* await Spectra.browser.shouldContainUrl('/dashboard');
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
shouldContainUrl(expectedSubstr: string, options?: AssertionOptions): Promise<void>;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Asserts that current page title exactly matches the expected title.
|
|
658
|
+
*
|
|
659
|
+
* @param expectedTitle Full expected page title string.
|
|
660
|
+
* @example
|
|
661
|
+
* ```ts
|
|
662
|
+
* await Spectra.browser.shouldHaveTitle('Dashboard - TestSpectra');
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
665
|
+
shouldHaveTitle(expectedTitle: string, options?: AssertionOptions): Promise<void>;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Asserts that current page title contains the specified substring.
|
|
669
|
+
*
|
|
670
|
+
* @param expectedSubstr Substring expected in page title.
|
|
671
|
+
* @example
|
|
672
|
+
* ```ts
|
|
673
|
+
* await Spectra.browser.shouldContainTitle('Dashboard');
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
shouldContainTitle(expectedSubstr: string, options?: AssertionOptions): Promise<void>;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Asserts that the browser document `readyState` is 'complete' or 'interactive'.
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* ```ts
|
|
683
|
+
* await Spectra.browser.shouldBeLoaded();
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
shouldBeLoaded(options?: AssertionOptions): Promise<void>;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Asserts that no severe or unhandled JavaScript errors occurred in the browser console.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```ts
|
|
693
|
+
* await Spectra.browser.shouldHaveNoConsoleErrors();
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
shouldHaveNoConsoleErrors(options?: AssertionOptions): Promise<void>;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Clears all browser cookies for the active domain.
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```ts
|
|
703
|
+
* await Spectra.browser.clearCookies();
|
|
704
|
+
* ```
|
|
705
|
+
*/
|
|
706
|
+
clearCookies(): Promise<void>;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Applies one or more raw `Set-Cookie` header values — exactly as received from a `fetch()`
|
|
710
|
+
* response, e.g. `response.headers.getSetCookie()` — to the browser's cookie jar. Operates at
|
|
711
|
+
* the CDP `Network` domain level rather than through `document.cookie`, so `HttpOnly` cookies
|
|
712
|
+
* are fully supported (set, not just read-blocked). Useful for seeding an authenticated session
|
|
713
|
+
* by logging in via a direct API call instead of driving the real login UI — see
|
|
714
|
+
* `docs/v2/features/authentication-and-session-seeding.md`.
|
|
715
|
+
*
|
|
716
|
+
* `url` is required to resolve `Domain`/`Path`/`Secure` defaults for any `Set-Cookie` value that
|
|
717
|
+
* doesn't specify them explicitly (an omitted `Domain` defaults to the issuing request's own
|
|
718
|
+
* host, per RFC 6265) — pass the URL the response actually came from.
|
|
719
|
+
*
|
|
720
|
+
* Web only — Android has no browser/cookie-jar concept; see the docs above for the mobile
|
|
721
|
+
* equivalent (deep-link-triggered, Keystore-backed session seeding).
|
|
722
|
+
*
|
|
723
|
+
* @example
|
|
724
|
+
* ```ts
|
|
725
|
+
* const res = await fetch('https://api.example.com/auth/login', { method: 'POST', body: ... });
|
|
726
|
+
* await Spectra.browser.setCookies(res.headers.getSetCookie(), res.url);
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
setCookies(setCookieHeaders: string | string[], url: string): Promise<void>;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Clears all key-value entries in browser `localStorage`.
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```ts
|
|
736
|
+
* await Spectra.browser.clearLocalStorage();
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
clearLocalStorage(): Promise<void>;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Native proxy interface for interacting with a single DOM / UI element.
|
|
744
|
+
*/
|
|
745
|
+
export interface SingleElementProxy extends ElementReceiverAssertions<Promise<void>> {
|
|
746
|
+
/** Target CSS or XPath selector string for this element. */
|
|
747
|
+
selector: string;
|
|
748
|
+
|
|
749
|
+
/** Positional index when matched from a collection (or null for standalone selectors). */
|
|
750
|
+
index: number | null;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Finds `childSelector` scoped to this element's subtree, mirroring Playwright's locator
|
|
754
|
+
* chaining (`parent.locator(child)`) instead of a separate `within()`/`findWithin()` verb.
|
|
755
|
+
* Resolution is a real DOM descendant query on web; on Android (no ancestor API) it's a
|
|
756
|
+
* bounds-containment heuristic over the flat accessibility-tree dump.
|
|
757
|
+
*
|
|
758
|
+
* @example
|
|
759
|
+
* ```ts
|
|
760
|
+
* const modal = Spectra.get('#modal');
|
|
761
|
+
* await modal.get('#save-btn').click();
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
get(childSelector: string, index?: number | null): SingleElementProxy;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Finds all elements matching `childSelector` scoped to this element's subtree — the
|
|
768
|
+
* collection equivalent of `get()`.
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* await Spectra.get('#modal').getAll('.list-item').shouldHaveLength(3);
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
getAll(childSelector: string): CollectionProxy;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Waits until the element exists in the DOM within the specified timeout.
|
|
779
|
+
*
|
|
780
|
+
* @param timeoutMs Timeout in milliseconds (default: 5000ms).
|
|
781
|
+
*/
|
|
782
|
+
waitForElement(timeoutMs?: number): Promise<boolean>;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Clicks on the element.
|
|
786
|
+
*
|
|
787
|
+
* @param options Optional click interaction options.
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* await Spectra.get('#submit-btn').click();
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
click(options?: ClickOptions): Promise<void>;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Performs a double-click interaction on the element.
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```ts
|
|
800
|
+
* await Spectra.get('.editable-cell').doubleClick();
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
doubleClick(): Promise<void>;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Performs a context-click (right-click) on the element.
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
* ```ts
|
|
810
|
+
* await Spectra.get('.file-item').rightClick();
|
|
811
|
+
* ```
|
|
812
|
+
*/
|
|
813
|
+
rightClick(): Promise<void>;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Sets or replaces the value of a form input element.
|
|
817
|
+
*
|
|
818
|
+
* @param value Text value to set.
|
|
819
|
+
* @example
|
|
820
|
+
* ```ts
|
|
821
|
+
* await Spectra.get('#username').setValue('admin');
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
setValue(value: unknown): Promise<void>;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Types text keystrokes into the element, optionally clearing existing content first.
|
|
828
|
+
*
|
|
829
|
+
* @param value Text string to type.
|
|
830
|
+
* @param options Optional type options (e.g. `{ clearFirst: true }`).
|
|
831
|
+
* @example
|
|
832
|
+
* ```ts
|
|
833
|
+
* await LoginPage.emailInput.type('admin@testspectra.dev', { clearFirst: true });
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
type(value: unknown, options?: TypeOptions): Promise<void>;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Clears the current text value from an input or textarea element.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* await Spectra.get('#search-bar').clearValue();
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
846
|
+
clearValue(): Promise<void>;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Clears the current text value from an input or textarea element (alias to `clearValue()`).
|
|
850
|
+
*
|
|
851
|
+
* @example
|
|
852
|
+
* ```ts
|
|
853
|
+
* await Spectra.get('#search-bar').clear();
|
|
854
|
+
* ```
|
|
855
|
+
*/
|
|
856
|
+
clear(): Promise<void>;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Selects an option in a `<select>` element by its visible text or value.
|
|
860
|
+
*
|
|
861
|
+
* @param option Visible text or value of the option to select.
|
|
862
|
+
* @example
|
|
863
|
+
* ```ts
|
|
864
|
+
* await Spectra.get('#country-dropdown').select('Indonesia');
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
select(option: string): Promise<void>;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Selects an option in a `<select>` dropdown by its visible text.
|
|
871
|
+
*
|
|
872
|
+
* @param text Visible text label of the option.
|
|
873
|
+
*/
|
|
874
|
+
selectByVisibleText(text: string): Promise<void>;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Hovers the mouse cursor over the center of the element.
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```ts
|
|
881
|
+
* await Spectra.get('.dropdown-trigger').hover();
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
hover(): Promise<void>;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Focuses the target element (triggers focus event and active document focus).
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```ts
|
|
891
|
+
* await Spectra.get('#email-input').focus();
|
|
892
|
+
* ```
|
|
893
|
+
*/
|
|
894
|
+
focus(): Promise<void>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Moves the mouse cursor to the element (alias to `hover()`).
|
|
898
|
+
*/
|
|
899
|
+
moveTo(): Promise<void>;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Drags this element and drops it onto the target element destination.
|
|
903
|
+
*
|
|
904
|
+
* @param target Destination element target selector or proxy.
|
|
905
|
+
* @example
|
|
906
|
+
* ```ts
|
|
907
|
+
* await Spectra.get('#drag-source').dragDrop('#drop-zone');
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
dragDrop(target: ElementTarget): Promise<void>;
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Drags this element and drops it onto the target element destination (alias to `dragDrop()`).
|
|
914
|
+
*/
|
|
915
|
+
dragAndDrop(target: ElementTarget): Promise<void>;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Scrolls the page until this element is aligned into the visible viewport.
|
|
919
|
+
*
|
|
920
|
+
* @example
|
|
921
|
+
* ```ts
|
|
922
|
+
* await Spectra.get('#footer-links').scrollIntoView();
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
scrollIntoView(): Promise<void>;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Long-presses on the element for touch/mobile gestures.
|
|
929
|
+
*
|
|
930
|
+
* @param options Long-press duration in milliseconds or configuration object.
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* await Spectra.get('.draggable-card').longPress({ duration: 1500 });
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
longPress(options?: number | LongPressOptions): Promise<void>;
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Waits until the element is displayed and visible in the viewport.
|
|
940
|
+
*
|
|
941
|
+
* @param opts Optional timeout configuration object.
|
|
942
|
+
*/
|
|
943
|
+
waitForDisplayed(opts?: { timeout?: number }): Promise<boolean>;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Returns the inner text content of the element.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* const headingText = await Spectra.get('h1').getText();
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
getText(): Promise<string>;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Returns the current `value` property of an input or textarea element.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```ts
|
|
960
|
+
* const query = await Spectra.get('input#search').getValue();
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
getValue(): Promise<string>;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Returns true if the element is currently visible and rendered in the DOM.
|
|
967
|
+
*/
|
|
968
|
+
isDisplayed(): Promise<boolean>;
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Returns true if the element is currently visible (alias to `isDisplayed()`).
|
|
972
|
+
*/
|
|
973
|
+
isVisible(): Promise<boolean>;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Returns true if the element exists in the DOM.
|
|
977
|
+
*/
|
|
978
|
+
isExisting(): Promise<boolean>;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Returns true if the element is enabled (not disabled).
|
|
982
|
+
*/
|
|
983
|
+
isEnabled(): Promise<boolean>;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Returns true if the checkbox, radio, or `<option>` is selected.
|
|
987
|
+
*/
|
|
988
|
+
isSelected(): Promise<boolean>;
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Returns true if the checkbox or radio button is checked.
|
|
992
|
+
*/
|
|
993
|
+
isChecked(): Promise<boolean>;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Returns true if the element is the active focused element in document.
|
|
997
|
+
*/
|
|
998
|
+
isFocused(): Promise<boolean>;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Retrieves the value of a specified HTML attribute from the element.
|
|
1002
|
+
*
|
|
1003
|
+
* @param name Attribute name (e.g. 'href', 'src', 'data-id').
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* const linkUrl = await Spectra.get('a#download').getAttribute('href');
|
|
1007
|
+
* ```
|
|
1008
|
+
*/
|
|
1009
|
+
getAttribute(name: string): Promise<string | null>;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Retrieves the computed CSS property value of the element.
|
|
1013
|
+
*
|
|
1014
|
+
* @param name CSS property name (e.g. 'background-color', 'font-size').
|
|
1015
|
+
* @example
|
|
1016
|
+
* ```ts
|
|
1017
|
+
* const color = await Spectra.get('.btn-primary').getCSSProperty('background-color');
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
getCSSProperty(name: string): Promise<{ value: string }>;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* TestSpectra native element interface alias.
|
|
1025
|
+
*/
|
|
1026
|
+
export type SpectraElement = SingleElementProxy;
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Native proxy interface for interacting with multiple matching elements in a collection.
|
|
1030
|
+
*/
|
|
1031
|
+
export interface CollectionProxy extends CollectionReceiverAssertions<Promise<void>> {
|
|
1032
|
+
/** Target CSS or XPath selector string for this collection. */
|
|
1033
|
+
selector: string;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Returns the total count of elements matching this collection selector.
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* ```ts
|
|
1040
|
+
* const totalRows = await Spectra.getAll('.table-row').count();
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
count(): Promise<number>;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Total count of elements matching this collection selector (Promise).
|
|
1047
|
+
*/
|
|
1048
|
+
readonly length: Promise<number>;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Returns a `SingleElementProxy` pointing to the first matching element in the collection (index 0).
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```ts
|
|
1055
|
+
* await Spectra.getAll('.list-item').first().click();
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
first(): SingleElementProxy;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Returns a `SingleElementProxy` pointing to the last matching element in the collection.
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* ```ts
|
|
1065
|
+
* await Spectra.getAll('.list-item').last().click();
|
|
1066
|
+
* ```
|
|
1067
|
+
*/
|
|
1068
|
+
last(): SingleElementProxy;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Returns a `SingleElementProxy` pointing to the matching element at the specified zero-based index.
|
|
1072
|
+
*
|
|
1073
|
+
* When this collection itself came from a `.getAll()` chain, `first()`/`last()`/`nth()` carry
|
|
1074
|
+
* that scope forward instead of reverting to an unscoped lookup — e.g. the button below is
|
|
1075
|
+
* resolved within the 3rd `.card`, not just anywhere on the page:
|
|
1076
|
+
*
|
|
1077
|
+
* @param index Zero-based index of the target element.
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```ts
|
|
1080
|
+
* await Spectra.getAll('.list-item').nth(2).click();
|
|
1081
|
+
* await Spectra.getAll('.card').nth(2).get('.buy-btn').click();
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
nth(index: number): SingleElementProxy;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* TestSpectra native collection interface alias.
|
|
1089
|
+
*/
|
|
1090
|
+
export type SpectraCollection = CollectionProxy;
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Native browser bridge interface for page navigation, execution, and network interception.
|
|
1094
|
+
*/
|
|
1095
|
+
export interface SpectraBrowserBridge extends BrowserReceiverAssertions {
|
|
1096
|
+
/**
|
|
1097
|
+
* All network requests recorded so far this session — both genuine (non-intercepted) traffic
|
|
1098
|
+
* and requests an active `intercept()` mock fulfilled. Recording is always on; nothing needs
|
|
1099
|
+
* to be explicitly enabled first. On Android, only requests routed through the worker's local
|
|
1100
|
+
* mock proxy are recorded (see `Spectra.intercept`'s docs on why mobile needs an absolute URL
|
|
1101
|
+
* rather than a relative path) — a request the app makes that never reaches the proxy at all
|
|
1102
|
+
* won't appear here.
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```ts
|
|
1106
|
+
* await Spectra.get('~fetch-api-btn').click();
|
|
1107
|
+
* const entry = Spectra.browser.recordedNetwork.find((e) => e.url.includes('/posts'));
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
recordedNetwork: CDPNetworkEntry[];
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Retrieves the current browser URL.
|
|
1114
|
+
*
|
|
1115
|
+
* @example
|
|
1116
|
+
* ```ts
|
|
1117
|
+
* const currentUrl = await Spectra.browser.getUrl();
|
|
1118
|
+
* ```
|
|
1119
|
+
*/
|
|
1120
|
+
getUrl(): Promise<string>;
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Retrieves the current page title.
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```ts
|
|
1127
|
+
* const title = await Spectra.browser.getTitle();
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
getTitle(): Promise<string>;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Executes a JavaScript function or script snippet in the browser context and returns the result.
|
|
1134
|
+
*
|
|
1135
|
+
* @param fn Function or script string to execute.
|
|
1136
|
+
* @param args Arguments to pass into the function.
|
|
1137
|
+
* @example
|
|
1138
|
+
* ```ts
|
|
1139
|
+
* const docWidth = await Spectra.browser.execute(() => document.body.clientWidth);
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
execute<R = unknown>(fn: ((...args: unknown[]) => R) | string, ...args: unknown[]): Promise<R>;
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Evaluates a JavaScript expression string in the browser context.
|
|
1146
|
+
*
|
|
1147
|
+
* @param expr JavaScript expression string.
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* const isReady = await Spectra.browser.evaluate('document.readyState === "complete"');
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
evaluate<R = unknown>(expr: string): Promise<R>;
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Repeatedly polls a condition function until it returns true or times out.
|
|
1157
|
+
*
|
|
1158
|
+
* @param fn Condition function returning a boolean or boolean promise.
|
|
1159
|
+
* @param opts Optional timeout and message options.
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```ts
|
|
1162
|
+
* await Spectra.browser.waitUntil(async () => (await Spectra.get('#status').getText()) === 'Ready', {
|
|
1163
|
+
* timeout: 5000,
|
|
1164
|
+
* timeoutMsg: 'Status never reached Ready',
|
|
1165
|
+
* });
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
waitUntil(fn: () => Promise<boolean> | boolean, opts?: { timeout?: number; timeoutMsg?: string }): Promise<boolean>;
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Retrieves captured browser console log entries.
|
|
1172
|
+
*
|
|
1173
|
+
* @param type Optional log type filter (e.g. 'browser', 'error').
|
|
1174
|
+
*/
|
|
1175
|
+
getLogs(type?: string): Promise<Array<{ level: string; message: string }>>;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Intercepted HTTP request metadata captured during test execution.
|
|
1180
|
+
*/
|
|
1181
|
+
export interface InterceptedRequest {
|
|
1182
|
+
/** Optional unique identifier for the request */
|
|
1183
|
+
id?: string;
|
|
1184
|
+
/** Target request URL */
|
|
1185
|
+
url: string;
|
|
1186
|
+
/** HTTP method */
|
|
1187
|
+
method: string;
|
|
1188
|
+
/** Request headers */
|
|
1189
|
+
headers?: Record<string, string>;
|
|
1190
|
+
/** Request body / payload if available */
|
|
1191
|
+
postData?: string;
|
|
1192
|
+
/** Timestamp when intercepted */
|
|
1193
|
+
timestamp: number;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* Queued one-time mock response item for FIFO polling and retry flows.
|
|
1198
|
+
*/
|
|
1199
|
+
export interface QueuedMockResponse {
|
|
1200
|
+
response: unknown;
|
|
1201
|
+
statusCode: number;
|
|
1202
|
+
headers?: Record<string, string>;
|
|
1203
|
+
/** Milliseconds to wait before fulfilling this response — simulates a late/slow network reply. */
|
|
1204
|
+
delayMs?: number;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Mock rule configuration for CDP & Mobile network request interception.
|
|
1209
|
+
*/
|
|
1210
|
+
export interface MockRule {
|
|
1211
|
+
/** URL pattern or substring to match. */
|
|
1212
|
+
pattern: string;
|
|
1213
|
+
/** HTTP method (e.g. GET, POST, ALL). */
|
|
1214
|
+
method: string;
|
|
1215
|
+
/** Mock response payload. */
|
|
1216
|
+
response: unknown;
|
|
1217
|
+
/** HTTP status code (e.g. 200, 404). */
|
|
1218
|
+
statusCode: number;
|
|
1219
|
+
/** Custom HTTP response headers. */
|
|
1220
|
+
headers?: Record<string, string>;
|
|
1221
|
+
/** Milliseconds to wait before fulfilling the default response — simulates a late/slow reply. */
|
|
1222
|
+
delayMs?: number;
|
|
1223
|
+
/** Total times this mock rule matched and intercepted requests. */
|
|
1224
|
+
callCount: number;
|
|
1225
|
+
/** FIFO queue of one-time responses (respondOnce) */
|
|
1226
|
+
respondOnceQueue: QueuedMockResponse[];
|
|
1227
|
+
/** Whether requests matching this rule should be aborted / failed */
|
|
1228
|
+
aborted?: boolean;
|
|
1229
|
+
/** Specific error code for network abort simulation */
|
|
1230
|
+
abortReason?: 'Failed' | 'Aborted' | 'TimedOut' | 'ConnectionReset';
|
|
1231
|
+
/** Recorded list of intercepted requests matching this rule */
|
|
1232
|
+
calls: InterceptedRequest[];
|
|
1233
|
+
/** Internal pending waitForCall resolvers (keyed by expected call count). */
|
|
1234
|
+
waitResolvers: Array<{ count: number; resolve: (req: InterceptedRequest) => void }>;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Handle returned by `Spectra.intercept()` to dynamically inspect and update mock responses.
|
|
1239
|
+
*/
|
|
1240
|
+
export interface MockInterceptHandle {
|
|
1241
|
+
/**
|
|
1242
|
+
* Dynamically updates the default response payload for this active mock rule.
|
|
1243
|
+
*
|
|
1244
|
+
* @param newFixture New response payload object or string.
|
|
1245
|
+
* @param newOptions Optional status code and header overrides.
|
|
1246
|
+
*/
|
|
1247
|
+
respondWith: (
|
|
1248
|
+
newFixture: unknown,
|
|
1249
|
+
newOptions?: { statusCode?: number; headers?: Record<string, string>; delayMs?: number },
|
|
1250
|
+
) => Promise<void>;
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Queues a one-time mock response for the next matching request (FIFO queue for polling/retries).
|
|
1254
|
+
*
|
|
1255
|
+
* @param newFixture One-time response payload object or string.
|
|
1256
|
+
* @param newOptions Optional status code and header overrides.
|
|
1257
|
+
*/
|
|
1258
|
+
respondOnce: (
|
|
1259
|
+
newFixture: unknown,
|
|
1260
|
+
newOptions?: { statusCode?: number; headers?: Record<string, string>; delayMs?: number },
|
|
1261
|
+
) => Promise<void>;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Simulates a network failure or connection abort for matching requests.
|
|
1265
|
+
*
|
|
1266
|
+
* @param errorCode Network failure reason (default: 'Failed').
|
|
1267
|
+
*/
|
|
1268
|
+
abort: (errorCode?: 'Failed' | 'Aborted' | 'TimedOut' | 'ConnectionReset') => Promise<void>;
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Awaits until the mock rule has intercepted at least `count` matching requests.
|
|
1272
|
+
*
|
|
1273
|
+
* @param options Timeout and expected request count.
|
|
1274
|
+
*/
|
|
1275
|
+
waitForCall: (options?: { timeout?: number; count?: number }) => Promise<InterceptedRequest>;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns the number of times this mock intercepted network requests.
|
|
1279
|
+
*/
|
|
1280
|
+
callCount: (() => number) & number;
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Historical array of all intercepted requests matching this rule.
|
|
1284
|
+
*/
|
|
1285
|
+
calls: InterceptedRequest[];
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Audit log entry for captured CDP network requests.
|
|
1290
|
+
*/
|
|
1291
|
+
export interface CDPNetworkEntry {
|
|
1292
|
+
/** Unique CDP request ID. */
|
|
1293
|
+
requestId: string;
|
|
1294
|
+
/** Target request URL. */
|
|
1295
|
+
url: string;
|
|
1296
|
+
/** HTTP request method. */
|
|
1297
|
+
method: string;
|
|
1298
|
+
/** Resource type (e.g. 'Fetch', 'XHR', 'Document', 'Stylesheet'). */
|
|
1299
|
+
type: string;
|
|
1300
|
+
/** HTTP response status code. */
|
|
1301
|
+
status: number;
|
|
1302
|
+
/** HTTP response status message. */
|
|
1303
|
+
statusText: string;
|
|
1304
|
+
/** Host domain name. */
|
|
1305
|
+
domain: string;
|
|
1306
|
+
/** Protocol name (e.g. 'h2', 'http/1.1'). */
|
|
1307
|
+
protocol: string;
|
|
1308
|
+
/** Request timing metrics in milliseconds. */
|
|
1309
|
+
timing: { waiting: number; download: number };
|
|
1310
|
+
/** Content body size in bytes. */
|
|
1311
|
+
size: number;
|
|
1312
|
+
/** Wire transfer size in bytes. */
|
|
1313
|
+
transferSize: number;
|
|
1314
|
+
/** Start timestamp epoch. */
|
|
1315
|
+
startTime: number;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Main TestSpectra cross-platform automation and assertion interface contract.
|
|
1320
|
+
*/
|
|
1321
|
+
export interface SpectraStatic {
|
|
1322
|
+
/**
|
|
1323
|
+
* Locates a single DOM / UI element proxy by selector or target reference.
|
|
1324
|
+
*
|
|
1325
|
+
* @param target CSS selector string, XPath string, or element proxy.
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* const submitBtn = Spectra.get('#btn-submit');
|
|
1329
|
+
* await submitBtn.click();
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
get(target: ElementTarget): SingleElementProxy;
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Locates a collection proxy of multiple matching DOM / UI elements by selector.
|
|
1336
|
+
*
|
|
1337
|
+
* @param selector CSS or XPath selector matching multiple elements.
|
|
1338
|
+
* @example
|
|
1339
|
+
* ```ts
|
|
1340
|
+
* const rows = Spectra.getAll('table tr');
|
|
1341
|
+
* await rows.shouldHaveLength(5);
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
getAll(selector: string): CollectionProxy;
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Navigates the active browser window to the specified URL. On Android, deep-links directly
|
|
1348
|
+
* into the app via `adb shell am start` instead — pass a full URI matching a scheme the app
|
|
1349
|
+
* registers (e.g. `expo-router`'s `scheme` in `app.json`), not a bare path, since there's no
|
|
1350
|
+
* configured base scheme to combine one against.
|
|
1351
|
+
*
|
|
1352
|
+
* @param url Absolute or relative URL on web; a full deep-link URI on Android.
|
|
1353
|
+
* @example
|
|
1354
|
+
* ```ts
|
|
1355
|
+
* await Spectra.navigate('/dashboard'); // web
|
|
1356
|
+
* await Spectra.navigate('testspectra-demo://permission-rationale'); // Android
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
1359
|
+
navigate(url: string): Promise<void>;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Navigates one step backward in browser history.
|
|
1363
|
+
*
|
|
1364
|
+
* @example
|
|
1365
|
+
* ```ts
|
|
1366
|
+
* await Spectra.back();
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
back(): Promise<void>;
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Navigates one step forward in browser history.
|
|
1373
|
+
*
|
|
1374
|
+
* @example
|
|
1375
|
+
* ```ts
|
|
1376
|
+
* await Spectra.forward();
|
|
1377
|
+
* ```
|
|
1378
|
+
*/
|
|
1379
|
+
forward(): Promise<void>;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Reloads / refreshes the current active page.
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```ts
|
|
1386
|
+
* await Spectra.refresh();
|
|
1387
|
+
* ```
|
|
1388
|
+
*/
|
|
1389
|
+
refresh(): Promise<void>;
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* Sets the browser viewport dimensions (width and height in pixels).
|
|
1393
|
+
*
|
|
1394
|
+
* @param width Viewport width in pixels.
|
|
1395
|
+
* @param height Viewport height in pixels.
|
|
1396
|
+
* @example
|
|
1397
|
+
* ```ts
|
|
1398
|
+
* await Spectra.setViewport(1920, 1080);
|
|
1399
|
+
* ```
|
|
1400
|
+
*/
|
|
1401
|
+
setViewport(width: number, height: number): Promise<void>;
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* Clicks on the specified element target.
|
|
1405
|
+
*
|
|
1406
|
+
* @param target Element selector string, Page Object element, or proxy.
|
|
1407
|
+
* @param textOrOptions Optional text filter or click options.
|
|
1408
|
+
* @example
|
|
1409
|
+
* ```ts
|
|
1410
|
+
* await Spectra.click('#submit-btn');
|
|
1411
|
+
* await Spectra.click(LoginPage.submitButton);
|
|
1412
|
+
* ```
|
|
1413
|
+
*/
|
|
1414
|
+
click(target: ElementTarget, textOrOptions?: string | ClickOptions): Promise<void>;
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Performs a double-click interaction on the specified element target.
|
|
1418
|
+
*
|
|
1419
|
+
* @param target Target element selector or proxy.
|
|
1420
|
+
* @example
|
|
1421
|
+
* ```ts
|
|
1422
|
+
* await Spectra.doubleClick('.grid-cell');
|
|
1423
|
+
* ```
|
|
1424
|
+
*/
|
|
1425
|
+
doubleClick(target: ElementTarget): Promise<void>;
|
|
1426
|
+
|
|
1427
|
+
/**
|
|
1428
|
+
* Performs a context-click (right-click) interaction on the specified element target.
|
|
1429
|
+
*
|
|
1430
|
+
* @param target Target element selector or proxy.
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* await Spectra.rightClick('#context-menu-area');
|
|
1434
|
+
* ```
|
|
1435
|
+
*/
|
|
1436
|
+
rightClick(target: ElementTarget): Promise<void>;
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Types text keystrokes into the specified element target.
|
|
1440
|
+
*
|
|
1441
|
+
* @param target Target input or textarea element selector or proxy.
|
|
1442
|
+
* @param text String content to type.
|
|
1443
|
+
* @param options Optional typing configuration (e.g. `{ clearFirst: true }`).
|
|
1444
|
+
* @example
|
|
1445
|
+
* ```ts
|
|
1446
|
+
* await Spectra.type('#username', 'john_doe', { clearFirst: true });
|
|
1447
|
+
* ```
|
|
1448
|
+
*/
|
|
1449
|
+
type(target: ElementTarget, text: string, options?: TypeOptions): Promise<void>;
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* Clears the current text value from an input or textarea element.
|
|
1453
|
+
*
|
|
1454
|
+
* @param target Target element selector or proxy.
|
|
1455
|
+
* @example
|
|
1456
|
+
* ```ts
|
|
1457
|
+
* await Spectra.clear('#search-input');
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
clear(target: ElementTarget): Promise<void>;
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Selects an option in a `<select>` dropdown by its visible text or value.
|
|
1464
|
+
*
|
|
1465
|
+
* @param target Target select element selector or proxy.
|
|
1466
|
+
* @param option Visible text label or value of the option.
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```ts
|
|
1469
|
+
* await Spectra.select('#country-dropdown', 'United States');
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
select(target: ElementTarget, option: string): Promise<void>;
|
|
1473
|
+
|
|
1474
|
+
/**
|
|
1475
|
+
* Hovers the mouse cursor over the specified element target.
|
|
1476
|
+
*
|
|
1477
|
+
* @param target Target element selector or proxy.
|
|
1478
|
+
* @example
|
|
1479
|
+
* ```ts
|
|
1480
|
+
* await Spectra.hover('.profile-menu-trigger');
|
|
1481
|
+
* ```
|
|
1482
|
+
*/
|
|
1483
|
+
hover(target: ElementTarget): Promise<void>;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* Focuses the target element (triggers focus event and active document focus).
|
|
1487
|
+
*
|
|
1488
|
+
* @param target Target element selector or proxy.
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```ts
|
|
1491
|
+
* await Spectra.focus('#email-input');
|
|
1492
|
+
* ```
|
|
1493
|
+
*/
|
|
1494
|
+
focus(target: ElementTarget): Promise<void>;
|
|
1495
|
+
|
|
1496
|
+
/**
|
|
1497
|
+
* Drags a source element and drops it onto a destination element target.
|
|
1498
|
+
*
|
|
1499
|
+
* @param source Draggable source element selector or proxy.
|
|
1500
|
+
* @param destination Drop zone destination element selector or proxy.
|
|
1501
|
+
* @example
|
|
1502
|
+
* ```ts
|
|
1503
|
+
* await Spectra.dragDrop('#item-1', '#kanban-column-done');
|
|
1504
|
+
* ```
|
|
1505
|
+
*/
|
|
1506
|
+
dragDrop(source: ElementTarget, destination: ElementTarget): Promise<void>;
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Scrolls the page until the specified element is aligned into the visible viewport.
|
|
1510
|
+
*
|
|
1511
|
+
* @param target Target element selector or proxy.
|
|
1512
|
+
* @example
|
|
1513
|
+
* ```ts
|
|
1514
|
+
* await Spectra.scrollIntoView('#footer-contact');
|
|
1515
|
+
* ```
|
|
1516
|
+
*/
|
|
1517
|
+
scrollIntoView(target: ElementTarget): Promise<void>;
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Performs a directional scroll on the page.
|
|
1521
|
+
*
|
|
1522
|
+
* @param options Scroll options (direction, pixel distance, or target selector).
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```ts
|
|
1525
|
+
* await Spectra.scroll({ direction: 'down', pixels: 400 });
|
|
1526
|
+
* ```
|
|
1527
|
+
*/
|
|
1528
|
+
scroll(options?: ScrollOptions): Promise<void>;
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Performs a directional touch swipe gesture (mobile & web).
|
|
1532
|
+
*
|
|
1533
|
+
* @param options Swipe options (direction, distance in pixels, anchor selector).
|
|
1534
|
+
* @example
|
|
1535
|
+
* ```ts
|
|
1536
|
+
* await Spectra.swipe({ direction: 'left', distance: 300 });
|
|
1537
|
+
* ```
|
|
1538
|
+
*/
|
|
1539
|
+
swipe(options: SwipeOptions): Promise<void>;
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Performs a long-press touch gesture on the target element.
|
|
1543
|
+
*
|
|
1544
|
+
* @param target Target element selector or proxy.
|
|
1545
|
+
* @param options Long-press duration in milliseconds or configuration object.
|
|
1546
|
+
* @example
|
|
1547
|
+
* ```ts
|
|
1548
|
+
* await Spectra.longPress('#sortable-item', { duration: 1500 });
|
|
1549
|
+
* ```
|
|
1550
|
+
*/
|
|
1551
|
+
longPress(target: ElementTarget, options?: LongPressOptions | number): Promise<void>;
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* Presses a specific keyboard key into the active document element.
|
|
1555
|
+
*
|
|
1556
|
+
* @param key Key name to press (e.g. 'Enter', 'Tab', 'Escape', 'Backspace').
|
|
1557
|
+
* @example
|
|
1558
|
+
* ```ts
|
|
1559
|
+
* await Spectra.pressKey('Enter');
|
|
1560
|
+
* ```
|
|
1561
|
+
*/
|
|
1562
|
+
pressKey(key: KeyOption | string): Promise<void>;
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Grants an Android runtime permission on demand — typically called right after confirming an
|
|
1566
|
+
* in-app rationale dialog, so a test can exercise its own permission-request UX instead of
|
|
1567
|
+
* having every permission pre-granted before the app even launches. No-op on platforms without
|
|
1568
|
+
* an OS-level runtime permission model (e.g. web).
|
|
1569
|
+
*
|
|
1570
|
+
* @param name Fully-qualified Android permission name (e.g. 'android.permission.CAMERA').
|
|
1571
|
+
* @example
|
|
1572
|
+
* ```ts
|
|
1573
|
+
* await Spectra.get('~rationale-allow-btn').click();
|
|
1574
|
+
* await Spectra.grantPermission('android.permission.CAMERA');
|
|
1575
|
+
* ```
|
|
1576
|
+
*/
|
|
1577
|
+
grantPermission(name: string): Promise<void>;
|
|
1578
|
+
|
|
1579
|
+
/**
|
|
1580
|
+
* Pauses test execution for the specified number of milliseconds.
|
|
1581
|
+
*
|
|
1582
|
+
* @param ms Milliseconds to wait.
|
|
1583
|
+
* @example
|
|
1584
|
+
* ```ts
|
|
1585
|
+
* await Spectra.wait(1000);
|
|
1586
|
+
* ```
|
|
1587
|
+
*/
|
|
1588
|
+
wait(ms: number): Promise<void>;
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Waits for the specified element to appear and exist in the DOM.
|
|
1592
|
+
*
|
|
1593
|
+
* @param target Target element selector or proxy.
|
|
1594
|
+
* @param timeoutMs Maximum time to wait in milliseconds (default: 5000ms).
|
|
1595
|
+
* @example
|
|
1596
|
+
* ```ts
|
|
1597
|
+
* await Spectra.waitForElement('#dynamic-content', 10000);
|
|
1598
|
+
* ```
|
|
1599
|
+
*/
|
|
1600
|
+
waitForElement(target: ElementTarget, timeoutMs?: number): Promise<void>;
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* Direct access to browser context commands and page assertions.
|
|
1604
|
+
*/
|
|
1605
|
+
browser: SpectraBrowserBridge;
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Typed environment variables from `spectra.config.ts`'s `executionConfig.environmentVariables`.
|
|
1609
|
+
* Each configured key is generated into `.testspectra/types/env.d.ts` as a `SpectraEnv` member
|
|
1610
|
+
* (TypeScript interface merging), so `Spectra.env.MY_KEY` resolves to `string` — never
|
|
1611
|
+
* `string | undefined` like raw `process.env.MY_KEY` would.
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
* ```ts
|
|
1615
|
+
* const mode = Spectra.env.API_MODE;
|
|
1616
|
+
* ```
|
|
1617
|
+
*/
|
|
1618
|
+
env: SpectraEnv;
|
|
1619
|
+
|
|
1620
|
+
/**
|
|
1621
|
+
* Intercepts and mocks HTTP network requests matching the specified pattern or options.
|
|
1622
|
+
*
|
|
1623
|
+
* @param patternOrOptions URL pattern string or structured intercept configuration object.
|
|
1624
|
+
* @param method HTTP method (GET, POST, etc.) when pattern string is used.
|
|
1625
|
+
* @param fixture Mock response payload.
|
|
1626
|
+
* @param options Additional response options (status code, custom headers).
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```ts
|
|
1629
|
+
* const mock = await Spectra.intercept('/api/v1/profile', 'GET', { name: 'Admin', role: 'root' });
|
|
1630
|
+
* ```
|
|
1631
|
+
*/
|
|
1632
|
+
intercept(
|
|
1633
|
+
patternOrOptions: string | { url: string; method?: string; response?: unknown },
|
|
1634
|
+
method?: string,
|
|
1635
|
+
fixture?: unknown,
|
|
1636
|
+
options?: { statusCode?: number; headers?: Record<string, string>; delayMs?: number },
|
|
1637
|
+
): Promise<MockInterceptHandle>;
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Clears and resets all active CDP network interception rules.
|
|
1641
|
+
*
|
|
1642
|
+
* @example
|
|
1643
|
+
* ```ts
|
|
1644
|
+
* Spectra.clearMocks();
|
|
1645
|
+
* ```
|
|
1646
|
+
*/
|
|
1647
|
+
clearMocks(): void;
|
|
1648
|
+
}
|