@testspectra/matchers 1.0.70 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -3,49 +3,66 @@
3
3
  * @see backend/src/models/test_step.rs
4
4
  */
5
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";
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
22
 
23
23
  /**
24
24
  * Canonical assertion keys supported across TestSpectra runner and database models.
25
25
  * @see backend/src/models/test_step.rs
26
26
  */
27
27
  export type AssertionKey =
28
- | "elementDisplayed"
29
- | "elementNotDisplayed"
30
- | "elementExists"
31
- | "elementEnabled"
32
- | "elementDisabled"
33
- | "textContains"
34
- | "textEquals"
35
- | "textNotContains"
36
- | "urlContains"
37
- | "urlEquals"
38
- | "valueEquals"
39
- | "valueContains"
40
- | "attributeEquals"
41
- | "attributeContains"
42
- | "hasClass"
43
- | "hasAttribute"
44
- | "isSelected"
45
- | "elementCount"
46
- | "elementCountGreaterThan"
47
- | "pageLoaded"
48
- | "noErrors";
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';
49
66
 
50
67
  /**
51
68
  * Supported keyboard key names for `Spectra.pressKey(key)`.
@@ -57,26 +74,26 @@ export type AssertionKey =
57
74
  * ```
58
75
  */
59
76
  export type KeyOption =
60
- | "Enter"
61
- | "Tab"
62
- | "Escape"
63
- | "Backspace"
64
- | "Delete"
65
- | "ArrowUp"
66
- | "ArrowDown"
67
- | "ArrowLeft"
68
- | "ArrowRight"
69
- | "Space";
77
+ | 'Enter'
78
+ | 'Tab'
79
+ | 'Escape'
80
+ | 'Backspace'
81
+ | 'Delete'
82
+ | 'ArrowUp'
83
+ | 'ArrowDown'
84
+ | 'ArrowLeft'
85
+ | 'ArrowRight'
86
+ | 'Space';
70
87
 
71
88
  /**
72
89
  * Cardinal directions for gestures such as swipe and scroll.
73
90
  */
74
- export type Direction = "up" | "down" | "left" | "right";
91
+ export type Direction = 'up' | 'down' | 'left' | 'right';
75
92
 
76
93
  /**
77
94
  * Target reference for locating an element.
78
- * Can be a CSS/XPath selector string, a resolved `WebdriverIO.Element`,
79
- * or a chainable element promise `ChainablePromiseElement`.
95
+ * Can be a CSS/XPath selector string, a resolved `SpectraElement` proxy,
96
+ * or a chainable element promise `Promise<SpectraElement>`.
80
97
  *
81
98
  * @example
82
99
  * ```ts
@@ -87,7 +104,7 @@ export type Direction = "up" | "down" | "left" | "right";
87
104
  * Spectra.get(LoginPage.submitButton);
88
105
  * ```
89
106
  */
90
- export type ElementTarget = string | WebdriverIO.Element | ChainablePromiseElement;
107
+ export type ElementTarget = string | SingleElementProxy | Promise<SingleElementProxy>;
91
108
 
92
109
  /**
93
110
  * Configuration options for scroll actions.
@@ -146,7 +163,7 @@ export interface ClickOptions {
146
163
  /** Optional inner text filter */
147
164
  text?: string;
148
165
  /** Click type: standard single click or double click */
149
- clickType?: "single" | "double";
166
+ clickType?: 'single' | 'double';
150
167
  }
151
168
 
152
169
  /**
@@ -163,52 +180,1342 @@ export interface TypeOptions {
163
180
  }
164
181
 
165
182
  /**
166
- * Fluent assertion matcher strings for single element verification.
167
- * Used in `Spectra.get(target).should(matcher, ...args)`.
168
- *
169
- * @example
170
- * ```ts
171
- * await Spectra.get("#username").should("be.visible");
172
- * await Spectra.get("#greeting").should("have.text", "Welcome back");
173
- * await Spectra.get("#status").should("have.class", "active");
174
- * ```
183
+ * Canonical assertion matcher keys for single element verification.
184
+ * Dispatched internally by semantic receiver methods (`.shouldBeVisible()`, `.shouldHaveText()`, etc.).
175
185
  */
176
186
  export type SingleElementMatcher =
177
- | "be.visible"
178
- | "not.be.visible"
179
- | "exist"
180
- | "not.exist"
181
- | "be.enabled"
182
- | "be.disabled"
183
- | "be.checked"
184
- | "not.be.checked"
185
- | "be.selected"
186
- | "not.be.selected"
187
- | "have.value"
188
- | "contain.value"
189
- | "have.text"
190
- | "contain.text"
191
- | "have.class"
192
- | "have.attr"
193
- | "have.url"
194
- | "contain.url"
195
- | "have.title"
196
- | "contain.title";
197
-
198
- /**
199
- * Fluent assertion matcher strings for multi-element collections.
200
- * Used in `Spectra.getAll(selector).should(matcher, ...args)`.
201
- *
202
- * @example
203
- * ```ts
204
- * await Spectra.getAll(".product-item").should("have.length", 4);
205
- * await Spectra.getAll(".product-item").should("have.length.greaterThan", 0);
206
- * await Spectra.getAll(".badge").should("not.be.empty");
207
- * ```
187
+ | 'be.visible'
188
+ | 'not.be.visible'
189
+ | 'exist'
190
+ | 'not.exist'
191
+ | 'be.clickable'
192
+ | 'not.be.clickable'
193
+ | 'be.enabled'
194
+ | 'be.disabled'
195
+ | 'be.checked'
196
+ | 'not.be.checked'
197
+ | 'be.selected'
198
+ | 'not.be.selected'
199
+ | 'be.focused'
200
+ | 'not.be.focused'
201
+ | 'have.value'
202
+ | 'not.have.value'
203
+ | 'contain.value'
204
+ | 'not.contain.value'
205
+ | 'have.text'
206
+ | 'not.have.text'
207
+ | 'contain.text'
208
+ | 'not.contain.text'
209
+ | 'have.class'
210
+ | 'not.have.class'
211
+ | 'have.attr'
212
+ | 'not.have.attr'
213
+ | 'have.css'
214
+ | 'not.have.css'
215
+ | 'have.url'
216
+ | 'contain.url'
217
+ | 'have.title'
218
+ | 'contain.title';
219
+
220
+ /**
221
+ * Canonical assertion matcher keys for multi-element collections.
222
+ * Dispatched internally by semantic collection methods (`.shouldHaveLength()`, `.shouldBeEmpty()`, etc.).
208
223
  */
