codeceptjs 2.4.3 → 2.6.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 +117 -0
- package/README.md +32 -7
- package/bin/codecept.js +3 -0
- package/docs/basics.md +11 -5
- package/docs/bdd.md +4 -4
- package/docs/build/MockRequest.js +3 -0
- package/docs/build/Nightmare.js +10 -2
- package/docs/build/Playwright.js +3187 -0
- package/docs/build/Protractor.js +16 -2
- package/docs/build/Puppeteer.js +126 -19
- package/docs/build/REST.js +3 -1
- package/docs/build/TestCafe.js +11 -3
- package/docs/build/WebDriver.js +361 -28
- package/docs/changelog.md +116 -0
- package/docs/configuration.md +2 -2
- package/docs/custom-helpers.md +55 -10
- package/docs/helpers/Appium.md +81 -1
- package/docs/helpers/MockRequest.md +281 -38
- package/docs/helpers/Nightmare.md +10 -2
- package/docs/helpers/Playwright.md +1770 -0
- package/docs/helpers/Protractor.md +15 -3
- package/docs/helpers/Puppeteer-firefox.md +32 -1
- package/docs/helpers/Puppeteer.md +126 -76
- package/docs/helpers/TestCafe.md +10 -2
- package/docs/helpers/WebDriver.md +208 -118
- package/docs/locators.md +2 -0
- package/docs/playwright.md +306 -0
- package/docs/plugins.md +103 -0
- package/docs/reports.md +12 -0
- package/docs/shadow.md +68 -0
- package/docs/visual.md +0 -73
- package/docs/webapi/forceClick.mustache +27 -0
- package/docs/webapi/seeInPopup.mustache +7 -0
- package/docs/webapi/setCookie.mustache +10 -2
- package/docs/webapi/type.mustache +12 -0
- package/docs/webdriver.md +7 -3
- package/lib/codecept.js +1 -1
- package/lib/command/definitions.js +2 -2
- package/lib/command/generate.js +4 -4
- package/lib/command/gherkin/snippets.js +4 -4
- package/lib/command/init.js +1 -1
- package/lib/command/interactive.js +3 -0
- package/lib/command/run-multiple.js +2 -2
- package/lib/command/run-rerun.js +2 -0
- package/lib/command/run-workers.js +22 -8
- package/lib/command/run.js +2 -0
- package/lib/command/workers/runTests.js +1 -0
- package/lib/container.js +1 -1
- package/lib/event.js +2 -0
- package/lib/helper/MockRequest.js +3 -0
- package/lib/helper/Playwright.js +2422 -0
- package/lib/helper/Protractor.js +1 -2
- package/lib/helper/Puppeteer.js +84 -19
- package/lib/helper/REST.js +3 -1
- package/lib/helper/TestCafe.js +1 -1
- package/lib/helper/WebDriver.js +313 -26
- package/lib/helper/extras/PlaywrightPropEngine.js +53 -0
- package/lib/helper/scripts/isElementClickable.js +54 -14
- package/lib/interfaces/gherkin.js +1 -1
- package/lib/listener/helpers.js +3 -0
- package/lib/locator.js +5 -0
- package/lib/mochaFactory.js +12 -10
- package/lib/plugin/allure.js +8 -1
- package/lib/plugin/autoDelay.js +1 -8
- package/lib/plugin/commentStep.js +133 -0
- package/lib/plugin/screenshotOnFail.js +3 -10
- package/lib/plugin/selenoid.js +2 -2
- package/lib/plugin/standardActingHelpers.js +13 -0
- package/lib/plugin/stepByStepReport.js +1 -8
- package/lib/plugin/wdio.js +10 -1
- package/lib/reporter/cli.js +30 -1
- package/lib/session.js +7 -4
- package/package.json +13 -10
- package/typings/Mocha.d.ts +567 -16
- package/typings/index.d.ts +9 -5
- package/typings/types.d.ts +1634 -74
|
@@ -1094,9 +1094,13 @@ I.seeInField('#searchform input','Search');
|
|
|
1094
1094
|
Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1095
1095
|
given string.
|
|
1096
1096
|
|
|
1097
|
+
```js
|
|
1098
|
+
I.seeInPopup('Popup text');
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1097
1101
|
#### Parameters
|
|
1098
1102
|
|
|
1099
|
-
- `text`
|
|
1103
|
+
- `text` **[string][9]** value to check.
|
|
1100
1104
|
|
|
1101
1105
|
### seeInSource
|
|
1102
1106
|
|
|
@@ -1203,15 +1207,23 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1203
1207
|
|
|
1204
1208
|
### setCookie
|
|
1205
1209
|
|
|
1206
|
-
Sets
|
|
1210
|
+
Sets cookie(s).
|
|
1211
|
+
|
|
1212
|
+
Can be a single cookie object or an array of cookies:
|
|
1207
1213
|
|
|
1208
1214
|
```js
|
|
1209
1215
|
I.setCookie({name: 'auth', value: true});
|
|
1216
|
+
|
|
1217
|
+
// as array
|
|
1218
|
+
I.setCookie([
|
|
1219
|
+
{name: 'auth', value: true},
|
|
1220
|
+
{name: 'agree', value: true}
|
|
1221
|
+
]);
|
|
1210
1222
|
```
|
|
1211
1223
|
|
|
1212
1224
|
#### Parameters
|
|
1213
1225
|
|
|
1214
|
-
- `cookie` **[object][10]** a cookie object.
|
|
1226
|
+
- `cookie` **([object][10] | [array][14])** a cookie object or array of cookie objects.
|
|
1215
1227
|
|
|
1216
1228
|
### switchTo
|
|
1217
1229
|
|
|
@@ -21,7 +21,7 @@ If you want to use puppeteer-firefox, you should add it in Puppeteer section in
|
|
|
21
21
|
```js
|
|
22
22
|
helpers: {
|
|
23
23
|
Puppeteer: {
|
|
24
|
-
browser: process.env.BROWSER || 'firefox',
|
|
24
|
+
browser: process.env.BROWSER || 'firefox',
|
|
25
25
|
url: process.env.BASE_URL || 'https://example.com',
|
|
26
26
|
chrome: {
|
|
27
27
|
args: [
|
|
@@ -39,6 +39,7 @@ helpers: {
|
|
|
39
39
|
## Run-multiple
|
|
40
40
|
|
|
41
41
|
Example multiple section in codecept.conf.js:
|
|
42
|
+
|
|
42
43
|
```js
|
|
43
44
|
multiple: {
|
|
44
45
|
parallel: {
|
|
@@ -53,3 +54,33 @@ Example multiple section in codecept.conf.js:
|
|
|
53
54
|
},
|
|
54
55
|
},
|
|
55
56
|
```
|
|
57
|
+
|
|
58
|
+
## Puppeteer v2.1.0 onwards
|
|
59
|
+
|
|
60
|
+
Historically, Puppeteer supported Firefox indirectly through puppeteer-firefox, which relied on a custom, patched version of Firefox. This approach was also known as “Juggler”. After discussions with Mozilla, we collectively concluded that relying on custom patches was infeasible. Since then, we have been collaborating with Mozilla on supporting Puppeteer on “stock” Firefox. From Puppeteer v2.1.0 onwards, as an experimental feature, you can specify puppeteer.launch({product: 'firefox'}) to run your Puppeteer scripts in Firefox Nightly, without any additional custom patches.
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npm i puppeteer@v2.1.0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If you want to try this expirement within CodeceptJS, you should add it in Puppeteer section in codecept.conf.js.
|
|
67
|
+
|
|
68
|
+
- browser: 'chrome' OR 'firefox', 'chrome' is default value
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
helpers: {
|
|
72
|
+
Puppeteer: {
|
|
73
|
+
browser: process.env.BROWSER || 'firefox',
|
|
74
|
+
url: process.env.BASE_URL || 'https://example.com',
|
|
75
|
+
chrome: {
|
|
76
|
+
args: [
|
|
77
|
+
'--ignore-certificate-errors',
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
firefox: {
|
|
81
|
+
args: [
|
|
82
|
+
'--ignore-certificate-errors'
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
```
|
|
@@ -287,7 +287,7 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
287
287
|
#### Parameters
|
|
288
288
|
|
|
289
289
|
- `locator` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
290
|
-
- `pathToFile` **[string][8]** local file path relative to codecept.json config file.
|
|
290
|
+
- `pathToFile` **[string][8]** local file path relative to codecept.json config file.> ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][9], downgrade to 2.0.0 if you face it.
|
|
291
291
|
|
|
292
292
|
### cancelPopup
|
|
293
293
|
|
|
@@ -601,7 +601,7 @@ I.dragSlider('#slider', -70);
|
|
|
601
601
|
#### Parameters
|
|
602
602
|
|
|
603
603
|
- `locator` **([string][8] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
604
|
-
- `offsetX` **[number][
|
|
604
|
+
- `offsetX` **[number][10]** position to drag.
|
|
605
605
|
|
|
606
606
|
|
|
607
607
|
|
|
@@ -613,7 +613,7 @@ This action supports [React locators](https://codecept.io/react#locators)
|
|
|
613
613
|
Executes async script on page.
|
|
614
614
|
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
615
615
|
|
|
616
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][
|
|
616
|
+
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][11].
|
|
617
617
|
|
|
618
618
|
```js
|
|
619
619
|
I.executeAsyncScript(function(done) {
|
|
@@ -633,10 +633,10 @@ let val = await I.executeAsyncScript(function(url, done) {
|
|
|
633
633
|
|
|
634
634
|
#### Parameters
|
|
635
635
|
|
|
636
|
-
- `fn` **([string][8] | [function][
|
|
636
|
+
- `fn` **([string][8] | [function][12])** function to be executed in browser context.
|
|
637
637
|
- `args` **...any** to be passed to function.
|
|
638
638
|
|
|
639
|
-
Returns **[Promise][
|
|
639
|
+
Returns **[Promise][13]<any>** Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
|
|
640
640
|
|
|
641
641
|
### executeScript
|
|
642
642
|
|
|
@@ -666,10 +666,10 @@ let date = await I.executeScript(function(el) {
|
|
|
666
666
|
|
|
667
667
|
#### Parameters
|
|
668
668
|
|
|
669
|
-
- `fn` **([string][8] | [function][
|
|
669
|
+
- `fn` **([string][8] | [function][12])** function to be executed in browser context.
|
|
670
670
|
- `args` **...any** to be passed to function.
|
|
671
671
|
|
|
672
|
-
Returns **[Promise][
|
|
672
|
+
Returns **[Promise][13]<any>** If a function returns a Promise It will wait for it resolution.
|
|
673
673
|
|
|
674
674
|
### fillField
|
|
675
675
|
|
|
@@ -696,6 +696,42 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
696
696
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
697
697
|
|
|
698
698
|
|
|
699
|
+
### forceClick
|
|
700
|
+
|
|
701
|
+
Perform an emulated click on a link or a button, given by a locator.
|
|
702
|
+
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
703
|
+
This works on hidden, animated or inactive elements as well.
|
|
704
|
+
|
|
705
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
706
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
707
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
708
|
+
|
|
709
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
710
|
+
|
|
711
|
+
```js
|
|
712
|
+
// simple link
|
|
713
|
+
I.forceClick('Logout');
|
|
714
|
+
// button of form
|
|
715
|
+
I.forceClick('Submit');
|
|
716
|
+
// CSS button
|
|
717
|
+
I.forceClick('#form input[type=submit]');
|
|
718
|
+
// XPath
|
|
719
|
+
I.forceClick('//form/*[@type=submit]');
|
|
720
|
+
// link in context
|
|
721
|
+
I.forceClick('Logout', '#nav');
|
|
722
|
+
// using strict locator
|
|
723
|
+
I.forceClick({css: 'nav a.login'});
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
#### Parameters
|
|
727
|
+
|
|
728
|
+
- `locator` **([string][8] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
729
|
+
- `context` **([string][8]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
This action supports [React locators](https://codecept.io/react#locators)
|
|
733
|
+
|
|
734
|
+
|
|
699
735
|
### grabAttributeFrom
|
|
700
736
|
|
|
701
737
|
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
@@ -711,7 +747,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
711
747
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
712
748
|
- `attr` **[string][8]** attribute name.
|
|
713
749
|
|
|
714
|
-
Returns **[Promise][
|
|
750
|
+
Returns **[Promise][13]<[string][8]>** attribute value
|
|
715
751
|
|
|
716
752
|
|
|
717
753
|
|
|
@@ -727,7 +763,7 @@ let logs = await I.grabBrowserLogs();
|
|
|
727
763
|
console.log(JSON.stringify(logs))
|
|
728
764
|
```
|
|
729
765
|
|
|
730
|
-
Returns **[Promise][
|
|
766
|
+
Returns **[Promise][13]<[Array][14]<any>>**
|
|
731
767
|
|
|
732
768
|
### grabCookie
|
|
733
769
|
|
|
@@ -744,7 +780,7 @@ assert(cookie.value, '123456');
|
|
|
744
780
|
|
|
745
781
|
- `name` **[string][8]?** cookie name.
|
|
746
782
|
|
|
747
|
-
Returns **[Promise][
|
|
783
|
+
Returns **[Promise][13]<[string][8]>** attribute valueReturns cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
748
784
|
|
|
749
785
|
### grabCssPropertyFrom
|
|
750
786
|
|
|
@@ -760,7 +796,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
760
796
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
761
797
|
- `cssProperty` **[string][8]** CSS property name.
|
|
762
798
|
|
|
763
|
-
Returns **[Promise][
|
|
799
|
+
Returns **[Promise][13]<[string][8]>** CSS value
|
|
764
800
|
|
|
765
801
|
|
|
766
802
|
|
|
@@ -777,7 +813,7 @@ let url = await I.grabCurrentUrl();
|
|
|
777
813
|
console.log(`Current URL is [${url}]`);
|
|
778
814
|
```
|
|
779
815
|
|
|
780
|
-
Returns **[Promise][
|
|
816
|
+
Returns **[Promise][13]<[string][8]>** current URL
|
|
781
817
|
|
|
782
818
|
### grabDataFromPerformanceTiming
|
|
783
819
|
|
|
@@ -845,7 +881,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
845
881
|
- `locator`
|
|
846
882
|
- `element` **([string][8] | [object][6])** located by CSS|XPath|strict locator.
|
|
847
883
|
|
|
848
|
-
Returns **[Promise][
|
|
884
|
+
Returns **[Promise][13]<[string][8]>** HTML code for an element
|
|
849
885
|
|
|
850
886
|
### grabNumberOfOpenTabs
|
|
851
887
|
|
|
@@ -855,7 +891,7 @@ Grab number of open tabs.
|
|
|
855
891
|
let tabs = await I.grabNumberOfOpenTabs();
|
|
856
892
|
```
|
|
857
893
|
|
|
858
|
-
Returns **[Promise][
|
|
894
|
+
Returns **[Promise][13]<[number][10]>** number of open tabs
|
|
859
895
|
|
|
860
896
|
### grabNumberOfVisibleElements
|
|
861
897
|
|
|
@@ -869,7 +905,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
869
905
|
|
|
870
906
|
- `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator.
|
|
871
907
|
|
|
872
|
-
Returns **[Promise][
|
|
908
|
+
Returns **[Promise][13]<[number][10]>** number of visible elements
|
|
873
909
|
|
|
874
910
|
|
|
875
911
|
|
|
@@ -885,7 +921,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
885
921
|
let { x, y } = await I.grabPageScrollPosition();
|
|
886
922
|
```
|
|
887
923
|
|
|
888
|
-
Returns **[Promise][
|
|
924
|
+
Returns **[Promise][13]<[Object][6]<[string][8], any>>** scroll position
|
|
889
925
|
|
|
890
926
|
### grabPopupText
|
|
891
927
|
|
|
@@ -895,7 +931,7 @@ Grab the text within the popup. If no popup is visible then it will return null
|
|
|
895
931
|
await I.grabPopupText();
|
|
896
932
|
```
|
|
897
933
|
|
|
898
|
-
Returns **[Promise][
|
|
934
|
+
Returns **[Promise][13]<([string][8] | null)>**
|
|
899
935
|
|
|
900
936
|
### grabSource
|
|
901
937
|
|
|
@@ -906,7 +942,7 @@ Resumes test execution, so should be used inside an async function.
|
|
|
906
942
|
let pageSource = await I.grabSource();
|
|
907
943
|
```
|
|
908
944
|
|
|
909
|
-
Returns **[Promise][
|
|
945
|
+
Returns **[Promise][13]<[string][8]>** source code
|
|
910
946
|
|
|
911
947
|
### grabTextFrom
|
|
912
948
|
|
|
@@ -923,7 +959,7 @@ If multiple elements found returns an array of texts.
|
|
|
923
959
|
|
|
924
960
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
925
961
|
|
|
926
|
-
Returns **[Promise][
|
|
962
|
+
Returns **[Promise][13]<([string][8] | [Array][14]<[string][8]>)>** attribute value
|
|
927
963
|
|
|
928
964
|
|
|
929
965
|
|
|
@@ -939,7 +975,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
939
975
|
let title = await I.grabTitle();
|
|
940
976
|
```
|
|
941
977
|
|
|
942
|
-
Returns **[Promise][
|
|
978
|
+
Returns **[Promise][13]<[string][8]>** title
|
|
943
979
|
|
|
944
980
|
### grabValueFrom
|
|
945
981
|
|
|
@@ -954,12 +990,12 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
954
990
|
|
|
955
991
|
- `locator` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
956
992
|
|
|
957
|
-
Returns **[Promise][
|
|
993
|
+
Returns **[Promise][13]<[string][8]>** attribute value
|
|
958
994
|
|
|
959
995
|
### handleDownloads
|
|
960
996
|
|
|
961
997
|
Sets a directory to where save files. Allows to test file downloads.
|
|
962
|
-
Should be used with [FileSystem helper][
|
|
998
|
+
Should be used with [FileSystem helper][15] to check that file were downloaded correctly.
|
|
963
999
|
|
|
964
1000
|
By default files are saved to `output/downloads`.
|
|
965
1001
|
This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
|
|
@@ -1002,8 +1038,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1002
1038
|
#### Parameters
|
|
1003
1039
|
|
|
1004
1040
|
- `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator.
|
|
1005
|
-
- `offsetX` **[number][
|
|
1006
|
-
- `offsetY` **[number][
|
|
1041
|
+
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1042
|
+
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1007
1043
|
|
|
1008
1044
|
|
|
1009
1045
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -1021,7 +1057,7 @@ I.openNewTab();
|
|
|
1021
1057
|
|
|
1022
1058
|
Presses a key in the browser (on a focused element).
|
|
1023
1059
|
|
|
1024
|
-
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][
|
|
1060
|
+
_Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][16].
|
|
1025
1061
|
|
|
1026
1062
|
```js
|
|
1027
1063
|
I.pressKey('Backspace');
|
|
@@ -1080,13 +1116,13 @@ Some of the supported key names are:
|
|
|
1080
1116
|
|
|
1081
1117
|
#### Parameters
|
|
1082
1118
|
|
|
1083
|
-
- `key` **([string][8] | [Array][
|
|
1119
|
+
- `key` **([string][8] | [Array][14]<[string][8]>)** key or array of keys to press._Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][17]).
|
|
1084
1120
|
|
|
1085
1121
|
### pressKeyDown
|
|
1086
1122
|
|
|
1087
1123
|
Presses a key in the browser and leaves it in a down state.
|
|
1088
1124
|
|
|
1089
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1125
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][18]).
|
|
1090
1126
|
|
|
1091
1127
|
```js
|
|
1092
1128
|
I.pressKeyDown('Control');
|
|
@@ -1102,7 +1138,7 @@ I.pressKeyUp('Control');
|
|
|
1102
1138
|
|
|
1103
1139
|
Releases a key in the browser which was previously set to a down state.
|
|
1104
1140
|
|
|
1105
|
-
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][
|
|
1141
|
+
To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][18]).
|
|
1106
1142
|
|
|
1107
1143
|
```js
|
|
1108
1144
|
I.pressKeyDown('Control');
|
|
@@ -1129,8 +1165,8 @@ First parameter can be set to `maximize`.
|
|
|
1129
1165
|
|
|
1130
1166
|
#### Parameters
|
|
1131
1167
|
|
|
1132
|
-
- `width` **[number][
|
|
1133
|
-
- `height` **[number][
|
|
1168
|
+
- `width` **[number][10]** width in pixels or `maximize`.
|
|
1169
|
+
- `height` **[number][10]** height in pixels.Unlike other drivers Puppeteer changes the size of a viewport, not the window!
|
|
1134
1170
|
Puppeteer does not control the window of a browser so it can't adjust its real size.
|
|
1135
1171
|
It also can't maximize a window.
|
|
1136
1172
|
|
|
@@ -1170,7 +1206,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1170
1206
|
#### Parameters
|
|
1171
1207
|
|
|
1172
1208
|
- `fileName` **[string][8]** file name to save.
|
|
1173
|
-
- `fullPage` **[boolean][
|
|
1209
|
+
- `fullPage` **[boolean][19]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1174
1210
|
|
|
1175
1211
|
### scrollPageToBottom
|
|
1176
1212
|
|
|
@@ -1201,8 +1237,8 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1201
1237
|
#### Parameters
|
|
1202
1238
|
|
|
1203
1239
|
- `locator` **([string][8] | [object][6])** located by CSS|XPath|strict locator.
|
|
1204
|
-
- `offsetX` **[number][
|
|
1205
|
-
- `offsetY` **[number][
|
|
1240
|
+
- `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
|
|
1241
|
+
- `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
|
|
1206
1242
|
|
|
1207
1243
|
### see
|
|
1208
1244
|
|
|
@@ -1366,9 +1402,13 @@ I.seeInField('#searchform input','Search');
|
|
|
1366
1402
|
Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1367
1403
|
given string.
|
|
1368
1404
|
|
|
1405
|
+
```js
|
|
1406
|
+
I.seeInPopup('Popup text');
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1369
1409
|
#### Parameters
|
|
1370
1410
|
|
|
1371
|
-
- `text`
|
|
1411
|
+
- `text` **[string][8]** value to check.
|
|
1372
1412
|
|
|
1373
1413
|
### seeInSource
|
|
1374
1414
|
|
|
@@ -1406,7 +1446,7 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
1406
1446
|
#### Parameters
|
|
1407
1447
|
|
|
1408
1448
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1409
|
-
- `num` **[number][
|
|
1449
|
+
- `num` **[number][10]** number of elements.
|
|
1410
1450
|
|
|
1411
1451
|
|
|
1412
1452
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -1424,7 +1464,7 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1424
1464
|
#### Parameters
|
|
1425
1465
|
|
|
1426
1466
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1427
|
-
- `num` **[number][
|
|
1467
|
+
- `num` **[number][10]** number of elements.
|
|
1428
1468
|
|
|
1429
1469
|
|
|
1430
1470
|
This action supports [React locators](https://codecept.io/react#locators)
|
|
@@ -1479,19 +1519,27 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1479
1519
|
#### Parameters
|
|
1480
1520
|
|
|
1481
1521
|
- `select` **([string][8] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1482
|
-
- `option` **([string][8] | [Array][
|
|
1522
|
+
- `option` **([string][8] | [Array][14]<any>)** visible text or value of option.
|
|
1483
1523
|
|
|
1484
1524
|
### setCookie
|
|
1485
1525
|
|
|
1486
|
-
Sets
|
|
1526
|
+
Sets cookie(s).
|
|
1527
|
+
|
|
1528
|
+
Can be a single cookie object or an array of cookies:
|
|
1487
1529
|
|
|
1488
1530
|
```js
|
|
1489
1531
|
I.setCookie({name: 'auth', value: true});
|
|
1532
|
+
|
|
1533
|
+
// as array
|
|
1534
|
+
I.setCookie([
|
|
1535
|
+
{name: 'auth', value: true},
|
|
1536
|
+
{name: 'agree', value: true}
|
|
1537
|
+
]);
|
|
1490
1538
|
```
|
|
1491
1539
|
|
|
1492
1540
|
#### Parameters
|
|
1493
1541
|
|
|
1494
|
-
- `cookie` **[object][6]** a cookie object.
|
|
1542
|
+
- `cookie` **([object][6] | [array][14])** a cookie object or array of cookie objects.
|
|
1495
1543
|
|
|
1496
1544
|
### switchTo
|
|
1497
1545
|
|
|
@@ -1517,7 +1565,7 @@ I.switchToNextTab(2);
|
|
|
1517
1565
|
|
|
1518
1566
|
#### Parameters
|
|
1519
1567
|
|
|
1520
|
-
- `num` **[number][
|
|
1568
|
+
- `num` **[number][10]**
|
|
1521
1569
|
|
|
1522
1570
|
### switchToPreviousTab
|
|
1523
1571
|
|
|
@@ -1530,7 +1578,7 @@ I.switchToPreviousTab(2);
|
|
|
1530
1578
|
|
|
1531
1579
|
#### Parameters
|
|
1532
1580
|
|
|
1533
|
-
- `num` **[number][
|
|
1581
|
+
- `num` **[number][10]**
|
|
1534
1582
|
|
|
1535
1583
|
### uncheckOption
|
|
1536
1584
|
|
|
@@ -1560,7 +1608,7 @@ I.wait(2); // wait 2 secs
|
|
|
1560
1608
|
|
|
1561
1609
|
#### Parameters
|
|
1562
1610
|
|
|
1563
|
-
- `sec` **[number][
|
|
1611
|
+
- `sec` **[number][10]** number of second to wait.
|
|
1564
1612
|
|
|
1565
1613
|
### waitForClickable
|
|
1566
1614
|
|
|
@@ -1576,7 +1624,7 @@ I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
|
1576
1624
|
|
|
1577
1625
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1578
1626
|
- `waitTimeout`
|
|
1579
|
-
- `sec` **[number][
|
|
1627
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1580
1628
|
|
|
1581
1629
|
### waitForDetached
|
|
1582
1630
|
|
|
@@ -1590,7 +1638,7 @@ I.waitForDetached('#popup');
|
|
|
1590
1638
|
#### Parameters
|
|
1591
1639
|
|
|
1592
1640
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1593
|
-
- `sec` **[number][
|
|
1641
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1594
1642
|
|
|
1595
1643
|
### waitForElement
|
|
1596
1644
|
|
|
@@ -1605,7 +1653,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
1605
1653
|
#### Parameters
|
|
1606
1654
|
|
|
1607
1655
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1608
|
-
- `sec` **[number][
|
|
1656
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1609
1657
|
|
|
1610
1658
|
|
|
1611
1659
|
|
|
@@ -1620,7 +1668,7 @@ Element can be located by CSS or XPath.
|
|
|
1620
1668
|
#### Parameters
|
|
1621
1669
|
|
|
1622
1670
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1623
|
-
- `sec` **[number][
|
|
1671
|
+
- `sec` **[number][10]** (optional) time in seconds to wait, 1 by default.
|
|
1624
1672
|
|
|
1625
1673
|
### waitForFunction
|
|
1626
1674
|
|
|
@@ -1639,9 +1687,9 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
1639
1687
|
|
|
1640
1688
|
#### Parameters
|
|
1641
1689
|
|
|
1642
|
-
- `fn` **([string][8] | [function][
|
|
1643
|
-
- `argsOrSec` **([Array][
|
|
1644
|
-
- `sec` **[number][
|
|
1690
|
+
- `fn` **([string][8] | [function][12])** to be executed in browser context.
|
|
1691
|
+
- `argsOrSec` **([Array][14]<any> | [number][10])?** (optional, `1` by default) arguments for function or seconds.
|
|
1692
|
+
- `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait
|
|
1645
1693
|
|
|
1646
1694
|
### waitForInvisible
|
|
1647
1695
|
|
|
@@ -1655,7 +1703,7 @@ I.waitForInvisible('#popup');
|
|
|
1655
1703
|
#### Parameters
|
|
1656
1704
|
|
|
1657
1705
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1658
|
-
- `sec` **[number][
|
|
1706
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1659
1707
|
|
|
1660
1708
|
### waitForNavigation
|
|
1661
1709
|
|
|
@@ -1678,8 +1726,8 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
1678
1726
|
|
|
1679
1727
|
#### Parameters
|
|
1680
1728
|
|
|
1681
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
1682
|
-
- `sec` **[number][
|
|
1729
|
+
- `urlOrPredicate` **([string][8] | [function][12])**
|
|
1730
|
+
- `sec` **[number][10]?** seconds to wait
|
|
1683
1731
|
|
|
1684
1732
|
### waitForResponse
|
|
1685
1733
|
|
|
@@ -1692,8 +1740,8 @@ I.waitForResponse(request => request.url() === 'http://example.com' && request.m
|
|
|
1692
1740
|
|
|
1693
1741
|
#### Parameters
|
|
1694
1742
|
|
|
1695
|
-
- `urlOrPredicate` **([string][8] | [function][
|
|
1696
|
-
- `sec` **[number][
|
|
1743
|
+
- `urlOrPredicate` **([string][8] | [function][12])**
|
|
1744
|
+
- `sec` **[number][10]?** number of seconds to wait
|
|
1697
1745
|
|
|
1698
1746
|
### waitForText
|
|
1699
1747
|
|
|
@@ -1709,7 +1757,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
1709
1757
|
#### Parameters
|
|
1710
1758
|
|
|
1711
1759
|
- `text` **[string][8]** to wait for.
|
|
1712
|
-
- `sec` **[number][
|
|
1760
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1713
1761
|
- `context` **([string][8] | [object][6])?** (optional) element located by CSS|XPath|strict locator.
|
|
1714
1762
|
|
|
1715
1763
|
### waitForValue
|
|
@@ -1724,7 +1772,7 @@ I.waitForValue('//input', "GoodValue");
|
|
|
1724
1772
|
|
|
1725
1773
|
- `field` **([string][8] | [object][6])** input field.
|
|
1726
1774
|
- `value` **[string][8]** expected value.
|
|
1727
|
-
- `sec` **[number][
|
|
1775
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1728
1776
|
|
|
1729
1777
|
### waitForVisible
|
|
1730
1778
|
|
|
@@ -1738,7 +1786,7 @@ I.waitForVisible('#popup');
|
|
|
1738
1786
|
#### Parameters
|
|
1739
1787
|
|
|
1740
1788
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1741
|
-
- `sec` **[number][
|
|
1789
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to waitThis method accepts [React selectors][20].
|
|
1742
1790
|
|
|
1743
1791
|
### waitInUrl
|
|
1744
1792
|
|
|
@@ -1751,7 +1799,7 @@ I.waitInUrl('/info', 2);
|
|
|
1751
1799
|
#### Parameters
|
|
1752
1800
|
|
|
1753
1801
|
- `urlPart` **[string][8]** value to check.
|
|
1754
|
-
- `sec` **[number][
|
|
1802
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1755
1803
|
|
|
1756
1804
|
### waitNumberOfVisibleElements
|
|
1757
1805
|
|
|
@@ -1764,8 +1812,8 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
1764
1812
|
#### Parameters
|
|
1765
1813
|
|
|
1766
1814
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1767
|
-
- `num` **[number][
|
|
1768
|
-
- `sec` **[number][
|
|
1815
|
+
- `num` **[number][10]** number of elements.
|
|
1816
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1769
1817
|
|
|
1770
1818
|
|
|
1771
1819
|
|
|
@@ -1784,7 +1832,7 @@ I.waitToHide('#popup');
|
|
|
1784
1832
|
#### Parameters
|
|
1785
1833
|
|
|
1786
1834
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1787
|
-
- `sec` **[number][
|
|
1835
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1788
1836
|
|
|
1789
1837
|
### waitUntil
|
|
1790
1838
|
|
|
@@ -1797,10 +1845,10 @@ I.waitUntil(() => window.requests == 0, 5);
|
|
|
1797
1845
|
|
|
1798
1846
|
#### Parameters
|
|
1799
1847
|
|
|
1800
|
-
- `fn` **([function][
|
|
1801
|
-
- `sec` **[number][
|
|
1848
|
+
- `fn` **([function][12] | [string][8])** function which is executed in browser context.
|
|
1849
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1802
1850
|
- `timeoutMsg` **[string][8]** message to show in case of timeout fail.
|
|
1803
|
-
- `interval` **[number][
|
|
1851
|
+
- `interval` **[number][10]?**
|
|
1804
1852
|
|
|
1805
1853
|
### waitUrlEquals
|
|
1806
1854
|
|
|
@@ -1814,7 +1862,7 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
1814
1862
|
#### Parameters
|
|
1815
1863
|
|
|
1816
1864
|
- `urlPart` **[string][8]** value to check.
|
|
1817
|
-
- `sec` **[number][
|
|
1865
|
+
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1818
1866
|
|
|
1819
1867
|
[1]: https://github.com/GoogleChrome/puppeteer
|
|
1820
1868
|
|
|
@@ -1832,24 +1880,26 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
1832
1880
|
|
|
1833
1881
|
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1834
1882
|
|
|
1835
|
-
[9]: https://
|
|
1883
|
+
[9]: https://github.com/puppeteer/puppeteer/issues/5420
|
|
1884
|
+
|
|
1885
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
1836
1886
|
|
|
1837
|
-
[
|
|
1887
|
+
[11]: https://vuejs.org/v2/api/#Vue-nextTick
|
|
1838
1888
|
|
|
1839
|
-
[
|
|
1889
|
+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1840
1890
|
|
|
1841
|
-
[
|
|
1891
|
+
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1842
1892
|
|
|
1843
|
-
[
|
|
1893
|
+
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1844
1894
|
|
|
1845
|
-
[
|
|
1895
|
+
[15]: https://codecept.io/helpers/FileSystem
|
|
1846
1896
|
|
|
1847
|
-
[
|
|
1897
|
+
[16]: #fillfield
|
|
1848
1898
|
|
|
1849
|
-
[
|
|
1899
|
+
[17]: https://github.com/GoogleChrome/puppeteer/issues/1313
|
|
1850
1900
|
|
|
1851
|
-
[
|
|
1901
|
+
[18]: #click
|
|
1852
1902
|
|
|
1853
|
-
[
|
|
1903
|
+
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
1854
1904
|
|
|
1855
|
-
[
|
|
1905
|
+
[20]: https://codecept.io/react
|