codeceptjs 3.1.3 â 3.2.0
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 +49 -1
- package/README.md +2 -3
- package/bin/codecept.js +1 -0
- package/docs/advanced.md +94 -60
- package/docs/basics.md +1 -1
- package/docs/build/FileSystem.js +1 -0
- package/docs/build/Playwright.js +19 -26
- package/docs/build/Protractor.js +9 -24
- package/docs/build/Puppeteer.js +9 -27
- package/docs/build/REST.js +1 -0
- package/docs/build/WebDriver.js +1 -23
- package/docs/changelog.md +49 -1
- package/docs/custom-helpers.md +1 -36
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/FileSystem.md +1 -1
- package/docs/helpers/Playwright.md +16 -18
- package/docs/helpers/Puppeteer.md +1 -17
- package/docs/helpers/REST.md +3 -1
- package/docs/helpers/WebDriver.md +1 -17
- package/docs/mobile-react-native-locators.md +3 -0
- package/docs/plugins.md +125 -0
- package/docs/reports.md +2 -2
- package/lib/actor.js +19 -1
- package/lib/codecept.js +2 -0
- package/lib/command/info.js +1 -1
- package/lib/config.js +12 -0
- package/lib/container.js +3 -1
- package/lib/helper/FileSystem.js +1 -0
- package/lib/helper/Playwright.js +19 -16
- package/lib/helper/Protractor.js +2 -14
- package/lib/helper/Puppeteer.js +2 -17
- package/lib/helper/REST.js +1 -0
- package/lib/helper/WebDriver.js +1 -13
- package/lib/interfaces/featureConfig.js +3 -0
- package/lib/interfaces/scenarioConfig.js +4 -0
- package/lib/listener/steps.js +21 -3
- package/lib/listener/timeout.js +71 -0
- package/lib/locator.js +3 -0
- package/lib/plugin/allure.js +6 -1
- package/lib/plugin/retryTo.js +130 -0
- package/lib/plugin/screenshotOnFail.js +1 -0
- package/lib/plugin/stepByStepReport.js +7 -0
- package/lib/plugin/stepTimeout.js +90 -0
- package/lib/recorder.js +16 -5
- package/lib/step.js +3 -0
- package/lib/store.js +2 -0
- package/lib/ui.js +2 -2
- package/package.json +4 -6
- package/typings/index.d.ts +6 -1
- package/typings/types.d.ts +40 -64
- package/docs/angular.md +0 -325
- package/docs/helpers/Protractor.md +0 -1658
- package/docs/webapi/waitUntil.mustache +0 -11
- package/typings/Protractor.d.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
## 3.2.0
|
|
2
|
+
|
|
3
|
+
đŠī¸ Features:
|
|
4
|
+
|
|
5
|
+
**Timeouts implemented**
|
|
6
|
+
* global timeouts (via `timeout` config option).
|
|
7
|
+
* _Breaking change:_ timeout option expects **timeout in seconds**, not in miliseconds as it was previously.
|
|
8
|
+
* test timeouts (via `Scenario` and `Feature` options)
|
|
9
|
+
* _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// set timeout for every test in suite to 10 secs
|
|
13
|
+
Feature('tests with timeout', { timeout: 10 });
|
|
14
|
+
|
|
15
|
+
// set timeout for this test to 20 secs
|
|
16
|
+
Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
* step timeouts (See #3059 by @nikocanvacom)
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// set step timeout to 5 secs
|
|
23
|
+
I.limitTime(5).click('Link');
|
|
24
|
+
```
|
|
25
|
+
* `stepTimeout` plugin introduced to automatically add timeouts for each step (#3059 by @nikocanvacom).
|
|
26
|
+
|
|
27
|
+
[**retryTo**](/plugins/#retryto) plugin introduced to rerun a set of steps on failure:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// editing in text in iframe
|
|
31
|
+
// if iframe was not loaded - retry 5 times
|
|
32
|
+
await retryTo(() => {
|
|
33
|
+
I.switchTo('#editor frame');
|
|
34
|
+
I.fillField('textarea', 'value');
|
|
35
|
+
}, 5);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
* [Playwright] added `locale` configuration
|
|
39
|
+
* [WebDriver] upgraded to webdriverio v7
|
|
40
|
+
|
|
41
|
+
đ Bugfixes:
|
|
42
|
+
|
|
43
|
+
* Fixed allure plugin "Unexpected endStep()" error in #3098 by @abhimanyupandian
|
|
44
|
+
* [Puppeteer] always close remote browser on test end. See #3054 by @mattonem
|
|
45
|
+
* stepbyStepReport Plugin: Disabled screenshots after test has failed. See #3119 by @ioannisChalkias
|
|
46
|
+
|
|
47
|
+
|
|
1
48
|
## 3.1.3
|
|
2
49
|
|
|
3
50
|
đŠī¸ Features:
|
|
@@ -15,7 +62,7 @@ Given('I have an employee card', (table) => {
|
|
|
15
62
|
// rows = [['Harry', 'Potter', Seeker]];
|
|
16
63
|
}
|
|
17
64
|
```
|
|
18
|
-
See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
65
|
+
See updated [BDD section](https://codecept.io/bdd/) for more API options. Thanks to @EgorBodnar
|
|
19
66
|
|
|
20
67
|
* Support `cjs` file extensions for config file: `codecept.conf.cjs`. See #3052 by @kalvenschraut
|
|
21
68
|
* API updates: Added `test.file` and `suite.file` properties to `test` and `suite` objects to use in helpers and plugins.
|
|
@@ -28,6 +75,7 @@ See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
|
28
75
|
* [Playwright] `I.haveRequestHeaders` affects all tabs. See #3049 by @jancorvus
|
|
29
76
|
* BDD: Fixed unhandled empty feature files. Fix #3046 by @abhimanyupandian
|
|
30
77
|
* Fixed `RangeError: Invalid string length` in `recorder.js` when running huge amount of tests.
|
|
78
|
+
* [Appium] Fixed definitions for `touchPerform`, `hideDeviceKeyboard`, `removeApp` by @mirao
|
|
31
79
|
|
|
32
80
|
đ Documentation:
|
|
33
81
|
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Scenario('check Welcome page on site', ({ I }) => {
|
|
|
29
29
|
|
|
30
30
|
CodeceptJS tests are:
|
|
31
31
|
|
|
32
|
-
* **Synchronous**. You don't need to care about callbacks
|
|
32
|
+
* **Synchronous**. You don't need to care about callbacks or promises or test scenarios which are linear. But, your tests should be linear.
|
|
33
33
|
* Written from **user's perspective**. Every action is a method of `I`. That makes test easy to read, write and maintain even for non-tech persons.
|
|
34
34
|
* Backend **API agnostic**. We don't know which WebDriver implementation is running this test. We can easily switch from WebDriverIO to Protractor or PhantomJS.
|
|
35
35
|
|
|
@@ -38,11 +38,10 @@ CodeceptJS uses **Helper** modules to provide actions to `I` object. Currently C
|
|
|
38
38
|
* [**Playwright**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Playwright.md) - is a Node library to automate the Chromium, WebKit and Firefox browsers with a single API.
|
|
39
39
|
* [**Puppeteer**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Puppeteer.md) - uses Google Chrome's Puppeteer for fast headless testing.
|
|
40
40
|
* [**WebDriver**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/WebDriver.md) - uses [webdriverio](http://webdriver.io/) to run tests via WebDriver protocol.
|
|
41
|
-
* [**Protractor**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Protractor.md) - helper empowered by [Protractor](http://protractortest.org/) to run tests via WebDriver protocol.
|
|
42
41
|
* [**TestCafe**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/TestCafe.md) - cheap and fast cross-browser test automation.
|
|
43
42
|
* [**Nightmare**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Nightmare.md) - uses Electron and NightmareJS to run tests.
|
|
44
43
|
* [**Appium**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Appium.md) - for **mobile testing** with Appium
|
|
45
|
-
* [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library,
|
|
44
|
+
* [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library, aimed to unify testing experience for CodeceptJS framework. Detox provides a grey box testing for mobile applications, playing especially well for React Native apps.
|
|
46
45
|
|
|
47
46
|
And more to come...
|
|
48
47
|
|
package/bin/codecept.js
CHANGED
|
@@ -105,6 +105,7 @@ program.command('run [test]')
|
|
|
105
105
|
.option('-c, --config [file]', 'configuration file to be used')
|
|
106
106
|
.option('--features', 'run only *.feature files and skip tests')
|
|
107
107
|
.option('--tests', 'run only JS test files and skip features')
|
|
108
|
+
.option('--no-timeouts', 'disable all timeouts')
|
|
108
109
|
.option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated')
|
|
109
110
|
|
|
110
111
|
// mocha options
|
package/docs/advanced.md
CHANGED
|
@@ -100,7 +100,7 @@ Scenario('update user profile', ({ }) => {
|
|
|
100
100
|
All tests with `@tag` could be executed with `--grep @tag` option.
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
|
-
codeceptjs run --grep @slow
|
|
103
|
+
npx codeceptjs run --grep @slow
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
Use regex for more flexible filtering:
|
|
@@ -119,24 +119,30 @@ CodeceptJS provides a debug mode in which additional information is printed.
|
|
|
119
119
|
It can be turned on with `--debug` flag.
|
|
120
120
|
|
|
121
121
|
```sh
|
|
122
|
-
codeceptjs run --debug
|
|
122
|
+
npx codeceptjs run --debug
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
to receive even more information turn on `--verbose` flag:
|
|
126
126
|
|
|
127
127
|
```sh
|
|
128
|
-
codeceptjs run --verbose
|
|
128
|
+
npx codeceptjs run --verbose
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
> You can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
To see a complete internal debug of CodeceptJS use `DEBUG` env variable:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
DEBUG=codeceptjs:* npx codeceptjs run
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For an interactive debugging use NodeJS debugger. In **WebStorm**:
|
|
134
140
|
|
|
135
141
|
```sh
|
|
136
142
|
node $NODE_DEBUG_OPTION ./node_modules/.bin/codeceptjs run
|
|
137
143
|
```
|
|
138
144
|
|
|
139
|
-
For Visual Studio Code
|
|
145
|
+
For **Visual Studio Code**, add the following configuration in launch.json:
|
|
140
146
|
|
|
141
147
|
```json
|
|
142
148
|
{
|
|
@@ -180,29 +186,99 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
|
|
|
180
186
|
});
|
|
181
187
|
```
|
|
182
188
|
|
|
183
|
-
### Timeout
|
|
189
|
+
### Timeout <Badge text="Updated in 3.2" type="warning"/>
|
|
184
190
|
|
|
185
|
-
|
|
191
|
+
Tests can get stuck due to various reasons such as network connection issues, crashed browser, etc.
|
|
192
|
+
This can make tests process hang. To prevent these situations timeouts can be used. Timeouts can be set explicitly for flaky parts of code, or implicitly in a config.
|
|
193
|
+
|
|
194
|
+
> Previous timeout implementation was disabled as it had no effect when dealing with steps and promises.
|
|
195
|
+
|
|
196
|
+
### Steps Timeout
|
|
197
|
+
|
|
198
|
+
It is possible to limit a step execution to specified time with `I.limitTime` command.
|
|
199
|
+
It will set timeout in seconds for the next executed step:
|
|
186
200
|
|
|
187
201
|
```js
|
|
188
|
-
|
|
202
|
+
// limit clicking to 5 seconds
|
|
203
|
+
I.limitTime(5).click('Link')
|
|
189
204
|
```
|
|
190
205
|
|
|
191
|
-
|
|
206
|
+
It is possible to set a timeout for all steps implicitly (except waiters) using [stepTimeout plugin](/plugins/#steptimeout).
|
|
207
|
+
|
|
208
|
+
### Tests Timeout
|
|
209
|
+
|
|
210
|
+
Test timeout can be set in seconds via Scenario options:
|
|
192
211
|
|
|
193
212
|
```js
|
|
194
|
-
//
|
|
195
|
-
Scenario(
|
|
196
|
-
//
|
|
197
|
-
})
|
|
213
|
+
// limit test to 20 seconds
|
|
214
|
+
Scenario('slow test that should be stopped', { timeout: 20 }, ({ I }) => {
|
|
215
|
+
// ...
|
|
216
|
+
})
|
|
217
|
+
```
|
|
198
218
|
|
|
199
|
-
|
|
200
|
-
Scenario("Stop me faster", {timeout: 1000},({ I }) => {});
|
|
219
|
+
This timeout can be set globally in `codecept.conf.js` in seconds:
|
|
201
220
|
|
|
202
|
-
|
|
203
|
-
|
|
221
|
+
```js
|
|
222
|
+
exports.config = {
|
|
223
|
+
|
|
224
|
+
// each test must not run longer than 5 mins
|
|
225
|
+
timeout: 300,
|
|
226
|
+
|
|
227
|
+
}
|
|
204
228
|
```
|
|
205
229
|
|
|
230
|
+
### Suites Timeout
|
|
231
|
+
|
|
232
|
+
A timeout for a group of tests can be set on Feature level via options.
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
// limit all tests in this suite to 30 seconds
|
|
236
|
+
Feature('flaky tests', { timeout: 30 })
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Sum Up
|
|
240
|
+
|
|
241
|
+
Let's list all available timeout options.
|
|
242
|
+
|
|
243
|
+
Timeouts can be set globally in config:
|
|
244
|
+
|
|
245
|
+
```js
|
|
246
|
+
// in codecept.confg.js:
|
|
247
|
+
{ // ...
|
|
248
|
+
timeout: 30, // limit all tests in all suites to 30 secs
|
|
249
|
+
|
|
250
|
+
plugins: {
|
|
251
|
+
stepTimeout: {
|
|
252
|
+
enabled: true,
|
|
253
|
+
timeout: 10, // limit all steps except waiters to 10 secs
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
or inside a test file:
|
|
261
|
+
|
|
262
|
+
```js
|
|
263
|
+
// limit all tests in this suite to 10 secs
|
|
264
|
+
Feature('tests with timeout', { timeout: 10 });
|
|
265
|
+
|
|
266
|
+
// limit this test to 20 secs
|
|
267
|
+
Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {
|
|
268
|
+
// limit step to 5 seconds
|
|
269
|
+
I.limitTime(5).click('Link');
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Global timeouts will be overridden by explicit timeouts of a test or steps.
|
|
274
|
+
|
|
275
|
+
### Disable Timeouts
|
|
276
|
+
|
|
277
|
+
To execute tests ignoring all timeout settings use `--no-timeouts` option:
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
npx codeceptjs run --no-timeouts
|
|
281
|
+
```
|
|
206
282
|
|
|
207
283
|
## Dynamic Configuration
|
|
208
284
|
|
|
@@ -249,45 +325,3 @@ Please note that some config changes can't be applied on the fly. For instance,
|
|
|
249
325
|
|
|
250
326
|
Configuration changes will be reverted after a test or a suite.
|
|
251
327
|
|
|
252
|
-
|
|
253
|
-
### Rerunning Flaky Tests Multiple Times <Badge text="Since 2.4" type="warning"/>
|
|
254
|
-
|
|
255
|
-
End to end tests can be flaky for various reasons. Even when we can't do anything to solve this problem it we can do next two things:
|
|
256
|
-
|
|
257
|
-
* Detect flaky tests in our suite
|
|
258
|
-
* Fix flaky tests by rerunning them.
|
|
259
|
-
|
|
260
|
-
Both tasks can be achieved with [`run-rerun` command](/commands/#run-rerun) which runs tests multiple times until all tests are passed.
|
|
261
|
-
|
|
262
|
-
You should set min and max runs boundaries so when few tests fail in a row you can rerun them until they are succeeded.
|
|
263
|
-
|
|
264
|
-
```js
|
|
265
|
-
// inside to codecept.conf.js
|
|
266
|
-
exports.config = { // ...
|
|
267
|
-
rerun: {
|
|
268
|
-
// run 4 times until 1st success
|
|
269
|
-
minSuccess: 1,
|
|
270
|
-
maxReruns: 4,
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
If you want to check all your tests for stability you can set high boundaries for minimal success:
|
|
276
|
-
|
|
277
|
-
```js
|
|
278
|
-
// inside to codecept.conf.js
|
|
279
|
-
exports.config = { // ...
|
|
280
|
-
rerun: {
|
|
281
|
-
// run all tests must pass exactly 5 times
|
|
282
|
-
minSuccess: 5,
|
|
283
|
-
maxReruns: 5,
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Now execute tests with `run-rerun` command:
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
npx codeceptjs run-rerun
|
|
292
|
-
```
|
|
293
|
-
|
package/docs/basics.md
CHANGED
|
@@ -108,7 +108,7 @@ I.seeElement({name: 'password'});
|
|
|
108
108
|
I.seeElement({react: 'user-profile', props: {name: 'davert'}});
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
In [mobile testing](
|
|
111
|
+
In [mobile testing](https://codecept.io/mobile/#locating-elements) you can use `~` to specify the accessibility id to locate an element. In web application you can locate elements by their `aria-label` value.
|
|
112
112
|
|
|
113
113
|
```js
|
|
114
114
|
// locate element by [aria-label] attribute in web
|
package/docs/build/FileSystem.js
CHANGED
package/docs/build/Playwright.js
CHANGED
|
@@ -80,6 +80,7 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
80
80
|
* * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
81
81
|
* * `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
82
82
|
* * `userAgent`: (optional) user-agent string.
|
|
83
|
+
* * `locale`: (optional) locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
83
84
|
* * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
84
85
|
* * `chromium`: (optional) pass additional chromium options
|
|
85
86
|
* * `electron`: (optional) pass additional electron options
|
|
@@ -197,6 +198,19 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
197
198
|
* }
|
|
198
199
|
* ```
|
|
199
200
|
*
|
|
201
|
+
* #### Example #7: Launch test with a specifc user locale
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* {
|
|
205
|
+
* helpers: {
|
|
206
|
+
* Playwright : {
|
|
207
|
+
* url: "http://localhost",
|
|
208
|
+
* locale: "fr-FR",
|
|
209
|
+
* }
|
|
210
|
+
* }
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
200
214
|
* Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
201
215
|
*
|
|
202
216
|
* ## Access From Helpers
|
|
@@ -371,6 +385,8 @@ class Playwright extends Helper {
|
|
|
371
385
|
}
|
|
372
386
|
if (this.options.recordVideo) contextOptions.recordVideo = this.options.recordVideo;
|
|
373
387
|
if (this.storageState) contextOptions.storageState = this.storageState;
|
|
388
|
+
if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent;
|
|
389
|
+
if (this.options.locale) contextOptions.locale = this.options.locale;
|
|
374
390
|
this.browserContext = await this.browser.newContext(contextOptions); // Adding the HTTPSError ignore in the context so that we can ignore those errors
|
|
375
391
|
}
|
|
376
392
|
|
|
@@ -2956,11 +2972,11 @@ class Playwright extends Helper {
|
|
|
2956
2972
|
}
|
|
2957
2973
|
|
|
2958
2974
|
/**
|
|
2959
|
-
* Waits for a network
|
|
2975
|
+
* Waits for a network response.
|
|
2960
2976
|
*
|
|
2961
2977
|
* ```js
|
|
2962
2978
|
* I.waitForResponse('http://example.com/resource');
|
|
2963
|
-
* I.waitForResponse(
|
|
2979
|
+
* I.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
|
|
2964
2980
|
* ```
|
|
2965
2981
|
*
|
|
2966
2982
|
* @param {string|function} urlOrPredicate
|
|
@@ -3069,26 +3085,6 @@ class Playwright extends Helper {
|
|
|
3069
3085
|
return this.page.waitForNavigation(opts);
|
|
3070
3086
|
}
|
|
3071
3087
|
|
|
3072
|
-
/**
|
|
3073
|
-
* Waits for a function to return true (waits for 1sec by default).
|
|
3074
|
-
*
|
|
3075
|
-
* ```js
|
|
3076
|
-
* I.waitUntil(() => window.requests == 0);
|
|
3077
|
-
* I.waitUntil(() => window.requests == 0, 5);
|
|
3078
|
-
* ```
|
|
3079
|
-
*
|
|
3080
|
-
* @param {function|string} fn function which is executed in browser context.
|
|
3081
|
-
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3082
|
-
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
3083
|
-
* @param {?number} [interval=null]
|
|
3084
|
-
*/
|
|
3085
|
-
async waitUntil(fn, sec = null) {
|
|
3086
|
-
console.log('This method will remove in CodeceptJS 1.4; use `waitForFunction` instead!');
|
|
3087
|
-
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
3088
|
-
const context = await this._getContext();
|
|
3089
|
-
return context.waitForFunction(fn, { timeout: waitTimeout });
|
|
3090
|
-
}
|
|
3091
|
-
|
|
3092
3088
|
async waitUntilExists(locator, sec) {
|
|
3093
3089
|
console.log(`waitUntilExists deprecated:
|
|
3094
3090
|
* use 'waitForElement' to wait for element to be attached
|
|
@@ -3551,13 +3547,10 @@ async function targetCreatedHandler(page) {
|
|
|
3551
3547
|
});
|
|
3552
3548
|
});
|
|
3553
3549
|
page.on('console', (msg) => {
|
|
3554
|
-
this.debugSection(`Browser:${ucfirst(msg.type())}`, (msg._text || '') + msg.args().join(' '));
|
|
3550
|
+
this.debugSection(`Browser:${ucfirst(msg.type())}`, (msg.text && msg.text() || msg._text || '') + msg.args().join(' '));
|
|
3555
3551
|
consoleLogStore.add(msg);
|
|
3556
3552
|
});
|
|
3557
3553
|
|
|
3558
|
-
if (this.options.userAgent) {
|
|
3559
|
-
await page.setUserAgent(this.options.userAgent);
|
|
3560
|
-
}
|
|
3561
3554
|
if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0 && this._getType() === 'Browser') {
|
|
3562
3555
|
await page.setViewportSize(parseWindowSize(this.options.windowSize));
|
|
3563
3556
|
}
|
package/docs/build/Protractor.js
CHANGED
|
@@ -1181,11 +1181,14 @@ class Protractor extends Helper {
|
|
|
1181
1181
|
}
|
|
1182
1182
|
|
|
1183
1183
|
/**
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1184
|
+
* Checks that title is equal to provided one.
|
|
1185
|
+
*
|
|
1186
|
+
* ```js
|
|
1187
|
+
* I.seeTitleEquals('Test title.');
|
|
1188
|
+
* ```
|
|
1189
|
+
*
|
|
1190
|
+
* @param {string} text value to check.
|
|
1191
|
+
*
|
|
1189
1192
|
*/
|
|
1190
1193
|
async seeTitleEquals(text) {
|
|
1191
1194
|
const title = await this.browser.getTitle();
|
|
@@ -1509,7 +1512,7 @@ class Protractor extends Helper {
|
|
|
1509
1512
|
}
|
|
1510
1513
|
|
|
1511
1514
|
/**
|
|
1512
|
-
|
|
1515
|
+
* Checks that current url contains a provided fragment.
|
|
1513
1516
|
*
|
|
1514
1517
|
* ```js
|
|
1515
1518
|
* I.seeInCurrentUrl('/register'); // we are on registration page
|
|
@@ -2184,24 +2187,6 @@ class Protractor extends Helper {
|
|
|
2184
2187
|
return this.browser.wait(() => this.browser.executeScript.call(this.browser, fn, ...args), aSec * 1000);
|
|
2185
2188
|
}
|
|
2186
2189
|
|
|
2187
|
-
/**
|
|
2188
|
-
* Waits for a function to return true (waits for 1sec by default).
|
|
2189
|
-
*
|
|
2190
|
-
* ```js
|
|
2191
|
-
* I.waitUntil(() => window.requests == 0);
|
|
2192
|
-
* I.waitUntil(() => window.requests == 0, 5);
|
|
2193
|
-
* ```
|
|
2194
|
-
*
|
|
2195
|
-
* @param {function|string} fn function which is executed in browser context.
|
|
2196
|
-
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2197
|
-
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
2198
|
-
* @param {?number} [interval=null]
|
|
2199
|
-
*/
|
|
2200
|
-
async waitUntil(fn, sec = null, timeoutMsg = null) {
|
|
2201
|
-
const aSec = sec || this.options.waitForTimeout;
|
|
2202
|
-
return this.browser.wait(fn, aSec * 1000, timeoutMsg);
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
2190
|
/**
|
|
2206
2191
|
* Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
|
|
2207
2192
|
*
|
package/docs/build/Puppeteer.js
CHANGED
|
@@ -561,10 +561,9 @@ class Puppeteer extends Helper {
|
|
|
561
561
|
this.context = null;
|
|
562
562
|
popupStore.clear();
|
|
563
563
|
this.isAuthenticated = false;
|
|
564
|
+
await this.browser.close();
|
|
564
565
|
if (this.isRemoteBrowser) {
|
|
565
566
|
await this.browser.disconnect();
|
|
566
|
-
} else {
|
|
567
|
-
await this.browser.close();
|
|
568
567
|
}
|
|
569
568
|
}
|
|
570
569
|
|
|
@@ -852,11 +851,14 @@ class Puppeteer extends Helper {
|
|
|
852
851
|
}
|
|
853
852
|
|
|
854
853
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
854
|
+
* Checks that title is equal to provided one.
|
|
855
|
+
*
|
|
856
|
+
* ```js
|
|
857
|
+
* I.seeTitleEquals('Test title.');
|
|
858
|
+
* ```
|
|
859
|
+
*
|
|
860
|
+
* @param {string} text value to check.
|
|
861
|
+
*
|
|
860
862
|
*/
|
|
861
863
|
async seeTitleEquals(text) {
|
|
862
864
|
const title = await this.page.title();
|
|
@@ -3102,26 +3104,6 @@ class Puppeteer extends Helper {
|
|
|
3102
3104
|
return this.page.waitForNavigation(opts);
|
|
3103
3105
|
}
|
|
3104
3106
|
|
|
3105
|
-
/**
|
|
3106
|
-
* Waits for a function to return true (waits for 1sec by default).
|
|
3107
|
-
*
|
|
3108
|
-
* ```js
|
|
3109
|
-
* I.waitUntil(() => window.requests == 0);
|
|
3110
|
-
* I.waitUntil(() => window.requests == 0, 5);
|
|
3111
|
-
* ```
|
|
3112
|
-
*
|
|
3113
|
-
* @param {function|string} fn function which is executed in browser context.
|
|
3114
|
-
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3115
|
-
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
3116
|
-
* @param {?number} [interval=null]
|
|
3117
|
-
*/
|
|
3118
|
-
async waitUntil(fn, sec = null) {
|
|
3119
|
-
console.log('This method will remove in CodeceptJS 1.4; use `waitForFunction` instead!');
|
|
3120
|
-
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
3121
|
-
const context = await this._getContext();
|
|
3122
|
-
return context.waitForFunction(fn, { timeout: waitTimeout });
|
|
3123
|
-
}
|
|
3124
|
-
|
|
3125
3107
|
async waitUntilExists(locator, sec) {
|
|
3126
3108
|
console.log(`waitUntilExists deprecated:
|
|
3127
3109
|
* use 'waitForElement' to wait for element to be attached
|
package/docs/build/REST.js
CHANGED
package/docs/build/WebDriver.js
CHANGED
|
@@ -875,7 +875,7 @@ class WebDriver extends Helper {
|
|
|
875
875
|
* I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
|
|
876
876
|
* ```
|
|
877
877
|
*
|
|
878
|
-
* @param {
|
|
878
|
+
* @param {*} timeouts WebDriver timeouts object.
|
|
879
879
|
*/
|
|
880
880
|
defineTimeout(timeouts) {
|
|
881
881
|
return this._defineBrowserTimeout(this.browser, timeouts);
|
|
@@ -3259,28 +3259,6 @@ class WebDriver extends Helper {
|
|
|
3259
3259
|
return this.browser.waitUntil(async () => this.browser.execute(fn, ...args), { timeout: aSec * 1000, timeoutMsg: '' });
|
|
3260
3260
|
}
|
|
3261
3261
|
|
|
3262
|
-
/**
|
|
3263
|
-
* Waits for a function to return true (waits for 1sec by default).
|
|
3264
|
-
*
|
|
3265
|
-
* ```js
|
|
3266
|
-
* I.waitUntil(() => window.requests == 0);
|
|
3267
|
-
* I.waitUntil(() => window.requests == 0, 5);
|
|
3268
|
-
* ```
|
|
3269
|
-
*
|
|
3270
|
-
* @param {function|string} fn function which is executed in browser context.
|
|
3271
|
-
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3272
|
-
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
3273
|
-
* @param {?number} [interval=null]
|
|
3274
|
-
*/
|
|
3275
|
-
async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) {
|
|
3276
|
-
const aSec = sec || this.options.waitForTimeout;
|
|
3277
|
-
const _interval = typeof interval === 'number' ? interval * 1000 : null;
|
|
3278
|
-
if (isWebDriver5()) {
|
|
3279
|
-
return this.browser.waitUntil(fn, aSec * 1000, timeoutMsg, _interval);
|
|
3280
|
-
}
|
|
3281
|
-
return this.browser.waitUntil(fn, { timeout: aSec * 1000, timeoutMsg, interval: _interval });
|
|
3282
|
-
}
|
|
3283
|
-
|
|
3284
3262
|
/**
|
|
3285
3263
|
* Switches frame or in case of null locator reverts to parent.
|
|
3286
3264
|
*
|
package/docs/changelog.md
CHANGED
|
@@ -7,6 +7,53 @@ layout: Section
|
|
|
7
7
|
|
|
8
8
|
# Releases
|
|
9
9
|
|
|
10
|
+
## 3.2.0
|
|
11
|
+
|
|
12
|
+
đŠī¸ Features:
|
|
13
|
+
|
|
14
|
+
**Timeouts implemented**
|
|
15
|
+
* global timeouts (via `timeout` config option).
|
|
16
|
+
* _Breaking change:_ timeout option expects **timeout in seconds**, not in miliseconds as it was previously.
|
|
17
|
+
* test timeouts (via `Scenario` and `Feature` options)
|
|
18
|
+
* _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
// set timeout for every test in suite to 10 secs
|
|
22
|
+
Feature('tests with timeout', { timeout: 10 });
|
|
23
|
+
|
|
24
|
+
// set timeout for this test to 20 secs
|
|
25
|
+
Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
* step timeouts (See [#3059](https://github.com/codeceptjs/CodeceptJS/issues/3059) by **[nikocanvacom](https://github.com/nikocanvacom)**)
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// set step timeout to 5 secs
|
|
32
|
+
I.limitTime(5).click('Link');
|
|
33
|
+
```
|
|
34
|
+
* `stepTimeout` plugin introduced to automatically add timeouts for each step ([#3059](https://github.com/codeceptjs/CodeceptJS/issues/3059) by **[nikocanvacom](https://github.com/nikocanvacom)**).
|
|
35
|
+
|
|
36
|
+
[**retryTo**](/plugins/#retryto) plugin introduced to rerun a set of steps on failure:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// editing in text in iframe
|
|
40
|
+
// if iframe was not loaded - retry 5 times
|
|
41
|
+
await retryTo(() => {
|
|
42
|
+
I.switchTo('#editor frame');
|
|
43
|
+
I.fillField('textarea', 'value');
|
|
44
|
+
}, 5);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
* **[Playwright]** added `locale` configuration
|
|
48
|
+
* **[WebDriver]** upgraded to webdriverio v7
|
|
49
|
+
|
|
50
|
+
đ Bugfixes:
|
|
51
|
+
|
|
52
|
+
* Fixed allure plugin "Unexpected endStep()" error in [#3098](https://github.com/codeceptjs/CodeceptJS/issues/3098) by **[abhimanyupandian](https://github.com/abhimanyupandian)**
|
|
53
|
+
* **[Puppeteer]** always close remote browser on test end. See [#3054](https://github.com/codeceptjs/CodeceptJS/issues/3054) by **[mattonem](https://github.com/mattonem)**
|
|
54
|
+
* stepbyStepReport Plugin: Disabled screenshots after test has failed. See [#3119](https://github.com/codeceptjs/CodeceptJS/issues/3119) by **[ioannisChalkias](https://github.com/ioannisChalkias)**
|
|
55
|
+
|
|
56
|
+
|
|
10
57
|
## 3.1.3
|
|
11
58
|
|
|
12
59
|
đŠī¸ Features:
|
|
@@ -24,7 +71,7 @@ Given('I have an employee card', (table) => {
|
|
|
24
71
|
// rows = [['Harry', 'Potter', Seeker]];
|
|
25
72
|
}
|
|
26
73
|
```
|
|
27
|
-
See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
74
|
+
See updated [BDD section](https://codecept.io/bdd/) for more API options. Thanks to **[EgorBodnar](https://github.com/EgorBodnar)**
|
|
28
75
|
|
|
29
76
|
* Support `cjs` file extensions for config file: `codecept.conf.cjs`. See [#3052](https://github.com/codeceptjs/CodeceptJS/issues/3052) by **[kalvenschraut](https://github.com/kalvenschraut)**
|
|
30
77
|
* API updates: Added `test.file` and `suite.file` properties to `test` and `suite` objects to use in helpers and plugins.
|
|
@@ -37,6 +84,7 @@ See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
|
37
84
|
* **[Playwright]** `I.haveRequestHeaders` affects all tabs. See [#3049](https://github.com/codeceptjs/CodeceptJS/issues/3049) by **[jancorvus](https://github.com/jancorvus)**
|
|
38
85
|
* BDD: Fixed unhandled empty feature files. Fix [#3046](https://github.com/codeceptjs/CodeceptJS/issues/3046) by **[abhimanyupandian](https://github.com/abhimanyupandian)**
|
|
39
86
|
* Fixed `RangeError: Invalid string length` in `recorder.js` when running huge amount of tests.
|
|
87
|
+
* **[Appium]** Fixed definitions for `touchPerform`, `hideDeviceKeyboard`, `removeApp` by **[mirao](https://github.com/mirao)**
|
|
40
88
|
|
|
41
89
|
đ Documentation:
|
|
42
90
|
|