209
224
  export type MultiElementMatcher =
210
- | "have.length"
211
- | "have.length.greaterThan"
212
- | "be.empty"
213
- | "exist";
225
+ | 'have.length'
226
+ | 'not.have.length'
227
+ | 'have.length.greaterThan'
228
+ | 'have.length.lessThan'
229
+ | 'be.empty'
230
+ | 'not.be.empty'
231
+ | 'exist';
232
+
233
+ /**
234
+ * Receiver-oriented element assertion methods.
235
+ * Attached directly to SingleElementProxy instances.
236
+ */
237
+ export interface ElementReceiverAssertions<TReturn = Promise<void>> {
238
+ /**
239
+ * Asserts that the target element is visible and displayed on the page.
240
+ *
241
+ * @example
242
+ * ```ts
243
+ * await Spectra.get('#submit-btn').shouldBeVisible();
244
+ * await LoginPage.submitButton.shouldBeVisible();
245
+ * ```
246
+ */
247
+ shouldBeVisible(): TReturn;
248
+
249
+ /**
250
+ * Asserts that the target element is hidden, detached, or not displayed on the page.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * await Spectra.get('.loading-spinner').shouldNotBeVisible();
255
+ * ```
256
+ */
257
+ shouldNotBeVisible(): TReturn;
258
+
259
+ /**
260
+ * Asserts that the target element exists in the DOM.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * await Spectra.get('#cookie-consent-modal').shouldExist();
265
+ * ```
266
+ */
267
+ shouldExist(): TReturn;
268
+
269
+ /**
270
+ * Asserts that the target element does not exist in the DOM.
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * await Spectra.get('#deleted-record-row').shouldNotExist();
275
+ * ```
276
+ */
277
+ shouldNotExist(): TReturn;
278
+
279
+ /**
280
+ * Asserts that the target element is visible, enabled, and clickable.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * await Spectra.get('button[type="submit"]').shouldBeClickable();
285
+ * ```
286
+ */
287
+ shouldBeClickable(): TReturn;
288
+
289
+ /**
290
+ * Asserts that the target element is disabled, covered, or not clickable.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * await Spectra.get('button.disabled-action').shouldNotBeClickable();
295
+ * ```
296
+ */
297
+ shouldNotBeClickable(): TReturn;
298
+
299
+ /**
300
+ * Asserts that the target form input/button is enabled (not disabled).
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * await Spectra.get('#username-field').shouldBeEnabled();
305
+ * ```
306
+ */
307
+ shouldBeEnabled(): TReturn;
308
+
309
+ /**
310
+ * Asserts that the target form input/button has the disabled state/attribute.
311
+ *
312
+ * @example
313
+ * ```ts
314
+ * await Spectra.get('#submit-order-btn').shouldBeDisabled();
315
+ * ```
316
+ */
317
+ shouldBeDisabled(): TReturn;
318
+
319
+ /**
320
+ * Asserts that the target checkbox or radio input is checked/selected.
321
+ *
322
+ * @example
323
+ * ```ts
324
+ * await Spectra.get('#terms-checkbox').shouldBeChecked();
325
+ * ```
326
+ */
327
+ shouldBeChecked(): TReturn;
328
+
329
+ /**
330
+ * Asserts that the target checkbox or radio input is unchecked/deselected.
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * await Spectra.get('#subscribe-newsletter').shouldNotBeChecked();
335
+ * ```
336
+ */
337
+ shouldNotBeChecked(): TReturn;
338
+
339
+ /**
340
+ * Asserts that the target element currently holds active document focus.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * await Spectra.get('#search-input').shouldBeFocused();
345
+ * ```
346
+ */
347
+ shouldBeFocused(): TReturn;
348
+
349
+ /**
350
+ * Asserts that the target element does not hold active document focus.
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * await Spectra.get('#blur-input').shouldNotBeFocused();
355
+ * ```
356
+ */
357
+ shouldNotBeFocused(): TReturn;
358
+
359
+ /**
360
+ * Asserts that the target element's text content matches the expected string or regular expression.
361
+ *
362
+ * @param expected Exact string or RegExp pattern to match against element text.
363
+ * @example
364
+ * ```ts
365
+ * await Spectra.get('h1.page-title').shouldHaveText('Dashboard Overview');
366
+ * await Spectra.get('.badge').shouldHaveText(/Active|Pending/);
367
+ * ```
368
+ */
369
+ shouldHaveText(expected: string | RegExp): TReturn;
370
+
371
+ /**
372
+ * Asserts that the target element's text content does not match the expected string or regular expression.
373
+ *
374
+ * @param expected String or RegExp pattern that the element text must NOT match.
375
+ * @example
376
+ * ```ts
377
+ * await Spectra.get('.status-label').shouldNotHaveText('Error');
378
+ * ```
379
+ */
380
+ shouldNotHaveText(expected: string | RegExp): TReturn;
381
+
382
+ /**
383
+ * Asserts that the target element's text content contains the specified substring.
384
+ *
385
+ * @param substring Substring expected to be present within the element text.
386
+ * @example
387
+ * ```ts
388
+ * await Spectra.get('.toast-message').shouldContainText('Successfully saved');
389
+ * ```
390
+ */
391
+ shouldContainText(substring: string): TReturn;
392
+
393
+ /**
394
+ * Asserts that the target element's text content does not contain the specified substring.
395
+ *
396
+ * @param substring Substring that must NOT be present within the element text.
397
+ * @example
398
+ * ```ts
399
+ * await Spectra.get('.log-output').shouldNotContainText('Fatal Exception');
400
+ * ```
401
+ */
402
+ shouldNotContainText(substring: string): TReturn;
403
+
404
+ /**
405
+ * Asserts that the form input or textarea element's value exactly equals the specified string.
406
+ *
407
+ * @param value Expected input field value.
408
+ * @example
409
+ * ```ts
410
+ * await Spectra.get('input[name="email"]').shouldHaveValue('admin@testspectra.dev');
411
+ * ```
412
+ */
413
+ shouldHaveValue(value: string): TReturn;
414
+
415
+ /**
416
+ * Asserts that the form input or textarea element's value does not equal the specified string.
417
+ *
418
+ * @param value Value that the input field must NOT equal.
419
+ * @example
420
+ * ```ts
421
+ * await Spectra.get('input[name="role"]').shouldNotHaveValue('guest');
422
+ * ```
423
+ */
424
+ shouldNotHaveValue(value: string): TReturn;
425
+
426
+ /**
427
+ * Asserts that the form input or textarea element's value contains the specified substring.
428
+ *
429
+ * @param substring Substring expected to be contained within the input value.
430
+ * @example
431
+ * ```ts
432
+ * await Spectra.get('input[name="email"]').shouldContainValue('@testspectra.dev');
433
+ * ```
434
+ */
435
+ shouldContainValue(substring: string): TReturn;
436
+
437
+ /**
438
+ * Asserts that the form input or textarea element's value does not contain the specified substring.
439
+ *
440
+ * @param substring Substring that must NOT be contained within the input value.
441
+ * @example
442
+ * ```ts
443
+ * await Spectra.get('input[name="url"]').shouldNotContainValue('http://');
444
+ * ```
445
+ */
446
+ shouldNotContainValue(substring: string): TReturn;
447
+
448
+ /**
449
+ * Asserts that the element has the specified attribute, and optionally that its value matches.
450
+ *
451
+ * @param name Attribute name to inspect.
452
+ * @param value Optional expected attribute value string.
453
+ * @example
454
+ * ```ts
455
+ * await Spectra.get('a.external-link').shouldHaveAttribute('target', '_blank');
456
+ * await Spectra.get('input.required-field').shouldHaveAttribute('required');
457
+ * ```
458
+ */
459
+ shouldHaveAttribute(name: string, value?: string): TReturn;
460
+
461
+ /**
462
+ * Asserts that the element does not have the specified attribute.
463
+ *
464
+ * @param name Attribute name that must NOT exist on the element.
465
+ * @example
466
+ * ```ts
467
+ * await Spectra.get('button#action-btn').shouldNotHaveAttribute('disabled');
468
+ * ```
469
+ */
470
+ shouldNotHaveAttribute(name: string): TReturn;
471
+
472
+ /**
473
+ * Asserts that the element contains the specified CSS class name.
474
+ *
475
+ * @param className CSS class name expected in the element's classList.
476
+ * @example
477
+ * ```ts
478
+ * await Spectra.get('.nav-tab').shouldHaveClass('active');
479
+ * ```
480
+ */
481
+ shouldHaveClass(className: string): TReturn;
482
+
483
+ /**
484
+ * Asserts that the element does not contain the specified CSS class name.
485
+ *
486
+ * @param className CSS class name that must NOT be in the element's classList.
487
+ * @example
488
+ * ```ts
489
+ * await Spectra.get('.modal-backdrop').shouldNotHaveClass('hidden');
490
+ * ```
491
+ */
492
+ shouldNotHaveClass(className: string): TReturn;
493
+
494
+ /**
495
+ * Asserts that the computed CSS style property of the element equals the specified value.
496
+ *
497
+ * @param property CSS style property name (e.g. 'color', 'display', 'opacity').
498
+ * @param value Expected computed CSS property value.
499
+ * @example
500
+ * ```ts
501
+ * await Spectra.get('.badge-success').shouldHaveCss('color', 'rgb(0, 128, 0)');
502
+ * ```
503
+ */
504
+ shouldHaveCss(property: string, value: string): TReturn;
505
+
506
+ /**
507
+ * Asserts that the computed CSS style property of the element does not equal the specified value.
508
+ *
509
+ * @param property CSS style property name.
510
+ * @param value Value that the computed CSS property must NOT equal.
511
+ * @example
512
+ * ```ts
513
+ * await Spectra.get('.main-content').shouldNotHaveCss('display', 'none');
514
+ * ```
515
+ */
516
+ shouldNotHaveCss(property: string, value: string): TReturn;
517
+ }
518
+
519
+ /**
520
+ * Receiver-oriented collection assertion methods.
521
+ * Attached directly to CollectionProxy and collection prototypes.
522
+ */
523
+ export interface CollectionReceiverAssertions<TReturn = Promise<void>> {
524
+ /**
525
+ * Asserts that the collection contains exactly the specified number of matching elements.
526
+ *
527
+ * @param count Expected exact count of elements.
528
+ * @example
529
+ * ```ts
530
+ * await Spectra.getAll('.user-table-row').shouldHaveLength(10);
531
+ * ```
532
+ */
533
+ shouldHaveLength(count: number): TReturn;
534
+
535
+ /**
536
+ * Asserts that the collection does not contain the specified number of matching elements.
537
+ *
538
+ * @param count Count that the element collection must NOT equal.
539
+ * @example
540
+ * ```ts
541
+ * await Spectra.getAll('.error-item').shouldNotHaveLength(0);
542
+ * ```
543
+ */
544
+ shouldNotHaveLength(count: number): TReturn;
545
+
546
+ /**
547
+ * Asserts that the collection contains strictly more than `min` matching elements.
548
+ *
549
+ * @param min Minimum threshold (exclusive).
550
+ * @example
551
+ * ```ts
552
+ * await Spectra.getAll('.search-result-card').shouldHaveLengthGreaterThan(0);
553
+ * ```
554
+ */
555
+ shouldHaveLengthGreaterThan(min: number): TReturn;
556
+
557
+ /**
558
+ * Asserts that the collection contains strictly fewer than `max` matching elements.
559
+ *
560
+ * @param max Maximum threshold (exclusive).
561
+ * @example
562
+ * ```ts
563
+ * await Spectra.getAll('.warning-banner').shouldHaveLengthLessThan(5);
564
+ * ```
565
+ */
566
+ shouldHaveLengthLessThan(max: number): TReturn;
567
+
568
+ /**
569
+ * Asserts that the collection contains zero matching elements.
570
+ *
571
+ * @example
572
+ * ```ts
573
+ * await Spectra.getAll('.unread-notification-badge').shouldBeEmpty();
574
+ * ```
575
+ */
576
+ shouldBeEmpty(): TReturn;
577
+
578
+ /**
579
+ * Asserts that the collection contains at least one matching element.
580
+ *
581
+ * @example
582
+ * ```ts
583
+ * await Spectra.getAll('.product-card').shouldNotBeEmpty();
584
+ * ```
585
+ */
586
+ shouldNotBeEmpty(): TReturn;
587
+ }
588
+
589
+ /**
590
+ * Browser-level context assertion methods.
591
+ * Hosted on Spectra.browser and the global browser object.
592
+ */
593
+ export interface BrowserReceiverAssertions {
594
+ /**
595
+ * Asserts that current browser URL exactly matches the expected URL.
596
+ *
597
+ * @param expectedUrl Full expected URL string.
598
+ * @example
599
+ * ```ts
600
+ * await Spectra.browser.shouldHaveUrl('https://app.testspectra.dev/dashboard');
601
+ * ```
602
+ */
603
+ shouldHaveUrl(expectedUrl: string): Promise<void>;
604
+
605
+ /**
606
+ * Asserts that current browser URL contains the specified substring.
607
+ *
608
+ * @param expectedSubstr Substring expected in browser URL.
609
+ * @example
610
+ * ```ts
611
+ * await Spectra.browser.shouldContainUrl('/dashboard');
612
+ * ```
613
+ */
614
+ shouldContainUrl(expectedSubstr: string): Promise<void>;
615
+
616
+ /**
617
+ * Asserts that current page title exactly matches the expected title.
618
+ *
619
+ * @param expectedTitle Full expected page title string.
620
+ * @example
621
+ * ```ts
622
+ * await Spectra.browser.shouldHaveTitle('Dashboard - TestSpectra');
623
+ * ```
624
+ */
625
+ shouldHaveTitle(expectedTitle: string): Promise<void>;
626
+
627
+ /**
628
+ * Asserts that current page title contains the specified substring.
629
+ *
630
+ * @param expectedSubstr Substring expected in page title.
631
+ * @example
632
+ * ```ts
633
+ * await Spectra.browser.shouldContainTitle('Dashboard');
634
+ * ```
635
+ */
636
+ shouldContainTitle(expectedSubstr: string): Promise<void>;
637
+
638
+ /**
639
+ * Asserts that the browser document `readyState` is 'complete' or 'interactive'.
640
+ *
641
+ * @example
642
+ * ```ts
643
+ * await Spectra.browser.shouldBeLoaded();
644
+ * ```
645
+ */
646
+ shouldBeLoaded(): Promise<void>;
647
+
648
+ /**
649
+ * Asserts that no severe or unhandled JavaScript errors occurred in the browser console.
650
+ *
651
+ * @example
652
+ * ```ts
653
+ * await Spectra.browser.shouldHaveNoConsoleErrors();
654
+ * ```
655
+ */
656
+ shouldHaveNoConsoleErrors(): Promise<void>;
657
+
658
+ /**
659
+ * Clears all browser cookies for the active domain.
660
+ *
661
+ * @example
662
+ * ```ts
663
+ * await Spectra.browser.clearCookies();
664
+ * ```
665
+ */
666
+ clearCookies(): Promise<void>;
667
+
668
+ /**
669
+ * Clears all key-value entries in browser `localStorage`.
670
+ *
671
+ * @example
672
+ * ```ts
673
+ * await Spectra.browser.clearLocalStorage();
674
+ * ```
675
+ */
676
+ clearLocalStorage(): Promise<void>;
677
+ }
678
+
679
+ /**
680
+ * Native proxy interface for interacting with a single DOM / UI element.
681
+ */
682
+ export interface SingleElementProxy extends ElementReceiverAssertions<Promise<void>> {
683
+ /** Target CSS or XPath selector string for this element. */
684
+ selector: string;
685
+
686
+ /** Positional index when matched from a collection (or null for standalone selectors). */
687
+ index: number | null;
688
+
689
+ /**
690
+ * Waits until the element exists in the DOM within the specified timeout.
691
+ *
692
+ * @param timeoutMs Timeout in milliseconds (default: 5000ms).
693
+ */
694
+ waitForElement(timeoutMs?: number): Promise<boolean>;
695
+
696
+ /**
697
+ * Clicks on the element.
698
+ *
699
+ * @param options Optional click interaction options.
700
+ * @example
701
+ * ```ts
702
+ * await Spectra.get('#submit-btn').click();
703
+ * ```
704
+ */
705
+ click(options?: ClickOptions): Promise<void>;
706
+
707
+ /**
708
+ * Performs a double-click interaction on the element.
709
+ *
710
+ * @example
711
+ * ```ts
712
+ * await Spectra.get('.editable-cell').doubleClick();
713
+ * ```
714
+ */
715
+ doubleClick(): Promise<void>;
716
+
717
+ /**
718
+ * Performs a context-click (right-click) on the element.
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * await Spectra.get('.file-item').rightClick();
723
+ * ```
724
+ */
725
+ rightClick(): Promise<void>;
726
+
727
+ /**
728
+ * Sets or replaces the value of a form input element.
729
+ *
730
+ * @param value Text value to set.
731
+ * @example
732
+ * ```ts
733
+ * await Spectra.get('#username').setValue('admin');
734
+ * ```
735
+ */
736
+ setValue(value: unknown): Promise<void>;
737
+
738
+ /**
739
+ * Types text keystrokes into the element, optionally clearing existing content first.
740
+ *
741
+ * @param value Text string to type.
742
+ * @param options Optional type options (e.g. `{ clearFirst: true }`).
743
+ * @example
744
+ * ```ts
745
+ * await LoginPage.emailInput.type('admin@testspectra.dev', { clearFirst: true });
746
+ * ```
747
+ */
748
+ type(value: unknown, options?: TypeOptions): Promise<void>;
749
+
750
+ /**
751
+ * Clears the current text value from an input or textarea element.
752
+ *
753
+ * @example
754
+ * ```ts
755
+ * await Spectra.get('#search-bar').clearValue();
756
+ * ```
757
+ */
758
+ clearValue(): Promise<void>;
759
+
760
+ /**
761
+ * Clears the current text value from an input or textarea element (alias to `clearValue()`).
762
+ *
763
+ * @example
764
+ * ```ts
765
+ * await Spectra.get('#search-bar').clear();
766
+ * ```
767
+ */
768
+ clear(): Promise<void>;
769
+
770
+ /**
771
+ * Selects an option in a `<select>` element by its visible text or value.
772
+ *
773
+ * @param option Visible text or value of the option to select.
774
+ * @example
775
+ * ```ts
776
+ * await Spectra.get('#country-dropdown').select('Indonesia');
777
+ * ```
778
+ */
779
+ select(option: string): Promise<void>;
780
+
781
+ /**
782
+ * Selects an option in a `<select>` dropdown by its visible text.
783
+ *
784
+ * @param text Visible text label of the option.
785
+ */
786
+ selectByVisibleText(text: string): Promise<void>;
787
+
788
+ /**
789
+ * Hovers the mouse cursor over the center of the element.
790
+ *
791
+ * @example
792
+ * ```ts
793
+ * await Spectra.get('.dropdown-trigger').hover();
794
+ * ```
795
+ */
796
+ hover(): Promise<void>;
797
+
798
+ /**
799
+ * Focuses the target element (triggers focus event and active document focus).
800
+ *
801
+ * @example
802
+ * ```ts
803
+ * await Spectra.get('#email-input').focus();
804
+ * ```
805
+ */
806
+ focus(): Promise<void>;
807
+
808
+ /**
809
+ * Moves the mouse cursor to the element (alias to `hover()`).
810
+ */
811
+ moveTo(): Promise<void>;
812
+
813
+ /**
814
+ * Drags this element and drops it onto the target element destination.
815
+ *
816
+ * @param target Destination element target selector or proxy.
817
+ * @example
818
+ * ```ts
819
+ * await Spectra.get('#drag-source').dragDrop('#drop-zone');
820
+ * ```
821
+ */
822
+ dragDrop(target: ElementTarget): Promise<void>;
823
+
824
+ /**
825
+ * Drags this element and drops it onto the target element destination (alias to `dragDrop()`).
826
+ */
827
+ dragAndDrop(target: ElementTarget): Promise<void>;
828
+
829
+ /**
830
+ * Scrolls the page until this element is aligned into the visible viewport.
831
+ *
832
+ * @example
833
+ * ```ts
834
+ * await Spectra.get('#footer-links').scrollIntoView();
835
+ * ```
836
+ */
837
+ scrollIntoView(): Promise<void>;
838
+
839
+ /**
840
+ * Long-presses on the element for touch/mobile gestures.
841
+ *
842
+ * @param options Long-press duration in milliseconds or configuration object.
843
+ * @example
844
+ * ```ts
845
+ * await Spectra.get('.draggable-card').longPress({ duration: 1500 });
846
+ * ```
847
+ */
848
+ longPress(options?: number | LongPressOptions): Promise<void>;
849
+
850
+ /**
851
+ * Waits until the element is displayed and visible in the viewport.
852
+ *
853
+ * @param opts Optional timeout configuration object.
854
+ */
855
+ waitForDisplayed(opts?: { timeout?: number }): Promise<boolean>;
856
+
857
+ /**
858
+ * Returns the inner text content of the element.
859
+ *
860
+ * @example
861
+ * ```ts
862
+ * const headingText = await Spectra.get('h1').getText();
863
+ * ```
864
+ */
865
+ getText(): Promise<string>;
866
+
867
+ /**
868
+ * Returns the current `value` property of an input or textarea element.
869
+ *
870
+ * @example
871
+ * ```ts
872
+ * const query = await Spectra.get('input#search').getValue();
873
+ * ```
874
+ */
875
+ getValue(): Promise<string>;
214
876
 
877
+ /**
878
+ * Returns true if the element is currently visible and rendered in the DOM.
879
+ */
880
+ isDisplayed(): Promise<boolean>;
881
+
882
+ /**
883
+ * Returns true if the element is currently visible (alias to `isDisplayed()`).
884
+ */
885
+ isVisible(): Promise<boolean>;
886
+
887
+ /**
888
+ * Returns true if the element exists in the DOM.
889
+ */
890
+ isExisting(): Promise<boolean>;
891
+
892
+ /**
893
+ * Returns true if the element is enabled (not disabled).
894
+ */
895
+ isEnabled(): Promise<boolean>;
896
+
897
+ /**
898
+ * Returns true if the checkbox, radio, or `<option>` is selected.
899
+ */
900
+ isSelected(): Promise<boolean>;
901
+
902
+ /**
903
+ * Returns true if the checkbox or radio button is checked.
904
+ */
905
+ isChecked(): Promise<boolean>;
906
+
907
+ /**
908
+ * Returns true if the element is the active focused element in document.
909
+ */
910
+ isFocused(): Promise<boolean>;
911
+
912
+ /**
913
+ * Retrieves the value of a specified HTML attribute from the element.
914
+ *
915
+ * @param name Attribute name (e.g. 'href', 'src', 'data-id').
916
+ * @example
917
+ * ```ts
918
+ * const linkUrl = await Spectra.get('a#download').getAttribute('href');
919
+ * ```
920
+ */
921
+ getAttribute(name: string): Promise<string | null>;
922
+
923
+ /**
924
+ * Retrieves the computed CSS property value of the element.
925
+ *
926
+ * @param name CSS property name (e.g. 'background-color', 'font-size').
927
+ * @example
928
+ * ```ts
929
+ * const color = await Spectra.get('.btn-primary').getCSSProperty('background-color');
930
+ * ```
931
+ */
932
+ getCSSProperty(name: string): Promise<{ value: string }>;
933
+ }
934
+
935
+ /**
936
+ * TestSpectra native element interface alias.
937
+ */
938
+ export type SpectraElement = SingleElementProxy;
939
+
940
+ /**
941
+ * Native proxy interface for interacting with multiple matching elements in a collection.
942
+ */
943
+ export interface CollectionProxy extends CollectionReceiverAssertions<Promise<void>> {
944
+ /** Target CSS or XPath selector string for this collection. */
945
+ selector: string;
946
+
947
+ /**
948
+ * Returns the total count of elements matching this collection selector.
949
+ *
950
+ * @example
951
+ * ```ts
952
+ * const totalRows = await Spectra.getAll('.table-row').count();
953
+ * ```
954
+ */
955
+ count(): Promise<number>;
956
+
957
+ /**
958
+ * Total count of elements matching this collection selector (Promise).
959
+ */
960
+ readonly length: Promise<number>;
961
+
962
+ /**
963
+ * Returns a `SingleElementProxy` pointing to the first matching element in the collection (index 0).
964
+ *
965
+ * @example
966
+ * ```ts
967
+ * await Spectra.getAll('.list-item').first().click();
968
+ * ```
969
+ */
970
+ first(): SingleElementProxy;
971
+
972
+ /**
973
+ * Returns a `SingleElementProxy` pointing to the last matching element in the collection.
974
+ *
975
+ * @example
976
+ * ```ts
977
+ * await Spectra.getAll('.list-item').last().click();
978
+ * ```
979
+ */
980
+ last(): SingleElementProxy;
981
+
982
+ /**
983
+ * Returns a `SingleElementProxy` pointing to the matching element at the specified zero-based index.
984
+ *
985
+ * @param index Zero-based index of the target element.
986
+ * @example
987
+ * ```ts
988
+ * await Spectra.getAll('.list-item').nth(2).click();
989
+ * ```
990
+ */
991
+ nth(index: number): SingleElementProxy;
992
+ }
993
+
994
+ /**
995
+ * TestSpectra native collection interface alias.
996
+ */
997
+ export type SpectraCollection = CollectionProxy;
998
+
999
+ /**
1000
+ * Native browser bridge interface for page navigation, execution, and network interception.
1001
+ */
1002
+ export interface SpectraBrowserBridge extends BrowserReceiverAssertions {
1003
+ /**
1004
+ * Navigates the browser to the specified absolute or relative URL.
1005
+ *
1006
+ * @param targetUrl Target destination URL.
1007
+ * @example
1008
+ * ```ts
1009
+ * await Spectra.browser.url('/auth/login');
1010
+ * ```
1011
+ */
1012
+ url(targetUrl: string): Promise<void>;
1013
+
1014
+ /**
1015
+ * Retrieves the current browser URL.
1016
+ *
1017
+ * @example
1018
+ * ```ts
1019
+ * const currentUrl = await Spectra.browser.getUrl();
1020
+ * ```
1021
+ */
1022
+ getUrl(): Promise<string>;
1023
+
1024
+ /**
1025
+ * Retrieves the current page title.
1026
+ *
1027
+ * @example
1028
+ * ```ts
1029
+ * const title = await Spectra.browser.getTitle();
1030
+ * ```
1031
+ */
1032
+ getTitle(): Promise<string>;
1033
+
1034
+ /**
1035
+ * Navigates one step back in the browser history.
1036
+ *
1037
+ * @example
1038
+ * ```ts
1039
+ * await Spectra.browser.back();
1040
+ * ```
1041
+ */
1042
+ back(): Promise<void>;
1043
+
1044
+ /**
1045
+ * Navigates one step forward in the browser history.
1046
+ *
1047
+ * @example
1048
+ * ```ts
1049
+ * await Spectra.browser.forward();
1050
+ * ```
1051
+ */
1052
+ forward(): Promise<void>;
1053
+
1054
+ /**
1055
+ * Reloads / refreshes the current active page.
1056
+ *
1057
+ * @example
1058
+ * ```ts
1059
+ * await Spectra.browser.refresh();
1060
+ * ```
1061
+ */
1062
+ refresh(): Promise<void>;
1063
+
1064
+ /**
1065
+ * Pauses test execution for the specified number of milliseconds.
1066
+ *
1067
+ * @param ms Duration in milliseconds to pause.
1068
+ * @example
1069
+ * ```ts
1070
+ * await Spectra.browser.pause(1000);
1071
+ * ```
1072
+ */
1073
+ pause(ms: number): Promise<void>;
1074
+
1075
+ /**
1076
+ * Sets the browser viewport dimensions (width and height in pixels).
1077
+ *
1078
+ * @param width Viewport width in pixels.
1079
+ * @param height Viewport height in pixels.
1080
+ * @example
1081
+ * ```ts
1082
+ * await Spectra.browser.setViewport(1920, 1080);
1083
+ * ```
1084
+ */
1085
+ setViewport(width: number, height: number): Promise<void>;
1086
+
1087
+ /**
1088
+ * Executes a JavaScript function or script snippet in the browser context and returns the result.
1089
+ *
1090
+ * @param fn Function or script string to execute.
1091
+ * @param args Arguments to pass into the function.
1092
+ * @example
1093
+ * ```ts
1094
+ * const docWidth = await Spectra.browser.execute(() => document.body.clientWidth);
1095
+ * ```
1096
+ */
1097
+ execute<R = unknown>(fn: ((...args: unknown[]) => R) | string, ...args: unknown[]): Promise<R>;
1098
+
1099
+ /**
1100
+ * Evaluates a JavaScript expression string in the browser context.
1101
+ *
1102
+ * @param expr JavaScript expression string.
1103
+ * @example
1104
+ * ```ts
1105
+ * const isReady = await Spectra.browser.evaluate('document.readyState === "complete"');
1106
+ * ```
1107
+ */
1108
+ evaluate<R = unknown>(expr: string): Promise<R>;
1109
+
1110
+ /**
1111
+ * Repeatedly polls a condition function until it returns true or times out.
1112
+ *
1113
+ * @param fn Condition function returning a boolean or boolean promise.
1114
+ * @param opts Optional timeout and message options.
1115
+ * @example
1116
+ * ```ts
1117
+ * await Spectra.browser.waitUntil(async () => (await Spectra.get('#status').getText()) === 'Ready', {
1118
+ * timeout: 5000,
1119
+ * timeoutMsg: 'Status never reached Ready',
1120
+ * });
1121
+ * ```
1122
+ */
1123
+ waitUntil(fn: () => Promise<boolean> | boolean, opts?: { timeout?: number; timeoutMsg?: string }): Promise<boolean>;
1124
+
1125
+ /**
1126
+ * Retrieves captured browser console log entries.
1127
+ *
1128
+ * @param type Optional log type filter (e.g. 'browser', 'error').
1129
+ */
1130
+ getLogs(type?: string): Promise<Array<{ level: string; message: string }>>;
1131
+
1132
+ /**
1133
+ * Intercepts and mocks HTTP network requests matching the specified URL pattern.
1134
+ *
1135
+ * @param pattern URL substring or glob pattern to intercept.
1136
+ * @param method HTTP method (GET, POST, PUT, DELETE, etc.).
1137
+ * @param fixture Mock response payload object or string.
1138
+ * @param options Mock response options (status code, custom headers).
1139
+ * @example
1140
+ * ```ts
1141
+ * const mock = await Spectra.browser.intercept('/api/v1/users', 'GET', [{ id: 1, name: 'Alice' }], {
1142
+ * statusCode: 200,
1143
+ * });
1144
+ * ```
1145
+ */
1146
+ intercept(
1147
+ pattern: string,
1148
+ method?: string,
1149
+ fixture?: unknown,
1150
+ options?: { statusCode?: number; headers?: Record<string, string> },
1151
+ ): Promise<MockInterceptHandle>;
1152
+ }
1153
+
1154
+ /**
1155
+ * Mock rule configuration for CDP network request interception.
1156
+ */
1157
+ export interface MockRule {
1158
+ /** URL pattern or substring to match. */
1159
+ pattern: string;
1160
+ /** HTTP method (e.g. GET, POST). */
1161
+ method: string;
1162
+ /** Mock response payload. */
1163
+ response: unknown;
1164
+ /** HTTP status code (e.g. 200, 404). */
1165
+ statusCode: number;
1166
+ /** Custom HTTP response headers. */
1167
+ headers?: Record<string, string>;
1168
+ /** Total times this mock rule matched and intercepted requests. */
1169
+ callCount: number;
1170
+ }
1171
+
1172
+ /**
1173
+ * Handle returned by `Spectra.intercept()` to dynamically inspect and update mock responses.
1174
+ */
1175
+ export interface MockInterceptHandle {
1176
+ /**
1177
+ * Dynamically updates the response payload for this active mock rule.
1178
+ *
1179
+ * @param newFixture New response payload object or string.
1180
+ * @param newOptions Optional status code and header overrides.
1181
+ */
1182
+ respondWith: (
1183
+ newFixture: unknown,
1184
+ newOptions?: { statusCode?: number; headers?: Record<string, string> },
1185
+ ) => Promise<void>;
1186
+
1187
+ /**
1188
+ * Returns the number of times this mock intercepted network requests.
1189
+ */
1190
+ callCount: () => number;
1191
+ }
1192
+
1193
+ /**
1194
+ * Audit log entry for captured CDP network requests.
1195
+ */
1196
+ export interface CDPNetworkEntry {
1197
+ /** Unique CDP request ID. */
1198
+ requestId: string;
1199
+ /** Target request URL. */
1200
+ url: string;
1201
+ /** HTTP request method. */
1202
+ method: string;
1203
+ /** Resource type (e.g. 'Fetch', 'XHR', 'Document', 'Stylesheet'). */
1204
+ type: string;
1205
+ /** HTTP response status code. */
1206
+ status: number;
1207
+ /** HTTP response status message. */
1208
+ statusText: string;
1209
+ /** Host domain name. */
1210
+ domain: string;
1211
+ /** Protocol name (e.g. 'h2', 'http/1.1'). */
1212
+ protocol: string;
1213
+ /** Request timing metrics in milliseconds. */
1214
+ timing: { waiting: number; download: number };
1215
+ /** Content body size in bytes. */
1216
+ size: number;
1217
+ /** Wire transfer size in bytes. */
1218
+ transferSize: number;
1219
+ /** Start timestamp epoch. */
1220
+ startTime: number;
1221
+ }
1222
+
1223
+ /**
1224
+ * Main TestSpectra cross-platform automation and assertion interface contract.
1225
+ */
1226
+ export interface SpectraStatic {
1227
+ /**
1228
+ * Locates a single DOM / UI element proxy by selector or target reference.
1229
+ *
1230
+ * @param target CSS selector string, XPath string, or element proxy.
1231
+ * @example
1232
+ * ```ts
1233
+ * const submitBtn = Spectra.get('#btn-submit');
1234
+ * await submitBtn.click();
1235
+ * ```
1236
+ */
1237
+ get(target: ElementTarget): SingleElementProxy;
1238
+
1239
+ /**
1240
+ * Locates a collection proxy of multiple matching DOM / UI elements by selector.
1241
+ *
1242
+ * @param selector CSS or XPath selector matching multiple elements.
1243
+ * @example
1244
+ * ```ts
1245
+ * const rows = Spectra.getAll('table tr');
1246
+ * await rows.shouldHaveLength(5);
1247
+ * ```
1248
+ */
1249
+ getAll(selector: string): CollectionProxy;
1250
+
1251
+ /**
1252
+ * Navigates the active browser window or mobile webview to the specified URL.
1253
+ *
1254
+ * @param url Absolute or relative URL destination.
1255
+ * @example
1256
+ * ```ts
1257
+ * await Spectra.navigate('/dashboard');
1258
+ * ```
1259
+ */
1260
+ navigate(url: string): Promise<void>;
1261
+
1262
+ /**
1263
+ * Navigates one step backward in browser history.
1264
+ *
1265
+ * @example
1266
+ * ```ts
1267
+ * await Spectra.back();
1268
+ * ```
1269
+ */
1270
+ back(): Promise<void>;
1271
+
1272
+ /**
1273
+ * Navigates one step forward in browser history.
1274
+ *
1275
+ * @example
1276
+ * ```ts
1277
+ * await Spectra.forward();
1278
+ * ```
1279
+ */
1280
+ forward(): Promise<void>;
1281
+
1282
+ /**
1283
+ * Reloads / refreshes the current active page.
1284
+ *
1285
+ * @example
1286
+ * ```ts
1287
+ * await Spectra.refresh();
1288
+ * ```
1289
+ */
1290
+ refresh(): Promise<void>;
1291
+
1292
+ /**
1293
+ * Sets the browser viewport dimensions (width and height in pixels).
1294
+ *
1295
+ * @param width Viewport width in pixels.
1296
+ * @param height Viewport height in pixels.
1297
+ * @example
1298
+ * ```ts
1299
+ * await Spectra.setViewport(1920, 1080);
1300
+ * ```
1301
+ */
1302
+ setViewport(width: number, height: number): Promise<void>;
1303
+
1304
+ /**
1305
+ * Clicks on the specified element target.
1306
+ *
1307
+ * @param target Element selector string, Page Object element, or proxy.
1308
+ * @param textOrOptions Optional text filter or click options.
1309
+ * @example
1310
+ * ```ts
1311
+ * await Spectra.click('#submit-btn');
1312
+ * await Spectra.click(LoginPage.submitButton);
1313
+ * ```
1314
+ */
1315
+ click(target: ElementTarget, textOrOptions?: string | ClickOptions): Promise<void>;
1316
+
1317
+ /**
1318
+ * Performs a double-click interaction on the specified element target.
1319
+ *
1320
+ * @param target Target element selector or proxy.
1321
+ * @example
1322
+ * ```ts
1323
+ * await Spectra.doubleClick('.grid-cell');
1324
+ * ```
1325
+ */
1326
+ doubleClick(target: ElementTarget): Promise<void>;
1327
+
1328
+ /**
1329
+ * Performs a context-click (right-click) interaction on the specified element target.
1330
+ *
1331
+ * @param target Target element selector or proxy.
1332
+ * @example
1333
+ * ```ts
1334
+ * await Spectra.rightClick('#context-menu-area');
1335
+ * ```
1336
+ */
1337
+ rightClick(target: ElementTarget): Promise<void>;
1338
+
1339
+ /**
1340
+ * Types text keystrokes into the specified element target.
1341
+ *
1342
+ * @param target Target input or textarea element selector or proxy.
1343
+ * @param text String content to type.
1344
+ * @param options Optional typing configuration (e.g. `{ clearFirst: true }`).
1345
+ * @example
1346
+ * ```ts
1347
+ * await Spectra.type('#username', 'john_doe', { clearFirst: true });
1348
+ * ```
1349
+ */
1350
+ type(target: ElementTarget, text: string, options?: TypeOptions): Promise<void>;
1351
+
1352
+ /**
1353
+ * Clears the current text value from an input or textarea element.
1354
+ *
1355
+ * @param target Target element selector or proxy.
1356
+ * @example
1357
+ * ```ts
1358
+ * await Spectra.clear('#search-input');
1359
+ * ```
1360
+ */
1361
+ clear(target: ElementTarget): Promise<void>;
1362
+
1363
+ /**
1364
+ * Selects an option in a `<select>` dropdown by its visible text or value.
1365
+ *
1366
+ * @param target Target select element selector or proxy.
1367
+ * @param option Visible text label or value of the option.
1368
+ * @example
1369
+ * ```ts
1370
+ * await Spectra.select('#country-dropdown', 'United States');
1371
+ * ```
1372
+ */
1373
+ select(target: ElementTarget, option: string): Promise<void>;
1374
+
1375
+ /**
1376
+ * Hovers the mouse cursor over the specified element target.
1377
+ *
1378
+ * @param target Target element selector or proxy.
1379
+ * @example
1380
+ * ```ts
1381
+ * await Spectra.hover('.profile-menu-trigger');
1382
+ * ```
1383
+ */
1384
+ hover(target: ElementTarget): Promise<void>;
1385
+
1386
+ /**
1387
+ * Focuses the target element (triggers focus event and active document focus).
1388
+ *
1389
+ * @param target Target element selector or proxy.
1390
+ * @example
1391
+ * ```ts
1392
+ * await Spectra.focus('#email-input');
1393
+ * ```
1394
+ */
1395
+ focus(target: ElementTarget): Promise<void>;
1396
+
1397
+ /**
1398
+ * Drags a source element and drops it onto a destination element target.
1399
+ *
1400
+ * @param source Draggable source element selector or proxy.
1401
+ * @param destination Drop zone destination element selector or proxy.
1402
+ * @example
1403
+ * ```ts
1404
+ * await Spectra.dragDrop('#item-1', '#kanban-column-done');
1405
+ * ```
1406
+ */
1407
+ dragDrop(source: ElementTarget, destination: ElementTarget): Promise<void>;
1408
+
1409
+ /**
1410
+ * Scrolls the page until the specified element is aligned into the visible viewport.
1411
+ *
1412
+ * @param target Target element selector or proxy.
1413
+ * @example
1414
+ * ```ts
1415
+ * await Spectra.scrollIntoView('#footer-contact');
1416
+ * ```
1417
+ */
1418
+ scrollIntoView(target: ElementTarget): Promise<void>;
1419
+
1420
+ /**
1421
+ * Performs a directional scroll on the page.
1422
+ *
1423
+ * @param options Scroll options (direction, pixel distance, or target selector).
1424
+ * @example
1425
+ * ```ts
1426
+ * await Spectra.scroll({ direction: 'down', pixels: 400 });
1427
+ * ```
1428
+ */
1429
+ scroll(options?: ScrollOptions): Promise<void>;
1430
+
1431
+ /**
1432
+ * Performs a directional touch swipe gesture (mobile & web).
1433
+ *
1434
+ * @param options Swipe options (direction, distance in pixels, anchor selector).
1435
+ * @example
1436
+ * ```ts
1437
+ * await Spectra.swipe({ direction: 'left', distance: 300 });
1438
+ * ```
1439
+ */
1440
+ swipe(options: SwipeOptions): Promise<void>;
1441
+
1442
+ /**
1443
+ * Performs a long-press touch gesture on the target element.
1444
+ *
1445
+ * @param target Target element selector or proxy.
1446
+ * @param options Long-press duration in milliseconds or configuration object.
1447
+ * @example
1448
+ * ```ts
1449
+ * await Spectra.longPress('#sortable-item', { duration: 1500 });
1450
+ * ```
1451
+ */
1452
+ longPress(target: ElementTarget, options?: LongPressOptions | number): Promise<void>;
1453
+
1454
+ /**
1455
+ * Presses a specific keyboard key into the active document element.
1456
+ *
1457
+ * @param key Key name to press (e.g. 'Enter', 'Tab', 'Escape', 'Backspace').
1458
+ * @example
1459
+ * ```ts
1460
+ * await Spectra.pressKey('Enter');
1461
+ * ```
1462
+ */
1463
+ pressKey(key: KeyOption | string): Promise<void>;
1464
+
1465
+ /**
1466
+ * Pauses test execution for the specified number of milliseconds.
1467
+ *
1468
+ * @param ms Milliseconds to wait.
1469
+ * @example
1470
+ * ```ts
1471
+ * await Spectra.wait(1000);
1472
+ * ```
1473
+ */
1474
+ wait(ms: number): Promise<void>;
1475
+
1476
+ /**
1477
+ * Waits for the specified element to appear and exist in the DOM.
1478
+ *
1479
+ * @param target Target element selector or proxy.
1480
+ * @param timeoutMs Maximum time to wait in milliseconds (default: 5000ms).
1481
+ * @example
1482
+ * ```ts
1483
+ * await Spectra.waitForElement('#dynamic-content', 10000);
1484
+ * ```
1485
+ */
1486
+ waitForElement(target: ElementTarget, timeoutMs?: number): Promise<void>;
1487
+
1488
+ /**
1489
+ * Direct access to browser context commands and page assertions.
1490
+ */
1491
+ browser: SpectraBrowserBridge;
1492
+
1493
+ /**
1494
+ * Intercepts and mocks HTTP network requests matching the specified pattern or options.
1495
+ *
1496
+ * @param patternOrOptions URL pattern string or structured intercept configuration object.
1497
+ * @param method HTTP method (GET, POST, etc.) when pattern string is used.
1498
+ * @param fixture Mock response payload.
1499
+ * @param options Additional response options (status code, custom headers).
1500
+ * @example
1501
+ * ```ts
1502
+ * const mock = await Spectra.intercept('/api/v1/profile', 'GET', { name: 'Admin', role: 'root' });
1503
+ * ```
1504
+ */
1505
+ intercept(
1506
+ patternOrOptions: string | { url: string; method?: string; response?: unknown },
1507
+ method?: string,
1508
+ fixture?: unknown,
1509
+ options?: { statusCode?: number; headers?: Record<string, string> },
1510
+ ): Promise<MockInterceptHandle>;
1511
+
1512
+ /**
1513
+ * Clears and resets all active CDP network interception rules.
1514
+ *
1515
+ * @example
1516
+ * ```ts
1517
+ * Spectra.clearMocks();
1518
+ * ```
1519
+ */
1520
+ clearMocks(): void;
1521
+ }