Skip to content

Commit 8ed0113

Browse files
committed
Merge branch 'master' of github.com:Codeception/CodeceptJS
2 parents f7aede0 + eb12916 commit 8ed0113

22 files changed

+293
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ testpullfilecache*
1414
.DS_Store
1515
package-lock.json
1616
yarn.lock
17+
/.vs

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.3.2
2+
3+
* Interactve Shell improvements for `pause()`
4+
* Added `next` command for **step-by-step debug** when using `pause()`.
5+
* Use `After(pause);` in a to start interactive console after last step.
6+
7+
18
## 1.3.1
29

310
* BDD-Gherkin: Fixed running async steps.

docs/basics.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ This also launches interactive console where you can call actions of `I` object.
5858

5959
You can also use `pause()` to check the web application in a browser. Press `ENTER` to resume test execution.
6060

61-
Interactive shell can be started outside test context by running
61+
To **debug test step-by-step** type `next` and press Enter. The next step will be executed and interactive shell will be shown again.
62+
63+
To see all available commands press TAB two times to see list of all actions included in I.
64+
65+
If a test is failing you can prevent browser from closing by putting `pause()` command into `After()` hook. This is very helpful to debug failing tests. This way you can keep the same session and try different actions on a page to get the idea what went wrong.
66+
67+
```js
68+
After(pause);
69+
```
70+
71+
Interactive shell can be started outside the test context by running
6272

6373
```bash
6474
codeceptjs shell

docs/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ exports.config = {
5252

5353
// don't build monolithic configs
5454
mocha: require('./mocha.conf.js') || {},
55-
includes: {
55+
include: {
56+
I: './src/steps_file.js',
5657
loginPage: './src/pages/login_page',
5758
dashboardPage: new DashboardPage()
5859
}

docs/helpers/Nightmare.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ First parameter can be set to `maximize`
532532
## saveScreenshot
533533

534534
Saves a screenshot to ouput folder (set in codecept.json).
535-
Filename is relative to output folder.
535+
Filename is relative to output folder.
536536
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
537537

538538
```js
@@ -835,9 +835,14 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
835835
Waits for a function to return true (waits for 1 sec by default).
836836
Running in browser context.
837837

838+
```js
839+
I.waitForFunction(fn[, [args[, timeout]])
840+
```
841+
838842
```js
839843
I.waitForFunction(() => window.requests == 0);
840844
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
845+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
841846
```
842847

843848
**Parameters**

docs/helpers/Protractor.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ Performs right click on an element matched by CSS or XPath.
775775
## saveScreenshot
776776

777777
Saves a screenshot to ouput folder (set in codecept.json).
778-
Filename is relative to output folder.
778+
Filename is relative to output folder.
779779
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
780780

781781
```js
@@ -1180,9 +1180,14 @@ Element can be located by CSS or XPath.
11801180
Waits for a function to return true (waits for 1 sec by default).
11811181
Running in browser context.
11821182

1183+
```js
1184+
I.waitForFunction(fn[, [args[, timeout]])
1185+
```
1186+
11831187
```js
11841188
I.waitForFunction(() => window.requests == 0);
11851189
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1190+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
11861191
```
11871192

11881193
**Parameters**

docs/helpers/Puppeteer.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ Performs right click on an element matched by CSS or XPath.
771771
## saveScreenshot
772772

773773
Saves a screenshot to ouput folder (set in codecept.json).
774-
Filename is relative to output folder.
774+
Filename is relative to output folder.
775775
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
776776

777777
```js
@@ -1163,9 +1163,14 @@ Element can be located by CSS or XPath.
11631163
Waits for a function to return true (waits for 1 sec by default).
11641164
Running in browser context.
11651165

1166+
```js
1167+
I.waitForFunction(fn[, [args[, timeout]])
1168+
```
1169+
11661170
```js
11671171
I.waitForFunction(() => window.requests == 0);
11681172
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1173+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
11691174
```
11701175

11711176
**Parameters**
@@ -1194,7 +1199,7 @@ See [Pupeteer's reference](https://github.com/GoogleChrome/puppeteer/blob/master
11941199

11951200
**Parameters**
11961201

1197-
- `opts` **Any**
1202+
- `opts` **Any**
11981203

11991204
## waitForText
12001205

docs/helpers/WebDriverIO.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ placeholder for ~ locator only test case write once run on both Appium and WebDr
878878
## saveScreenshot
879879
880880
Saves a screenshot to ouput folder (set in codecept.json).
881-
Filename is relative to output folder.
881+
Filename is relative to output folder.
882882
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
883883
884884
```js
@@ -1301,9 +1301,14 @@ Element can be located by CSS or XPath.
13011301
Waits for a function to return true (waits for 1 sec by default).
13021302
Running in browser context.
13031303
1304+
```js
1305+
I.waitForFunction(fn[, [args[, timeout]])
1306+
```
1307+
13041308
```js
13051309
I.waitForFunction(() => window.requests == 0);
13061310
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1311+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
13071312
```
13081313
13091314
**Parameters**

docs/pageobjects.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,34 @@ module.exports = {
145145
}
146146
```
147147

148+
To use a Page Fragment within a Test Scenario just inject it into your Scenario:
149+
150+
```js
151+
Scenario('failed_login', async (I, loginPage, modal) => {
152+
loginPage.sendForm('john@doe.com','wrong password');
153+
I.waitForVisible(modal.root);
154+
within(modal.root, function () {
155+
I.see('Login failed');
156+
})
157+
});
158+
```
159+
160+
To use a Page Fragment within a Page Object, you need to `require` it on top of the Page Object file:
161+
162+
```js
163+
const I = actor();
164+
const modal = require('../fragments/modal');
165+
166+
module.exports = {
167+
doStuff() {
168+
...
169+
modal.accept();
170+
...
171+
}
172+
}
173+
174+
```
175+
148176
## StepObjects
149177

150178
StepObjects represent complex actions which involve usage of multiple web pages. For instance, creating users in backend, changing permissions, etc.

docs/webapi/waitForFunction.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
Waits for a function to return true (waits for 1 sec by default).
22
Running in browser context.
33

4+
```js
5+
I.waitForFunction(fn[, [args[, timeout]])
6+
```
7+
48
```js
59
I.waitForFunction(() => window.requests == 0);
610
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
11+
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
712
```
813

914
@param function to be executed in browser context
10-
@param sec time seconds to wait, 1 by default
15+
@param args arguments for function
16+
@param sec time seconds to wait, 1 by default

0 commit comments

Comments
 (0)