codeceptjs 3.5.0 → 3.5.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/CHANGELOG.md +27 -0
- package/README.md +3 -3
- package/docs/ai.md +11 -9
- package/docs/build/OpenAI.js +14 -10
- package/docs/build/Playwright.js +60 -28
- package/docs/build/Puppeteer.js +56 -0
- package/docs/build/TestCafe.js +58 -1
- package/docs/build/WebDriver.js +55 -0
- package/docs/changelog.md +27 -0
- package/docs/helpers/Playwright.md +201 -166
- package/docs/helpers/Puppeteer.md +148 -102
- package/docs/helpers/TestCafe.md +95 -49
- package/docs/helpers/WebDriver.md +150 -104
- package/docs/plugins.md +1 -1
- package/docs/webapi/blur.mustache +17 -0
- package/docs/webapi/focus.mustache +12 -0
- package/lib/cli.js +9 -1
- package/lib/command/init.js +10 -0
- package/lib/event.js +2 -0
- package/lib/helper/OpenAI.js +14 -10
- package/lib/helper/Playwright.js +48 -45
- package/lib/helper/Puppeteer.js +27 -0
- package/lib/helper/TestCafe.js +29 -1
- package/lib/helper/WebDriver.js +26 -0
- package/lib/helper/scripts/blurElement.js +17 -0
- package/lib/helper/scripts/focusElement.js +17 -0
- package/lib/interfaces/gherkin.js +8 -0
- package/lib/plugin/heal.js +5 -7
- package/lib/recorder.js +7 -4
- package/lib/utils.js +13 -0
- package/package.json +7 -10
- package/typings/promiseBasedTypes.d.ts +130 -13
- package/typings/types.d.ts +134 -17
|
@@ -39,24 +39,24 @@ Type: [object][4]
|
|
|
39
39
|
|
|
40
40
|
- `url` **[string][6]** base url of website to be tested
|
|
41
41
|
- `basicAuth` **[object][4]?** (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
42
|
-
- `show` **[boolean][
|
|
43
|
-
- `restart` **[boolean][
|
|
44
|
-
- `disableScreenshots` **[boolean][
|
|
45
|
-
- `fullPageScreenshots` **[boolean][
|
|
46
|
-
- `uniqueScreenshotNames` **[boolean][
|
|
47
|
-
- `keepBrowserState` **[boolean][
|
|
48
|
-
- `keepCookies` **[boolean][
|
|
49
|
-
- `waitForAction` **[number][
|
|
50
|
-
- `waitForNavigation` **[string][6]?** when to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Puppeteer API][
|
|
51
|
-
- `pressKeyDelay` **[number][
|
|
52
|
-
- `getPageTimeout` **[number][
|
|
53
|
-
- `waitForTimeout` **[number][
|
|
42
|
+
- `show` **[boolean][20]?** show Google Chrome window for debug.
|
|
43
|
+
- `restart` **[boolean][20]?** restart browser between tests.
|
|
44
|
+
- `disableScreenshots` **[boolean][20]?** don't save screenshot on failure.
|
|
45
|
+
- `fullPageScreenshots` **[boolean][20]?** make full page screenshots on failure.
|
|
46
|
+
- `uniqueScreenshotNames` **[boolean][20]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
|
|
47
|
+
- `keepBrowserState` **[boolean][20]?** keep browser state between tests when `restart` is set to false.
|
|
48
|
+
- `keepCookies` **[boolean][20]?** keep cookies between tests when `restart` is set to false.
|
|
49
|
+
- `waitForAction` **[number][10]?** how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
|
|
50
|
+
- `waitForNavigation` **[string][6]?** when to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Puppeteer API][23]. Array values are accepted as well.
|
|
51
|
+
- `pressKeyDelay` **[number][10]?** delay between key presses in ms. Used when calling Puppeteers page.type(...) in fillField/appendField
|
|
52
|
+
- `getPageTimeout` **[number][10]?** config option to set maximum navigation time in milliseconds. If the timeout is set to 0, then timeout will be disabled.
|
|
53
|
+
- `waitForTimeout` **[number][10]?** default wait* timeout in ms.
|
|
54
54
|
- `windowSize` **[string][6]?** default window size. Set a dimension in format WIDTHxHEIGHT like `640x480`.
|
|
55
55
|
- `userAgent` **[string][6]?** user-agent string.
|
|
56
|
-
- `manualStart` **[boolean][
|
|
56
|
+
- `manualStart` **[boolean][20]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
|
|
57
57
|
- `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
|
|
58
|
-
- `chrome` **[object][4]?** pass additional [Puppeteer run options][
|
|
59
|
-
- `highlightElement` **[boolean][
|
|
58
|
+
- `chrome` **[object][4]?** pass additional [Puppeteer run options][25].
|
|
59
|
+
- `highlightElement` **[boolean][20]?** highlight the interacting elements
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
@@ -328,6 +328,29 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
328
328
|
- `pathToFile` **[string][6]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
329
329
|
⚠️ returns a _promise_ which is synchronized internally by recorder> ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][7], downgrade to 2.0.0 if you face it.
|
|
330
330
|
|
|
331
|
+
### blur
|
|
332
|
+
|
|
333
|
+
Remove focus from a text input, button, etc.
|
|
334
|
+
Calls [blur][8] on the element.
|
|
335
|
+
|
|
336
|
+
Examples:
|
|
337
|
+
|
|
338
|
+
```js
|
|
339
|
+
I.blur('.text-area')
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
```js
|
|
343
|
+
//element `#product-tile` is focused
|
|
344
|
+
I.see('#add-to-cart-btn');
|
|
345
|
+
I.blur('#product-tile')
|
|
346
|
+
I.dontSee('#add-to-cart-btn');
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
#### Parameters
|
|
350
|
+
|
|
351
|
+
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
352
|
+
- `options` **any?** Playwright only: [Additional options][9] for available options object as 2nd argument.
|
|
353
|
+
|
|
331
354
|
### cancelPopup
|
|
332
355
|
|
|
333
356
|
Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
|
|
@@ -656,7 +679,7 @@ I.dragSlider('#slider', -70);
|
|
|
656
679
|
#### Parameters
|
|
657
680
|
|
|
658
681
|
- `locator` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
659
|
-
- `offsetX` **[number][
|
|
682
|
+
- `offsetX` **[number][10]** position to drag.
|
|
660
683
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
661
684
|
|
|
662
685
|
|
|
@@ -668,7 +691,7 @@ This action supports [React locators](https://codecept.io/react#locators)
|
|
|
668
691
|
Executes async script on page.
|
|
669
692
|
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
670
693
|
|
|
671
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][
|
|
694
|
+
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][11].
|
|
672
695
|
|
|
673
696
|
```js
|
|
674
697
|
I.executeAsyncScript(function(done) {
|
|
@@ -690,7 +713,7 @@ let val = await I.executeAsyncScript(function(url, done) {
|
|
|
690
713
|
|
|
691
714
|
- `args` **...any** to be passed to function.
|
|
692
715
|
⚠️ returns a _promise_ which is synchronized internally by recorderAsynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
|
|
693
|
-
- `fn` **([string][6] | [function][
|
|
716
|
+
- `fn` **([string][6] | [function][12])** function to be executed in browser context.
|
|
694
717
|
|
|
695
718
|
### executeScript
|
|
696
719
|
|
|
@@ -722,7 +745,7 @@ let date = await I.executeScript(function(el) {
|
|
|
722
745
|
|
|
723
746
|
- `args` **...any** to be passed to function.
|
|
724
747
|
⚠️ returns a _promise_ which is synchronized internally by recorderIf a function returns a Promise It will wait for it resolution.
|
|
725
|
-
- `fn` **([string][6] | [function][
|
|
748
|
+
- `fn` **([string][6] | [function][12])** function to be executed in browser context.
|
|
726
749
|
|
|
727
750
|
### fillField
|
|
728
751
|
|
|
@@ -750,6 +773,23 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
750
773
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
751
774
|
|
|
752
775
|
|
|
776
|
+
### focus
|
|
777
|
+
|
|
778
|
+
Calls [focus][8] on the matching element.
|
|
779
|
+
|
|
780
|
+
Examples:
|
|
781
|
+
|
|
782
|
+
```js
|
|
783
|
+
I.dontSee('#add-to-cart-btn');
|
|
784
|
+
I.focus('#product-tile')
|
|
785
|
+
I.see('#add-to-cart-bnt');
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
#### Parameters
|
|
789
|
+
|
|
790
|
+
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
791
|
+
- `options` **any?** Playwright only: [Additional options][13] for available options object as 2nd argument.
|
|
792
|
+
|
|
753
793
|
### forceClick
|
|
754
794
|
|
|
755
795
|
Perform an emulated click on a link or a button, given by a locator.
|
|
@@ -802,7 +842,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
802
842
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
803
843
|
- `attr` **[string][6]** attribute name.
|
|
804
844
|
|
|
805
|
-
Returns **[Promise][
|
|
845
|
+
Returns **[Promise][14]<[string][6]>** attribute value
|
|
806
846
|
|
|
807
847
|
|
|
808
848
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -822,7 +862,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
822
862
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
823
863
|
- `attr` **[string][6]** attribute name.
|
|
824
864
|
|
|
825
|
-
Returns **[Promise][
|
|
865
|
+
Returns **[Promise][14]<[Array][15]<[string][6]>>** attribute value
|
|
826
866
|
|
|
827
867
|
|
|
828
868
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -837,7 +877,7 @@ let logs = await I.grabBrowserLogs();
|
|
|
837
877
|
console.log(JSON.stringify(logs))
|
|
838
878
|
```
|
|
839
879
|
|
|
840
|
-
Returns **[Promise][
|
|
880
|
+
Returns **[Promise][14]<[Array][15]<any>>**
|
|
841
881
|
|
|
842
882
|
### grabCookie
|
|
843
883
|
|
|
@@ -854,7 +894,7 @@ assert(cookie.value, '123456');
|
|
|
854
894
|
|
|
855
895
|
- `name` **[string][6]?** cookie name.
|
|
856
896
|
|
|
857
|
-
Returns **([Promise][
|
|
897
|
+
Returns **([Promise][14]<[string][6]> | [Promise][14]<[Array][15]<[string][6]>>)** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
858
898
|
|
|
859
899
|
### grabCssPropertyFrom
|
|
860
900
|
|
|
@@ -871,7 +911,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
871
911
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
872
912
|
- `cssProperty` **[string][6]** CSS property name.
|
|
873
913
|
|
|
874
|
-
Returns **[Promise][
|
|
914
|
+
Returns **[Promise][14]<[string][6]>** CSS value
|
|
875
915
|
|
|
876
916
|
|
|
877
917
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -891,7 +931,7 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
891
931
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
892
932
|
- `cssProperty` **[string][6]** CSS property name.
|
|
893
933
|
|
|
894
|
-
Returns **[Promise][
|
|
934
|
+
Returns **[Promise][14]<[Array][15]<[string][6]>>** CSS value
|
|
895
935
|
|
|
896
936
|
|
|
897
937
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -907,7 +947,7 @@ let url = await I.grabCurrentUrl();
|
|
|
907
947
|
console.log(`Current URL is [${url}]`);
|
|
908
948
|
```
|
|
909
949
|
|
|
910
|
-
Returns **[Promise][
|
|
950
|
+
Returns **[Promise][14]<[string][6]>** current URL
|
|
911
951
|
|
|
912
952
|
### grabDataFromPerformanceTiming
|
|
913
953
|
|
|
@@ -932,7 +972,7 @@ let data = await I.grabDataFromPerformanceTiming();
|
|
|
932
972
|
}
|
|
933
973
|
```
|
|
934
974
|
|
|
935
|
-
Returns **[Promise][
|
|
975
|
+
Returns **[Promise][14]<any>** automatically synchronized promise through #recorder
|
|
936
976
|
|
|
937
977
|
### grabElementBoundingRect
|
|
938
978
|
|
|
@@ -960,7 +1000,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
960
1000
|
- `prop`
|
|
961
1001
|
- `elementSize` **[string][6]?** x, y, width or height of the given element.
|
|
962
1002
|
|
|
963
|
-
Returns **([Promise][
|
|
1003
|
+
Returns **([Promise][14]<DOMRect> | [Promise][14]<[number][10]>)** Element bounding rectangle
|
|
964
1004
|
|
|
965
1005
|
### grabHTMLFrom
|
|
966
1006
|
|
|
@@ -977,7 +1017,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
977
1017
|
- `locator`
|
|
978
1018
|
- `element` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
979
1019
|
|
|
980
|
-
Returns **[Promise][
|
|
1020
|
+
Returns **[Promise][14]<[string][6]>** HTML code for an element
|
|
981
1021
|
|
|
982
1022
|
### grabHTMLFromAll
|
|
983
1023
|
|
|
@@ -993,7 +1033,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
993
1033
|
- `locator`
|
|
994
1034
|
- `element` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
995
1035
|
|
|
996
|
-
Returns **[Promise][
|
|
1036
|
+
Returns **[Promise][14]<[Array][15]<[string][6]>>** HTML code for an element
|
|
997
1037
|
|
|
998
1038
|
### grabNumberOfOpenTabs
|
|
999
1039
|
|
|
@@ -1004,7 +1044,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1004
1044
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
1005
1045
|
```
|
|
1006
1046
|
|
|
1007
|
-
Returns **[Promise][
|
|
1047
|
+
Returns **[Promise][14]<[number][10]>** number of open tabs
|
|
1008
1048
|
|
|
1009
1049
|
### grabNumberOfVisibleElements
|
|
1010
1050
|
|
|
@@ -1019,7 +1059,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
1019
1059
|
|
|
1020
1060
|
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1021
1061
|
|
|
1022
|
-
Returns **[Promise][
|
|
1062
|
+
Returns **[Promise][14]<[number][10]>** number of visible elements
|
|
1023
1063
|
|
|
1024
1064
|
|
|
1025
1065
|
|
|
@@ -1035,7 +1075,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
1035
1075
|
let { x, y } = await I.grabPageScrollPosition();
|
|
1036
1076
|
```
|
|
1037
1077
|
|
|
1038
|
-
Returns **[Promise][
|
|
1078
|
+
Returns **[Promise][14]<PageScrollPosition>** scroll position
|
|
1039
1079
|
|
|
1040
1080
|
### grabPopupText
|
|
1041
1081
|
|
|
@@ -1045,7 +1085,7 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
1045
1085
|
await I.grabPopupText();
|
|
1046
1086
|
```
|
|
1047
1087
|
|
|
1048
|
-
Returns **[Promise][
|
|
1088
|
+
Returns **[Promise][14]<([string][6] | null)>**
|
|
1049
1089
|
|
|
1050
1090
|
### grabSource
|
|
1051
1091
|
|
|
@@ -1056,7 +1096,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
1056
1096
|
let pageSource = await I.grabSource();
|
|
1057
1097
|
```
|
|
1058
1098
|
|
|
1059
|
-
Returns **[Promise][
|
|
1099
|
+
Returns **[Promise][14]<[string][6]>** source code
|
|
1060
1100
|
|
|
1061
1101
|
### grabTextFrom
|
|
1062
1102
|
|
|
@@ -1073,7 +1113,7 @@ If multiple elements found returns first element.
|
|
|
1073
1113
|
|
|
1074
1114
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1075
1115
|
|
|
1076
|
-
Returns **[Promise][
|
|
1116
|
+
Returns **[Promise][14]<[string][6]>** attribute value
|
|
1077
1117
|
|
|
1078
1118
|
|
|
1079
1119
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -1092,7 +1132,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
1092
1132
|
|
|
1093
1133
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1094
1134
|
|
|
1095
|
-
Returns **[Promise][
|
|
1135
|
+
Returns **[Promise][14]<[Array][15]<[string][6]>>** attribute value
|
|
1096
1136
|
|
|
1097
1137
|
|
|
1098
1138
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -1107,7 +1147,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
1107
1147
|
let title = await I.grabTitle();
|
|
1108
1148
|
```
|
|
1109
1149
|
|
|
1110
|
-
Returns **[Promise][
|
|
1150
|
+
Returns **[Promise][14]<[string][6]>** title
|
|
1111
1151
|
|
|
1112
1152
|
### grabValueFrom
|
|
1113
1153
|
|
|
@@ -1123,7 +1163,7 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
1123
1163
|
|
|
1124
1164
|
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1125
1165
|
|
|
1126
|
-
Returns **[Promise][
|
|
1166
|
+
Returns **[Promise][14]<[string][6]>** attribute value
|
|
1127
1167
|
|
|
1128
1168
|
### grabValueFromAll
|
|
1129
1169
|
|
|
@@ -1138,12 +1178,12 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
1138
1178
|
|
|
1139
1179
|
- `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1140
1180
|
|
|
1141
|
-
Returns **[Promise][
|
|
1181
|
+
Returns **[Promise][14]<[Array][15]<[string][6]>>** attribute value
|
|
1142
1182
|
|
|
1143
1183
|
### handleDownloads
|
|
1144
1184
|
|
|
1145
1185
|
Sets a directory to where save files. Allows to test file downloads.
|
|
1146
|
-
Should be used with [FileSystem helper][
|
|
1186
|
+
Should be used with [FileSystem helper][16] to check that file were downloaded correctly.
|
|
1147
1187
|
|
|
1148
1188
|
By default files are saved to `output/downloads`.
|
|
1149
1189
|
This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
|
|
@@ -1186,8 +1226,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1186
1226
|
#### Parameters
|
|
1187
1227
|
|
|
1188
1228
|
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1189
|
-
- `offsetX` **[number][
|
|
1190
|
-
- `offsetY` **[number][
|
|
1229
|
+
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1230
|
+
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1191
1231
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1192
1232
|
|
|
1193
1233
|
|
|
@@ -1206,7 +1246,7 @@ I.openNewTab();
|
|
|
1206
1246
|
|
|
1207
1247
|
Presses a key in the browser (on a focused element).
|
|
1208
1248
|
|
|
1209
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1249
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][17].
|
|
1210
1250
|
|
|
1211
1251
|
```js
|
|
1212
1252
|
I.pressKey('Backspace');
|
|
@@ -1265,14 +1305,14 @@ Some of the supported key names are:
|
|
|
1265
1305
|
|
|
1266
1306
|
#### Parameters
|
|
1267
1307
|
|
|
1268
|
-
- `key` **([string][6] | [Array][
|
|
1269
|
-
⚠️ returns a _promise_ which is synchronized internally by recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][
|
|
1308
|
+
- `key` **([string][6] | [Array][15]<[string][6]>)** key or array of keys to press.
|
|
1309
|
+
⚠️ returns a _promise_ which is synchronized internally by recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][18]).
|
|
1270
1310
|
|
|
1271
1311
|
### pressKeyDown
|
|
1272
1312
|
|
|
1273
1313
|
Presses a key in the browser and leaves it in a down state.
|
|
1274
1314
|
|
|
1275
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1315
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][19]).
|
|
1276
1316
|
|
|
1277
1317
|
```js
|
|
1278
1318
|
I.pressKeyDown('Control');
|
|
@@ -1289,7 +1329,7 @@ I.pressKeyUp('Control');
|
|
|
1289
1329
|
|
|
1290
1330
|
Releases a key in the browser which was previously set to a down state.
|
|
1291
1331
|
|
|
1292
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1332
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][19]).
|
|
1293
1333
|
|
|
1294
1334
|
```js
|
|
1295
1335
|
I.pressKeyDown('Control');
|
|
@@ -1319,8 +1359,8 @@ First parameter can be set to `maximize`.
|
|
|
1319
1359
|
|
|
1320
1360
|
#### Parameters
|
|
1321
1361
|
|
|
1322
|
-
- `width` **[number][
|
|
1323
|
-
- `height` **[number][
|
|
1362
|
+
- `width` **[number][10]** width in pixels or `maximize`.
|
|
1363
|
+
- `height` **[number][10]** height in pixels.
|
|
1324
1364
|
⚠️ returns a _promise_ which is synchronized internally by recorderUnlike other drivers Puppeteer changes the size of a viewport, not the window!
|
|
1325
1365
|
Puppeteer does not control the window of a browser so it can't adjust its real size.
|
|
1326
1366
|
It also can't maximize a window.
|
|
@@ -1377,7 +1417,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1377
1417
|
#### Parameters
|
|
1378
1418
|
|
|
1379
1419
|
- `fileName` **[string][6]** file name to save.
|
|
1380
|
-
- `fullPage` **[boolean][
|
|
1420
|
+
- `fullPage` **[boolean][20]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1381
1421
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1382
1422
|
|
|
1383
1423
|
### scrollPageToBottom
|
|
@@ -1413,8 +1453,8 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1413
1453
|
#### Parameters
|
|
1414
1454
|
|
|
1415
1455
|
- `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
|
|
1416
|
-
- `offsetX` **[number][
|
|
1417
|
-
- `offsetY` **[number][
|
|
1456
|
+
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1457
|
+
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1418
1458
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1419
1459
|
|
|
1420
1460
|
### see
|
|
@@ -1633,7 +1673,7 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
1633
1673
|
#### Parameters
|
|
1634
1674
|
|
|
1635
1675
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1636
|
-
- `num` **[number][
|
|
1676
|
+
- `num` **[number][10]** number of elements.
|
|
1637
1677
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1638
1678
|
|
|
1639
1679
|
|
|
@@ -1652,7 +1692,7 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1652
1692
|
#### Parameters
|
|
1653
1693
|
|
|
1654
1694
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1655
|
-
- `num` **[number][
|
|
1695
|
+
- `num` **[number][10]** number of elements.
|
|
1656
1696
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1657
1697
|
|
|
1658
1698
|
|
|
@@ -1710,7 +1750,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1710
1750
|
#### Parameters
|
|
1711
1751
|
|
|
1712
1752
|
- `select` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1713
|
-
- `option` **([string][6] | [Array][
|
|
1753
|
+
- `option` **([string][6] | [Array][15]<any>)** visible text or value of option.
|
|
1714
1754
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1715
1755
|
|
|
1716
1756
|
### setCookie
|
|
@@ -1731,7 +1771,7 @@ I.setCookie([
|
|
|
1731
1771
|
|
|
1732
1772
|
#### Parameters
|
|
1733
1773
|
|
|
1734
|
-
- `cookie` **(Cookie | [Array][
|
|
1774
|
+
- `cookie` **(Cookie | [Array][15]<Cookie>)** a cookie object or array of cookie objects.
|
|
1735
1775
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1736
1776
|
|
|
1737
1777
|
### switchTo
|
|
@@ -1759,7 +1799,7 @@ I.switchToNextTab(2);
|
|
|
1759
1799
|
|
|
1760
1800
|
#### Parameters
|
|
1761
1801
|
|
|
1762
|
-
- `num` **[number][
|
|
1802
|
+
- `num` **[number][10]**
|
|
1763
1803
|
|
|
1764
1804
|
### switchToPreviousTab
|
|
1765
1805
|
|
|
@@ -1772,13 +1812,13 @@ I.switchToPreviousTab(2);
|
|
|
1772
1812
|
|
|
1773
1813
|
#### Parameters
|
|
1774
1814
|
|
|
1775
|
-
- `num` **[number][
|
|
1815
|
+
- `num` **[number][10]**
|
|
1776
1816
|
|
|
1777
1817
|
### type
|
|
1778
1818
|
|
|
1779
1819
|
Types out the given text into an active field.
|
|
1780
1820
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
1781
|
-
_Note:_ Should be used when [`fillField`][
|
|
1821
|
+
_Note:_ Should be used when [`fillField`][17] is not an option.
|
|
1782
1822
|
|
|
1783
1823
|
```js
|
|
1784
1824
|
// passing in a string
|
|
@@ -1797,9 +1837,9 @@ I.type(secret('123456'));
|
|
|
1797
1837
|
#### Parameters
|
|
1798
1838
|
|
|
1799
1839
|
- `keys`
|
|
1800
|
-
- `delay` **[number][
|
|
1840
|
+
- `delay` **[number][10]?** (optional) delay in ms between key presses
|
|
1801
1841
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1802
|
-
- `key` **([string][6] | [Array][
|
|
1842
|
+
- `key` **([string][6] | [Array][15]<[string][6]>)** or array of keys to type.
|
|
1803
1843
|
|
|
1804
1844
|
### uncheckOption
|
|
1805
1845
|
|
|
@@ -1827,7 +1867,7 @@ Use Puppeteer API inside a test.
|
|
|
1827
1867
|
First argument is a description of an action.
|
|
1828
1868
|
Second argument is async function that gets this helper as parameter.
|
|
1829
1869
|
|
|
1830
|
-
{ [`page`][
|
|
1870
|
+
{ [`page`][21], [`browser`][22] } from Puppeteer API are available.
|
|
1831
1871
|
|
|
1832
1872
|
```js
|
|
1833
1873
|
I.usePuppeteerTo('emulate offline mode', async ({ page }) {
|
|
@@ -1838,7 +1878,7 @@ I.usePuppeteerTo('emulate offline mode', async ({ page }) {
|
|
|
1838
1878
|
#### Parameters
|
|
1839
1879
|
|
|
1840
1880
|
- `description` **[string][6]** used to show in logs.
|
|
1841
|
-
- `fn` **[function][
|
|
1881
|
+
- `fn` **[function][12]** async function that is executed with Puppeteer as argument
|
|
1842
1882
|
|
|
1843
1883
|
### wait
|
|
1844
1884
|
|
|
@@ -1850,7 +1890,7 @@ I.wait(2); // wait 2 secs
|
|
|
1850
1890
|
|
|
1851
1891
|
#### Parameters
|
|
1852
1892
|
|
|
1853
|
-
- `sec` **[number][
|
|
1893
|
+
- `sec` **[number][10]** number of second to wait.
|
|
1854
1894
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1855
1895
|
|
|
1856
1896
|
### waitForClickable
|
|
@@ -1867,7 +1907,7 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
|
1867
1907
|
|
|
1868
1908
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1869
1909
|
- `waitTimeout`
|
|
1870
|
-
- `sec` **[number][
|
|
1910
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1871
1911
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1872
1912
|
|
|
1873
1913
|
### waitForDetached
|
|
@@ -1882,7 +1922,7 @@ I.waitForDetached('#popup');
|
|
|
1882
1922
|
#### Parameters
|
|
1883
1923
|
|
|
1884
1924
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1885
|
-
- `sec` **[number][
|
|
1925
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1886
1926
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1887
1927
|
|
|
1888
1928
|
### waitForElement
|
|
@@ -1898,7 +1938,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
1898
1938
|
#### Parameters
|
|
1899
1939
|
|
|
1900
1940
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1901
|
-
- `sec` **[number][
|
|
1941
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1902
1942
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1903
1943
|
|
|
1904
1944
|
|
|
@@ -1913,7 +1953,7 @@ Element can be located by CSS or XPath.
|
|
|
1913
1953
|
#### Parameters
|
|
1914
1954
|
|
|
1915
1955
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1916
|
-
- `sec` **[number][
|
|
1956
|
+
- `sec` **[number][10]** (optional) time in seconds to wait, 1 by default.
|
|
1917
1957
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1918
1958
|
|
|
1919
1959
|
### waitForFunction
|
|
@@ -1933,9 +1973,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
1933
1973
|
|
|
1934
1974
|
#### Parameters
|
|
1935
1975
|
|
|
1936
|
-
- `fn` **([string][6] | [function][
|
|
1937
|
-
- `argsOrSec` **([Array][
|
|
1938
|
-
- `sec` **[number][
|
|
1976
|
+
- `fn` **([string][6] | [function][12])** to be executed in browser context.
|
|
1977
|
+
- `argsOrSec` **([Array][15]<any> | [number][10])?** (optional, `1` by default) arguments for function or seconds.
|
|
1978
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1939
1979
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1940
1980
|
|
|
1941
1981
|
### waitForInvisible
|
|
@@ -1950,14 +1990,14 @@ I.waitForInvisible('#popup');
|
|
|
1950
1990
|
#### Parameters
|
|
1951
1991
|
|
|
1952
1992
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1953
|
-
- `sec` **[number][
|
|
1993
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1954
1994
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
1955
1995
|
|
|
1956
1996
|
### waitForNavigation
|
|
1957
1997
|
|
|
1958
1998
|
Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
1959
1999
|
|
|
1960
|
-
See [Pupeteer's reference][
|
|
2000
|
+
See [Pupeteer's reference][23]
|
|
1961
2001
|
|
|
1962
2002
|
#### Parameters
|
|
1963
2003
|
|
|
@@ -1974,8 +2014,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
1974
2014
|
|
|
1975
2015
|
#### Parameters
|
|
1976
2016
|
|
|
1977
|
-
- `urlOrPredicate` **([string][6] | [function][
|
|
1978
|
-
- `sec` **[number][
|
|
2017
|
+
- `urlOrPredicate` **([string][6] | [function][12])**
|
|
2018
|
+
- `sec` **[number][10]?** seconds to wait
|
|
1979
2019
|
|
|
1980
2020
|
### waitForResponse
|
|
1981
2021
|
|
|
@@ -1988,8 +2028,8 @@ I.waitForResponse(response => response.url() === 'http://example.com' && respons
|
|
|
1988
2028
|
|
|
1989
2029
|
#### Parameters
|
|
1990
2030
|
|
|
1991
|
-
- `urlOrPredicate` **([string][6] | [function][
|
|
1992
|
-
- `sec` **[number][
|
|
2031
|
+
- `urlOrPredicate` **([string][6] | [function][12])**
|
|
2032
|
+
- `sec` **[number][10]?** number of seconds to wait
|
|
1993
2033
|
|
|
1994
2034
|
### waitForText
|
|
1995
2035
|
|
|
@@ -2005,7 +2045,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
2005
2045
|
#### Parameters
|
|
2006
2046
|
|
|
2007
2047
|
- `text` **[string][6]** to wait for.
|
|
2008
|
-
- `sec` **[number][
|
|
2048
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2009
2049
|
- `context` **([string][6] | [object][4])?** (optional) element located by CSS|XPath|strict locator.
|
|
2010
2050
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2011
2051
|
|
|
@@ -2021,7 +2061,7 @@ I.waitForValue('//input', "GoodValue");
|
|
|
2021
2061
|
|
|
2022
2062
|
- `field` **([string][6] | [object][4])** input field.
|
|
2023
2063
|
- `value` **[string][6]** expected value.
|
|
2024
|
-
- `sec` **[number][
|
|
2064
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2025
2065
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2026
2066
|
|
|
2027
2067
|
### waitForVisible
|
|
@@ -2036,8 +2076,8 @@ I.waitForVisible('#popup');
|
|
|
2036
2076
|
#### Parameters
|
|
2037
2077
|
|
|
2038
2078
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2039
|
-
- `sec` **[number][
|
|
2040
|
-
⚠️ returns a _promise_ which is synchronized internally by recorderThis method accepts [React selectors][
|
|
2079
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2080
|
+
⚠️ returns a _promise_ which is synchronized internally by recorderThis method accepts [React selectors][24].
|
|
2041
2081
|
|
|
2042
2082
|
### waitInUrl
|
|
2043
2083
|
|
|
@@ -2050,7 +2090,7 @@ I.waitInUrl('/info', 2);
|
|
|
2050
2090
|
#### Parameters
|
|
2051
2091
|
|
|
2052
2092
|
- `urlPart` **[string][6]** value to check.
|
|
2053
|
-
- `sec` **[number][
|
|
2093
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2054
2094
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2055
2095
|
|
|
2056
2096
|
### waitNumberOfVisibleElements
|
|
@@ -2064,8 +2104,8 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
2064
2104
|
#### Parameters
|
|
2065
2105
|
|
|
2066
2106
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2067
|
-
- `num` **[number][
|
|
2068
|
-
- `sec` **[number][
|
|
2107
|
+
- `num` **[number][10]** number of elements.
|
|
2108
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2069
2109
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2070
2110
|
|
|
2071
2111
|
|
|
@@ -2084,7 +2124,7 @@ I.waitToHide('#popup');
|
|
|
2084
2124
|
#### Parameters
|
|
2085
2125
|
|
|
2086
2126
|
- `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
|
|
2087
|
-
- `sec` **[number][
|
|
2127
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2088
2128
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2089
2129
|
|
|
2090
2130
|
### waitUrlEquals
|
|
@@ -2099,7 +2139,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2099
2139
|
#### Parameters
|
|
2100
2140
|
|
|
2101
2141
|
- `urlPart` **[string][6]** value to check.
|
|
2102
|
-
- `sec` **[number][
|
|
2142
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
2103
2143
|
⚠️ returns a _promise_ which is synchronized internally by recorder
|
|
2104
2144
|
|
|
2105
2145
|
[1]: https://github.com/GoogleChrome/puppeteer
|
|
@@ -2116,32 +2156,38 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2116
2156
|
|
|
2117
2157
|
[7]: https://github.com/puppeteer/puppeteer/issues/5420
|
|
2118
2158
|
|
|
2119
|
-
[8]: https://developer.mozilla.org/docs/Web/
|
|
2159
|
+
[8]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2160
|
+
|
|
2161
|
+
[9]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2162
|
+
|
|
2163
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2164
|
+
|
|
2165
|
+
[11]: https://vuejs.org/v2/api/#Vue-nextTick
|
|
2120
2166
|
|
|
2121
|
-
[
|
|
2167
|
+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
2122
2168
|
|
|
2123
|
-
[
|
|
2169
|
+
[13]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
2124
2170
|
|
|
2125
|
-
[
|
|
2171
|
+
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2126
2172
|
|
|
2127
|
-
[
|
|
2173
|
+
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
2128
2174
|
|
|
2129
|
-
[
|
|
2175
|
+
[16]: https://codecept.io/helpers/FileSystem
|
|
2130
2176
|
|
|
2131
|
-
[
|
|
2177
|
+
[17]: #fillfield
|
|
2132
2178
|
|
|
2133
|
-
[
|
|
2179
|
+
[18]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
2134
2180
|
|
|
2135
|
-
[
|
|
2181
|
+
[19]: #click
|
|
2136
2182
|
|
|
2137
|
-
[
|
|
2183
|
+
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2138
2184
|
|
|
2139
|
-
[
|
|
2185
|
+
[21]: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-page
|
|
2140
2186
|
|
|
2141
|
-
[
|
|
2187
|
+
[22]: https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browser
|
|
2142
2188
|
|
|
2143
|
-
[
|
|
2189
|
+
[23]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions
|
|
2144
2190
|
|
|
2145
|
-
[
|
|
2191
|
+
[24]: https://codecept.io/react
|
|
2146
2192
|
|
|
2147
|
-
[
|
|
2193
|
+
[25]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
|