@@ -151,26 +151,26 @@ BrowseTheWeb.as(actor).hover('mySelector', {
151
151
});
152
152
```
153
153
154
- #### isEnabled (selector: string, options?: SelectorOptions)
154
+ #### checkEnabledState (selector: string, mode: 'enabled' | 'disabled', options?: SelectorOptions, timeout?: number )
155
155
156
- Verify if a locator on the page is enabled.
156
+ Verify if a locator on the page is enabled or disabled .
157
157
158
158
``` js
159
159
// simple call with just selector
160
- BrowseTheWeb .as (actor).isEnabled (' mySelector' );
160
+ BrowseTheWeb .as (actor).checkEnabledState (' mySelector' , ' enabled ' );
161
161
// or with options
162
- BrowseTheWeb .as (actor).isEnabled (' mySelector' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
162
+ BrowseTheWeb .as (actor).checkEnabledState (' mySelector' , ' disabled ' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
163
163
```
164
164
165
- #### isVisible (selector: string, options?: SelectorOptions)
165
+ #### checkVisibilityState (selector: string, mode: 'visible' | 'hidden', options?: SelectorOptions, timeout?: number )
166
166
167
167
Verify if a locator on the page is visible.
168
168
169
169
``` js
170
170
// simple call with just selector
171
- BrowseTheWeb .as (actor).isVisible (' mySelector' );
171
+ BrowseTheWeb .as (actor).checkVisibilityState (' mySelector' , ' visible ' );
172
172
// or with options
173
- BrowseTheWeb .as (actor).isVisible (' mySelector' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
173
+ BrowseTheWeb .as (actor).checkVisibilityState (' mySelector' , ' hidden ' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
174
174
```
175
175
176
176
#### press(keys: string)
@@ -470,46 +470,46 @@ Send a request (GET, POST, PATCH, PUT, HEAD or DELETE) to the specified url. Hea
470
470
UseApi .as (actor).sendRequest (REQUEST_METHOD .POST , ' /items' , { authorization: ' Bearer dfh.dasgeq65qg.eyjkhf' }, ' json' , { title: ' new item' });
471
471
```
472
472
473
- #### checkStatus(response: Response, status: number)
473
+ #### checkStatus(response: Response, status: number, mode: 'equal' | 'unequal' )
474
474
475
475
Verify if the given response's status is equal to the expected status.
476
476
477
477
``` js
478
- UseApi .as (actor).checkStatus (response, 200 );
478
+ UseApi .as (actor).checkStatus (response, 200 , ' equal ' );
479
479
```
480
480
481
- #### checkBody(response: Response, body: ResponseBodyFormat )
481
+ #### checkBody(response: Response, body: ResponseBodyType, mode: 'equal' | 'unequal' )
482
482
483
483
Verify if the given response's body is equal to the expected body. The check includes type safety.
484
484
485
485
``` js
486
486
// json response
487
- UseApi .as (actor).checkBody (response, { text: ' test' });
487
+ UseApi .as (actor).checkBody (response, { text: ' test' }, ' equal ' );
488
488
// text response
489
- UseApi .as (actor).checkBody (response, ' test' );
489
+ UseApi .as (actor).checkBody (response, ' test' , ' unequal ' );
490
490
// buffer response
491
- UseApi .as (actor).checkBody (response, Buffer .from (' abc' ));
491
+ UseApi .as (actor).checkBody (response, Buffer .from (' abc' ), ' equal ' );
492
492
```
493
493
494
- #### checkHeaders(response: Response, headers: {[ key: string] : string | undefined })
494
+ #### checkHeaders(response: Response, headers: {[ key: string] : string | undefined }, mode: 'included' | 'excluded' )
495
495
496
496
Verify if the given headers are included in the given response's headers.
497
497
If the header has a value !== undefined, both key and value will be checked. If a header has a value === undefined, only the key will be checked.
498
498
499
499
``` js
500
500
// check only keys
501
- UseApi .as (actor).checkHeaders (response, { contentType: undefined });
501
+ UseApi .as (actor).checkHeaders (response, { contentType: undefined }, ' included ' );
502
502
// check key and value
503
- UseApi .as (actor).checkHeaders (response, { contentType: ' application/json' });
503
+ UseApi .as (actor).checkHeaders (response, { contentType: ' application/json' }, ' excluded ' );
504
504
```
505
505
506
- #### checkDuration(response: Response, duration: number)
506
+ #### checkDuration(response: Response, duration: number, mode: 'lessOrEqual' | 'greater' )
507
507
508
508
Verify if the reponse (including receiving body) was received within a given duration.
509
509
510
510
``` js
511
511
// check if response was received within 2s
512
- UseApi .as (actor).checkDuration (response, 2000 );
512
+ UseApi .as (actor).checkDuration (response, 2000 , ' lessOrEqual ' );
513
513
```
514
514
515
515
### API Actions
@@ -644,74 +644,91 @@ Sleep.for(5000);
644
644
645
645
### Available Web Questions
646
646
647
- #### Element.isVisible(selector: string, options?: SelectorOptions & { wait?: boolean })
647
+ #### Element.toBe
648
648
649
- Validates weather an element is visible or not. By default it is waited for this event to happen btu limited by the global playwright timeout settings.
650
- By settings wait to false in the options section this can be overridden.
649
+ Checks if a condition is true.
650
+
651
+ #### Element.notToBe
652
+
653
+ Checks if a condition is false.
654
+
655
+ #### Element.* .visible(selector: string, options?: SelectorOptions)
656
+
657
+ Validates wether an element is visible. A mode operator must be prepended.
651
658
652
659
``` js
653
660
// simple call with just selector
654
- Element .isVisible (' mySelector' );
661
+ Element .toBe . visible (' mySelector' );
655
662
// or with options
656
- Element .isVisible (' mySelector' , {
663
+ Element .notToBe . visible (' mySelector' , {
657
664
hasText: ' myText' ,
658
665
subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]
659
- wait: false // false means that the selector has to be available without any wait time.
660
666
});
661
667
```
662
668
663
- #### Element.isEnabled (selector: string, options?: SelectorOptions)
669
+ #### Element.* .enabled (selector: string, options?: SelectorOptions)
664
670
665
- Validates weather an element is enabled or not .
671
+ Validates wether an element is enabled. A mode operator must be prepended .
666
672
667
673
``` js
668
674
// simple call with just selector
669
- Element .isEnabled (' mySelector' );
675
+ Element .toBe . enabled (' mySelector' );
670
676
// or with options
671
- Element .isEnabled (' mySelector' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
677
+ Element .notToBe . enabled (' mySelector' , { hasText: ' myText' , subSelector: [' mySubSelector' , { hasText: ' anotherText' } ]});
672
678
```
673
679
674
680
### Available Api Questions
675
681
676
- #### Response.hasStatusCode(response: Response, code: number)
682
+ #### Response.has
683
+
684
+ Checks if a condition is true.
685
+
686
+ #### Response.hasNot
687
+
688
+ Checks if a condition is false.
689
+
690
+ #### Response.* .statusCode(response: Response, code: number)
677
691
678
- Checks if the response has a given status code.
692
+ Checks if the response has a given status code. A mode operator must be prepended.
679
693
680
694
``` js
681
- Response .hasStatusCode (response, 200 );
695
+ Response .has .statusCode (response, 200 );
696
+ Response .hasNot .statusCode (response, 200 );
682
697
```
683
698
684
- #### Response.bodyEquals (response: Response, body: ResponseBodyType)
699
+ #### Response.* .body (response: Response, body: ResponseBodyType)
685
700
686
- Checks if the response equals a given body.
701
+ Checks if the response body equals a given body. A mode operator must be prepended .
687
702
688
703
``` js
689
704
// json format
690
- Response .bodyEquals (response, { key: value });
705
+ Response .has . body (response, { key: value });
691
706
// text format
692
- Response .bodyEquals (response, ' text' );
707
+ Response .hasNot . body (response, ' text' );
693
708
// buffer format
694
- Response .bodyEquals (response, Buffer .from (' abc' ) );
709
+ Response .has . body (response, Buffer .from (' abc' ) );
695
710
```
696
711
697
- #### Response.hasHeaders (response: Response, headers: Headers)
712
+ #### Response.* .headers (response: Response, headers: Headers)
698
713
699
- Checks if the response holds the given headers either by key (value to be set to undefined) or key/value lookup.
714
+ Checks if the response has the given headers either by key (value to be set to undefined) or key/value lookup. A mode operator must be prepended .
700
715
701
716
``` js
702
717
// only check for header presence by passing undefined as the value
703
- Response .hasHeaders (response, { ' content-type' : undefined });
718
+ Response .has . headers (response, { ' content-type' : undefined });
704
719
// lookup for key/value combination to be present
705
- Response .hasHeaders (response, { ' content-type' : ' application/json' });
720
+ Response .hasNot . headers (response, { ' content-type' : ' application/json' });
706
721
```
707
722
708
- #### Response.wasReceivedWithin (response: Response, duration: number)
723
+ #### Response.* .beenReceivedWithin (response: Response, duration: number)
709
724
710
- Checks if the reponse (including receiving body) was received within a given duration.
725
+ Checks if the reponse (including receiving body) was received within a given duration. A mode operator must be prepended.
711
726
712
727
``` js
713
728
// check if response was received within 2s
714
- Response .wasReceivedWithin (response, 2000 );
729
+ Response .has .beenReceivedWithin (response, 2000 );
730
+ // check if response was not received within 2s
731
+ Response .hasNot .beenReceivedWithin (response, 2000 );
715
732
```
716
733
717
734
### Group Actions into a Task
@@ -776,7 +793,7 @@ test.describe('My Test', () => {
776
793
await actor .attemptsTo (Login .toApp ());
777
794
778
795
// Check if the login was successful - use the status question from the web package
779
- expect ( await actor .asks (Element .isVisible (' #logged-in-indicator' ))). toBe ( true );
796
+ await actor .asks (Element .toBe . visible (' #logged-in-indicator' ));
780
797
});
781
798
});
782
799
```
0 commit comments