codeceptjs 3.0.4 → 3.0.5
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/CHANGELOG.md +34 -0
- package/docs/build/Appium.js +1 -1
- package/docs/build/Nightmare.js +4 -5
- package/docs/build/Playwright.js +41 -15
- package/docs/build/Protractor.js +1 -1
- package/docs/build/Puppeteer.js +1 -1
- package/docs/build/REST.js +20 -1
- package/docs/build/TestCafe.js +1 -1
- package/docs/build/WebDriver.js +3 -3
- package/docs/changelog.md +34 -0
- package/docs/data.md +5 -5
- package/docs/detox.md +2 -2
- package/docs/docker.md +11 -11
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/Nightmare.md +4 -5
- package/docs/helpers/Playwright.md +81 -61
- package/docs/helpers/Protractor.md +1 -1
- package/docs/helpers/Puppeteer.md +1 -1
- package/docs/helpers/REST.md +9 -0
- package/docs/helpers/TestCafe.md +1 -1
- package/docs/helpers/WebDriver.md +1 -1
- package/docs/locators.md +2 -2
- package/docs/mobile-react-native-locators.md +2 -2
- package/docs/mobile.md +3 -3
- package/docs/pageobjects.md +3 -1
- package/docs/reports.md +3 -3
- package/docs/typescript.md +47 -5
- package/docs/webapi/fillField.mustache +1 -1
- package/lib/cli.js +16 -10
- package/lib/command/interactive.js +6 -7
- package/lib/config.js +6 -1
- package/lib/helper/Nightmare.js +1 -1
- package/lib/helper/Playwright.js +8 -16
- package/lib/helper/REST.js +20 -1
- package/lib/helper/WebDriver.js +2 -2
- package/lib/interfaces/gherkin.js +9 -3
- package/lib/output.js +2 -2
- package/lib/plugin/allure.js +3 -7
- package/lib/plugin/screenshotOnFail.js +1 -2
- package/lib/step.js +2 -1
- package/lib/within.js +1 -1
- package/lib/workers.js +13 -1
- package/package.json +5 -5
- package/typings/index.d.ts +7 -2
- package/typings/types.d.ts +55 -21
|
@@ -612,8 +612,10 @@ If a function returns a Promise it will wait for its resolution.
|
|
|
612
612
|
|
|
613
613
|
#### Parameters
|
|
614
614
|
|
|
615
|
-
- `fn`
|
|
616
|
-
- `arg`
|
|
615
|
+
- `fn` **([string][7] | [function][9])** function to be executed in browser context.
|
|
616
|
+
- `arg` **any?** optional argument to pass to the function
|
|
617
|
+
|
|
618
|
+
Returns **[Promise][10]<any>**
|
|
617
619
|
|
|
618
620
|
### fillField
|
|
619
621
|
|
|
@@ -634,21 +636,39 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
634
636
|
#### Parameters
|
|
635
637
|
|
|
636
638
|
- `field` **([string][7] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
637
|
-
- `value` **[string][7]** text value to fill.
|
|
639
|
+
- `value` **([string][7] | [object][5])** text value to fill.
|
|
638
640
|
|
|
639
641
|
### forceClick
|
|
640
642
|
|
|
641
|
-
|
|
643
|
+
Perform an emulated click on a link or a button, given by a locator.
|
|
644
|
+
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
645
|
+
This works on hidden, animated or inactive elements as well.
|
|
646
|
+
|
|
647
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
648
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
649
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
650
|
+
|
|
651
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
642
652
|
|
|
643
653
|
```js
|
|
644
|
-
|
|
645
|
-
I.forceClick('
|
|
654
|
+
// simple link
|
|
655
|
+
I.forceClick('Logout');
|
|
656
|
+
// button of form
|
|
657
|
+
I.forceClick('Submit');
|
|
658
|
+
// CSS button
|
|
659
|
+
I.forceClick('#form input[type=submit]');
|
|
660
|
+
// XPath
|
|
661
|
+
I.forceClick('//form/*[@type=submit]');
|
|
662
|
+
// link in context
|
|
663
|
+
I.forceClick('Logout', '#nav');
|
|
664
|
+
// using strict locator
|
|
665
|
+
I.forceClick({css: 'nav a.login'});
|
|
646
666
|
```
|
|
647
667
|
|
|
648
668
|
#### Parameters
|
|
649
669
|
|
|
650
|
-
- `locator`
|
|
651
|
-
- `context`
|
|
670
|
+
- `locator` **([string][7] | [object][5])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
671
|
+
- `context` **([string][7]? | [object][5])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
652
672
|
|
|
653
673
|
### grabAttributeFrom
|
|
654
674
|
|
|
@@ -665,7 +685,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
665
685
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
666
686
|
- `attr` **[string][7]** attribute name.
|
|
667
687
|
|
|
668
|
-
Returns **[Promise][
|
|
688
|
+
Returns **[Promise][10]<[string][7]>** attribute value
|
|
669
689
|
|
|
670
690
|
### grabAttributeFromAll
|
|
671
691
|
|
|
@@ -681,7 +701,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
681
701
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
682
702
|
- `attr` **[string][7]** attribute name.
|
|
683
703
|
|
|
684
|
-
Returns **[Promise][
|
|
704
|
+
Returns **[Promise][10]<[Array][11]<[string][7]>>** attribute value
|
|
685
705
|
|
|
686
706
|
### grabBrowserLogs
|
|
687
707
|
|
|
@@ -692,7 +712,7 @@ let logs = await I.grabBrowserLogs();
|
|
|
692
712
|
console.log(JSON.stringify(logs))
|
|
693
713
|
```
|
|
694
714
|
|
|
695
|
-
Returns **[Promise][
|
|
715
|
+
Returns **[Promise][10]<[Array][11]<any>>**
|
|
696
716
|
|
|
697
717
|
### grabCookie
|
|
698
718
|
|
|
@@ -709,7 +729,7 @@ assert(cookie.value, '123456');
|
|
|
709
729
|
|
|
710
730
|
- `name` **[string][7]?** cookie name.
|
|
711
731
|
|
|
712
|
-
Returns **([Promise][
|
|
732
|
+
Returns **([Promise][10]<[string][7]> | [Promise][10]<[Array][11]<[string][7]>>)** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
713
733
|
|
|
714
734
|
### grabCssPropertyFrom
|
|
715
735
|
|
|
@@ -726,7 +746,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
726
746
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
727
747
|
- `cssProperty` **[string][7]** CSS property name.
|
|
728
748
|
|
|
729
|
-
Returns **[Promise][
|
|
749
|
+
Returns **[Promise][10]<[string][7]>** CSS value
|
|
730
750
|
|
|
731
751
|
### grabCssPropertyFromAll
|
|
732
752
|
|
|
@@ -742,7 +762,7 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
742
762
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
743
763
|
- `cssProperty` **[string][7]** CSS property name.
|
|
744
764
|
|
|
745
|
-
Returns **[Promise][
|
|
765
|
+
Returns **[Promise][10]<[Array][11]<[string][7]>>** CSS value
|
|
746
766
|
|
|
747
767
|
### grabCurrentUrl
|
|
748
768
|
|
|
@@ -754,7 +774,7 @@ let url = await I.grabCurrentUrl();
|
|
|
754
774
|
console.log(`Current URL is [${url}]`);
|
|
755
775
|
```
|
|
756
776
|
|
|
757
|
-
Returns **[Promise][
|
|
777
|
+
Returns **[Promise][10]<[string][7]>** current URL
|
|
758
778
|
|
|
759
779
|
### grabDataFromPerformanceTiming
|
|
760
780
|
|
|
@@ -805,7 +825,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
805
825
|
- `prop`
|
|
806
826
|
- `elementSize` **[string][7]?** x, y, width or height of the given element.
|
|
807
827
|
|
|
808
|
-
Returns **([Promise][
|
|
828
|
+
Returns **([Promise][10]<DOMRect> | [Promise][10]<[number][8]>)** Element bounding rectangle
|
|
809
829
|
|
|
810
830
|
### grabHTMLFrom
|
|
811
831
|
|
|
@@ -822,7 +842,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
822
842
|
- `locator`
|
|
823
843
|
- `element` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
824
844
|
|
|
825
|
-
Returns **[Promise][
|
|
845
|
+
Returns **[Promise][10]<[string][7]>** HTML code for an element
|
|
826
846
|
|
|
827
847
|
### grabHTMLFromAll
|
|
828
848
|
|
|
@@ -838,7 +858,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
838
858
|
- `locator`
|
|
839
859
|
- `element` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
840
860
|
|
|
841
|
-
Returns **[Promise][
|
|
861
|
+
Returns **[Promise][10]<[Array][11]<[string][7]>>** HTML code for an element
|
|
842
862
|
|
|
843
863
|
### grabNumberOfOpenTabs
|
|
844
864
|
|
|
@@ -849,7 +869,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
849
869
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
850
870
|
```
|
|
851
871
|
|
|
852
|
-
Returns **[Promise][
|
|
872
|
+
Returns **[Promise][10]<[number][8]>** number of open tabs
|
|
853
873
|
|
|
854
874
|
### grabNumberOfVisibleElements
|
|
855
875
|
|
|
@@ -864,7 +884,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
864
884
|
|
|
865
885
|
- `locator` **([string][7] | [object][5])** located by CSS|XPath|strict locator.
|
|
866
886
|
|
|
867
|
-
Returns **[Promise][
|
|
887
|
+
Returns **[Promise][10]<[number][8]>** number of visible elements
|
|
868
888
|
|
|
869
889
|
### grabPageScrollPosition
|
|
870
890
|
|
|
@@ -875,7 +895,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
875
895
|
let { x, y } = await I.grabPageScrollPosition();
|
|
876
896
|
```
|
|
877
897
|
|
|
878
|
-
Returns **[Promise][
|
|
898
|
+
Returns **[Promise][10]<PageScrollPosition>** scroll position
|
|
879
899
|
|
|
880
900
|
### grabPopupText
|
|
881
901
|
|
|
@@ -885,7 +905,7 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
885
905
|
await I.grabPopupText();
|
|
886
906
|
```
|
|
887
907
|
|
|
888
|
-
Returns **[Promise][
|
|
908
|
+
Returns **[Promise][10]<([string][7] | null)>**
|
|
889
909
|
|
|
890
910
|
### grabSource
|
|
891
911
|
|
|
@@ -896,7 +916,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
896
916
|
let pageSource = await I.grabSource();
|
|
897
917
|
```
|
|
898
918
|
|
|
899
|
-
Returns **[Promise][
|
|
919
|
+
Returns **[Promise][10]<[string][7]>** source code
|
|
900
920
|
|
|
901
921
|
### grabTextFrom
|
|
902
922
|
|
|
@@ -913,7 +933,7 @@ If multiple elements found returns first element.
|
|
|
913
933
|
|
|
914
934
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
915
935
|
|
|
916
|
-
Returns **[Promise][
|
|
936
|
+
Returns **[Promise][10]<[string][7]>** attribute value
|
|
917
937
|
|
|
918
938
|
### grabTextFromAll
|
|
919
939
|
|
|
@@ -928,7 +948,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
928
948
|
|
|
929
949
|
- `locator` **([string][7] | [object][5])** element located by CSS|XPath|strict locator.
|
|
930
950
|
|
|
931
|
-
Returns **[Promise][
|
|
951
|
+
Returns **[Promise][10]<[Array][11]<[string][7]>>** attribute value
|
|
932
952
|
|
|
933
953
|
### grabTitle
|
|
934
954
|
|
|
@@ -939,7 +959,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
939
959
|
let title = await I.grabTitle();
|
|
940
960
|
```
|
|
941
961
|
|
|
942
|
-
Returns **[Promise][
|
|
962
|
+
Returns **[Promise][10]<[string][7]>** title
|
|
943
963
|
|
|
944
964
|
### grabValueFrom
|
|
945
965
|
|
|
@@ -955,7 +975,7 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
955
975
|
|
|
956
976
|
- `locator` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
957
977
|
|
|
958
|
-
Returns **[Promise][
|
|
978
|
+
Returns **[Promise][10]<[string][7]>** attribute value
|
|
959
979
|
|
|
960
980
|
### grabValueFromAll
|
|
961
981
|
|
|
@@ -970,14 +990,14 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
970
990
|
|
|
971
991
|
- `locator` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
972
992
|
|
|
973
|
-
Returns **[Promise][
|
|
993
|
+
Returns **[Promise][10]<[Array][11]<[string][7]>>** attribute value
|
|
974
994
|
|
|
975
995
|
### handleDownloads
|
|
976
996
|
|
|
977
997
|
Handles a file download.Aa file name is required to save the file on disk.
|
|
978
998
|
Files are saved to "output" directory.
|
|
979
999
|
|
|
980
|
-
Should be used with [FileSystem helper][
|
|
1000
|
+
Should be used with [FileSystem helper][12] to check that file were downloaded correctly.
|
|
981
1001
|
|
|
982
1002
|
```js
|
|
983
1003
|
I.handleDownloads('downloads/avatar.jpg');
|
|
@@ -1028,7 +1048,7 @@ Open new tab and automatically switched to new tab
|
|
|
1028
1048
|
I.openNewTab();
|
|
1029
1049
|
```
|
|
1030
1050
|
|
|
1031
|
-
You can pass in [page options][
|
|
1051
|
+
You can pass in [page options][13] to emulate device on this page
|
|
1032
1052
|
|
|
1033
1053
|
```js
|
|
1034
1054
|
// enable mobile
|
|
@@ -1043,7 +1063,7 @@ I.openNewTab({ isMobile: true });
|
|
|
1043
1063
|
|
|
1044
1064
|
Presses a key in the browser (on a focused element).
|
|
1045
1065
|
|
|
1046
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1066
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][14].
|
|
1047
1067
|
|
|
1048
1068
|
```js
|
|
1049
1069
|
I.pressKey('Backspace');
|
|
@@ -1102,13 +1122,13 @@ Some of the supported key names are:
|
|
|
1102
1122
|
|
|
1103
1123
|
#### Parameters
|
|
1104
1124
|
|
|
1105
|
-
- `key` **([string][7] | [Array][
|
|
1125
|
+
- `key` **([string][7] | [Array][11]<[string][7]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313][15]).
|
|
1106
1126
|
|
|
1107
1127
|
### pressKeyDown
|
|
1108
1128
|
|
|
1109
1129
|
Presses a key in the browser and leaves it in a down state.
|
|
1110
1130
|
|
|
1111
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1131
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][16]).
|
|
1112
1132
|
|
|
1113
1133
|
```js
|
|
1114
1134
|
I.pressKeyDown('Control');
|
|
@@ -1124,7 +1144,7 @@ I.pressKeyUp('Control');
|
|
|
1124
1144
|
|
|
1125
1145
|
Releases a key in the browser which was previously set to a down state.
|
|
1126
1146
|
|
|
1127
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1147
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][16]).
|
|
1128
1148
|
|
|
1129
1149
|
```js
|
|
1130
1150
|
I.pressKeyDown('Control');
|
|
@@ -1206,7 +1226,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1206
1226
|
#### Parameters
|
|
1207
1227
|
|
|
1208
1228
|
- `fileName` **[string][7]** file name to save.
|
|
1209
|
-
- `fullPage` **[boolean][
|
|
1229
|
+
- `fullPage` **[boolean][17]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1210
1230
|
|
|
1211
1231
|
### scrollPageToBottom
|
|
1212
1232
|
|
|
@@ -1466,7 +1486,7 @@ I.seeTitleEquals('Test title.');
|
|
|
1466
1486
|
|
|
1467
1487
|
#### Parameters
|
|
1468
1488
|
|
|
1469
|
-
- `text`
|
|
1489
|
+
- `text` **[string][7]** value to check.
|
|
1470
1490
|
|
|
1471
1491
|
### selectOption
|
|
1472
1492
|
|
|
@@ -1492,7 +1512,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1492
1512
|
#### Parameters
|
|
1493
1513
|
|
|
1494
1514
|
- `select` **([string][7] | [object][5])** field located by label|name|CSS|XPath|strict locator.
|
|
1495
|
-
- `option` **([string][7] | [Array][
|
|
1515
|
+
- `option` **([string][7] | [Array][11]<any>)** visible text or value of option.
|
|
1496
1516
|
|
|
1497
1517
|
### setCookie
|
|
1498
1518
|
|
|
@@ -1512,7 +1532,7 @@ I.setCookie([
|
|
|
1512
1532
|
|
|
1513
1533
|
#### Parameters
|
|
1514
1534
|
|
|
1515
|
-
- `cookie` **(Cookie | [Array][
|
|
1535
|
+
- `cookie` **(Cookie | [Array][11]<Cookie>)** a cookie object or array of cookie objects.
|
|
1516
1536
|
|
|
1517
1537
|
### switchTo
|
|
1518
1538
|
|
|
@@ -1557,7 +1577,7 @@ I.switchToPreviousTab(2);
|
|
|
1557
1577
|
|
|
1558
1578
|
Types out the given text into an active field.
|
|
1559
1579
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
1560
|
-
_Note:_ Should be used when [`fillField`][
|
|
1580
|
+
_Note:_ Should be used when [`fillField`][14] is not an option.
|
|
1561
1581
|
|
|
1562
1582
|
```js
|
|
1563
1583
|
// passing in a string
|
|
@@ -1574,7 +1594,7 @@ I.type(['T', 'E', 'X', 'T']);
|
|
|
1574
1594
|
|
|
1575
1595
|
- `keys`
|
|
1576
1596
|
- `delay` **[number][8]?** (optional) delay in ms between key presses
|
|
1577
|
-
- `key` **([string][7] | [Array][
|
|
1597
|
+
- `key` **([string][7] | [Array][11]<[string][7]>)** or array of keys to type.
|
|
1578
1598
|
|
|
1579
1599
|
### uncheckOption
|
|
1580
1600
|
|
|
@@ -1601,7 +1621,7 @@ Use Playwright API inside a test.
|
|
|
1601
1621
|
First argument is a description of an action.
|
|
1602
1622
|
Second argument is async function that gets this helper as parameter.
|
|
1603
1623
|
|
|
1604
|
-
{ [`page`][
|
|
1624
|
+
{ [`page`][18], [`context`][19] [`browser`][20] } objects from Playwright API are available.
|
|
1605
1625
|
|
|
1606
1626
|
```js
|
|
1607
1627
|
I.usePlaywrightTo('emulate offline mode', async ({ context }) {
|
|
@@ -1612,7 +1632,7 @@ I.usePlaywrightTo('emulate offline mode', async ({ context }) {
|
|
|
1612
1632
|
#### Parameters
|
|
1613
1633
|
|
|
1614
1634
|
- `description` **[string][7]** used to show in logs.
|
|
1615
|
-
- `fn` **[function][
|
|
1635
|
+
- `fn` **[function][9]** async functuion that executed with Playwright helper as argument
|
|
1616
1636
|
|
|
1617
1637
|
### wait
|
|
1618
1638
|
|
|
@@ -1698,8 +1718,8 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
1698
1718
|
|
|
1699
1719
|
#### Parameters
|
|
1700
1720
|
|
|
1701
|
-
- `fn` **([string][7] | [function][
|
|
1702
|
-
- `argsOrSec` **([Array][
|
|
1721
|
+
- `fn` **([string][7] | [function][9])** to be executed in browser context.
|
|
1722
|
+
- `argsOrSec` **([Array][11]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds.
|
|
1703
1723
|
- `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
|
|
1704
1724
|
|
|
1705
1725
|
### waitForInvisible
|
|
@@ -1720,7 +1740,7 @@ I.waitForInvisible('#popup');
|
|
|
1720
1740
|
|
|
1721
1741
|
Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
1722
1742
|
|
|
1723
|
-
See [
|
|
1743
|
+
See [Playwright's reference][21]
|
|
1724
1744
|
|
|
1725
1745
|
#### Parameters
|
|
1726
1746
|
|
|
@@ -1737,7 +1757,7 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
1737
1757
|
|
|
1738
1758
|
#### Parameters
|
|
1739
1759
|
|
|
1740
|
-
- `urlOrPredicate` **([string][7] | [function][
|
|
1760
|
+
- `urlOrPredicate` **([string][7] | [function][9])**
|
|
1741
1761
|
- `sec` **[number][8]?** seconds to wait
|
|
1742
1762
|
|
|
1743
1763
|
### waitForResponse
|
|
@@ -1751,7 +1771,7 @@ I.waitForResponse(request => request.url() === 'http://example.com' && request.m
|
|
|
1751
1771
|
|
|
1752
1772
|
#### Parameters
|
|
1753
1773
|
|
|
1754
|
-
- `urlOrPredicate` **([string][7] | [function][
|
|
1774
|
+
- `urlOrPredicate` **([string][7] | [function][9])**
|
|
1755
1775
|
- `sec` **[number][8]?** number of seconds to wait
|
|
1756
1776
|
|
|
1757
1777
|
### waitForText
|
|
@@ -1851,7 +1871,7 @@ I.waitUntil(() => window.requests == 0, 5);
|
|
|
1851
1871
|
|
|
1852
1872
|
#### Parameters
|
|
1853
1873
|
|
|
1854
|
-
- `fn` **([function][
|
|
1874
|
+
- `fn` **([function][9] | [string][7])** function which is executed in browser context.
|
|
1855
1875
|
- `sec` **[number][8]** (optional, `1` by default) time in seconds to wait
|
|
1856
1876
|
- `timeoutMsg` **[string][7]** message to show in case of timeout fail.
|
|
1857
1877
|
- `interval` **[number][8]?**
|
|
@@ -1886,30 +1906,30 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
1886
1906
|
|
|
1887
1907
|
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
1888
1908
|
|
|
1889
|
-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
1909
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1890
1910
|
|
|
1891
|
-
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
1911
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1892
1912
|
|
|
1893
|
-
[11]: https://
|
|
1913
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1894
1914
|
|
|
1895
|
-
[12]: https://
|
|
1915
|
+
[12]: https://codecept.io/helpers/FileSystem
|
|
1896
1916
|
|
|
1897
|
-
[13]: #
|
|
1917
|
+
[13]: https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewpageoptions
|
|
1898
1918
|
|
|
1899
|
-
[14]:
|
|
1919
|
+
[14]: #fillfield
|
|
1900
1920
|
|
|
1901
|
-
[15]:
|
|
1921
|
+
[15]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
1902
1922
|
|
|
1903
|
-
[16]:
|
|
1923
|
+
[16]: #click
|
|
1904
1924
|
|
|
1905
|
-
[17]: https://
|
|
1925
|
+
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
1906
1926
|
|
|
1907
|
-
[18]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-
|
|
1927
|
+
[18]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-page
|
|
1908
1928
|
|
|
1909
|
-
[19]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-
|
|
1929
|
+
[19]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-context
|
|
1910
1930
|
|
|
1911
|
-
[20]: https://
|
|
1931
|
+
[20]: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-browser
|
|
1912
1932
|
|
|
1913
|
-
[21]: https://
|
|
1933
|
+
[21]: https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions
|
|
1914
1934
|
|
|
1915
1935
|
[22]: https://codecept.io/react
|
|
@@ -563,7 +563,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
563
563
|
#### Parameters
|
|
564
564
|
|
|
565
565
|
- `field` **([string][9] | [object][10])** located by label|name|CSS|XPath|strict locator.
|
|
566
|
-
- `value` **[string][9]** text value to fill.
|
|
566
|
+
- `value` **([string][9] | [object][10])** text value to fill.
|
|
567
567
|
|
|
568
568
|
### grabAttributeFrom
|
|
569
569
|
|
|
@@ -690,7 +690,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
690
690
|
#### Parameters
|
|
691
691
|
|
|
692
692
|
- `field` **([string][8] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
693
|
-
- `value` **[string][8]** text value to fill.
|
|
693
|
+
- `value` **([string][8] | [object][6])** text value to fill.
|
|
694
694
|
|
|
695
695
|
|
|
696
696
|
This action supports [React locators](https://codecept.io/react#locators)
|
package/docs/helpers/REST.md
CHANGED
|
@@ -101,6 +101,9 @@ Sends PATCH request to API.
|
|
|
101
101
|
|
|
102
102
|
```js
|
|
103
103
|
I.sendPatchRequest('/api/users.json', { "email": "user@user.com" });
|
|
104
|
+
|
|
105
|
+
// To mask the payload in logs
|
|
106
|
+
I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
104
107
|
```
|
|
105
108
|
|
|
106
109
|
#### Parameters
|
|
@@ -115,6 +118,9 @@ Sends POST request to API.
|
|
|
115
118
|
|
|
116
119
|
```js
|
|
117
120
|
I.sendPostRequest('/api/users.json', { "email": "user@user.com" });
|
|
121
|
+
|
|
122
|
+
// To mask the payload in logs
|
|
123
|
+
I.sendPostRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
118
124
|
```
|
|
119
125
|
|
|
120
126
|
#### Parameters
|
|
@@ -129,6 +135,9 @@ Sends PUT request to API.
|
|
|
129
135
|
|
|
130
136
|
```js
|
|
131
137
|
I.sendPutRequest('/api/users.json', { "email": "user@user.com" });
|
|
138
|
+
|
|
139
|
+
// To mask the payload in logs
|
|
140
|
+
I.sendPutRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
132
141
|
```
|
|
133
142
|
|
|
134
143
|
#### Parameters
|
package/docs/helpers/TestCafe.md
CHANGED
|
@@ -399,7 +399,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
399
399
|
#### Parameters
|
|
400
400
|
|
|
401
401
|
- `field` **([string][4] | [object][5])** located by label|name|CSS|XPath|strict locator.
|
|
402
|
-
- `value` **[string][4]** text value to fill.
|
|
402
|
+
- `value` **([string][4] | [object][5])** text value to fill.
|
|
403
403
|
|
|
404
404
|
### grabAttributeFrom
|
|
405
405
|
|
|
@@ -868,7 +868,7 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
868
868
|
#### Parameters
|
|
869
869
|
|
|
870
870
|
- `field` **([string][19] | [object][18])** located by label|name|CSS|XPath|strict locator.
|
|
871
|
-
- `value` **[string][19]** text value to fill.
|
|
871
|
+
- `value` **([string][19] | [object][18])** text value to fill.
|
|
872
872
|
|
|
873
873
|
|
|
874
874
|
This action supports [React locators](https://codecept.io/react#locators)
|
package/docs/locators.md
CHANGED
|
@@ -21,7 +21,7 @@ If the locator is an object, it should have a single element, with the key signi
|
|
|
21
21
|
|
|
22
22
|
Examples:
|
|
23
23
|
|
|
24
|
-
* {
|
|
24
|
+
* {id: 'foo'} matches `<div id="foo">`
|
|
25
25
|
* {name: 'foo'} matches `<div name="foo">`
|
|
26
26
|
* {css: 'input[type=input][value=foo]'} matches `<input type="input" value="foo">`
|
|
27
27
|
* {xpath: "//input[@type='submit'][contains(@value, 'foo')]"} matches `<input type="submit" value="foobar">`
|
|
@@ -229,7 +229,7 @@ locate('button').after('.btn-cancel');
|
|
|
229
229
|
|
|
230
230
|
ID locators are best to select the exact semantic element in web and mobile testing:
|
|
231
231
|
|
|
232
|
-
* `#user` or `{
|
|
232
|
+
* `#user` or `{ id: 'user' }` finds element with id="user"
|
|
233
233
|
* `~user` finds element with accessibility id "user" (in Mobile testing) or with `aria-label=user`.
|
|
234
234
|
|
|
235
235
|
## Custom Locators
|
|
@@ -46,14 +46,14 @@ You could do it just by changing `automationName` in the `helpers` section of th
|
|
|
46
46
|
```
|
|
47
47
|
Then you could locate components using XPath expression:
|
|
48
48
|
```js
|
|
49
|
-
I.tap({android:
|
|
49
|
+
I.tap({android: '//*[@view-tag="someButton"]', ios: '~someButton'})
|
|
50
50
|
```
|
|
51
51
|
This way test would work for both platforms without any changes in code.
|
|
52
52
|
To simplify things further you could write a helper function:
|
|
53
53
|
```js
|
|
54
54
|
function tid(id) {
|
|
55
55
|
return {
|
|
56
|
-
android:
|
|
56
|
+
android: `//*[@view-tag="${id}"]`,
|
|
57
57
|
ios: '~' + id
|
|
58
58
|
}
|
|
59
59
|
}
|
package/docs/mobile.md
CHANGED
|
@@ -19,7 +19,7 @@ I.see('davert@codecept.io', '~email of the customer'));
|
|
|
19
19
|
I.clearField('~email of the customer'));
|
|
20
20
|
I.dontSee('Nothing special', '~email of the customer'));
|
|
21
21
|
I.seeElement({
|
|
22
|
-
android:
|
|
22
|
+
android: 'android.widget.Button',
|
|
23
23
|
ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'
|
|
24
24
|
});
|
|
25
25
|
```
|
|
@@ -118,6 +118,7 @@ helpers: {
|
|
|
118
118
|
app: "bs://<hashed app-id>",
|
|
119
119
|
host: "hub-cloud.browserstack.com",
|
|
120
120
|
port: 4444,
|
|
121
|
+
platform: "ios",
|
|
121
122
|
user: "BROWSERSTACK_USER",
|
|
122
123
|
key: "BROWSERSTACK_KEY",
|
|
123
124
|
device: "iPhone 7"
|
|
@@ -262,7 +263,7 @@ It is often happen that mobile applications behave similarly on different platfo
|
|
|
262
263
|
CodeceptJS provides a way to specify different locators for Android and iOS platforms:
|
|
263
264
|
|
|
264
265
|
```js
|
|
265
|
-
I.click({android:
|
|
266
|
+
I.click({android: '//android.widget.Button', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
|
|
266
267
|
```
|
|
267
268
|
|
|
268
269
|
In case some code should be executed on one platform and ignored on others use `runOnAndroid` and `runOnIOS` methods:
|
|
@@ -293,4 +294,3 @@ Just as you can specify android, and ios-specific locators, you can do so for we
|
|
|
293
294
|
```js
|
|
294
295
|
I.click({web: '#login', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
|
|
295
296
|
```
|
|
296
|
-
|
package/docs/pageobjects.md
CHANGED
|
@@ -32,7 +32,9 @@ const { I, myPage, mySteps } = inject();
|
|
|
32
32
|
// inject objects for a test by name
|
|
33
33
|
Scenario('sample test', ({ I, myPage, mySteps }) => {
|
|
34
34
|
// ...
|
|
35
|
-
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
36
38
|
## Actor
|
|
37
39
|
|
|
38
40
|
During initialization you were asked to create a custom steps file. If you accepted this option, you are now able to use the `custom_steps.js` file to extend `I`. See how the `login` method can be added to `I`:
|
package/docs/reports.md
CHANGED
|
@@ -360,9 +360,9 @@ Configure mocha-multi with reports that you want:
|
|
|
360
360
|
"mocha-junit-reporter": {
|
|
361
361
|
"stdout": "./output/console.log",
|
|
362
362
|
"options": {
|
|
363
|
-
"mochaFile": "./output/result.xml"
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
"mochaFile": "./output/result.xml",
|
|
364
|
+
"attachments": true //add screenshot for a failed test
|
|
365
|
+
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|