codeceptjs 3.3.0-beta.4 → 3.3.1
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 +43 -1
- package/README.md +26 -0
- package/docs/api.md +45 -30
- package/docs/bdd.md +1 -0
- package/docs/best.md +1 -1
- package/docs/build/ApiDataFactory.js +4 -3
- package/docs/build/Appium.js +58 -43
- package/docs/build/GraphQL.js +4 -2
- package/docs/build/GraphQLDataFactory.js +3 -3
- package/docs/build/JSONResponse.js +1 -1
- package/docs/build/Nightmare.js +99 -70
- package/docs/build/Playwright.js +187 -109
- package/docs/build/Protractor.js +70 -32
- package/docs/build/Puppeteer.js +141 -98
- package/docs/build/REST.js +4 -1
- package/docs/build/TestCafe.js +96 -65
- package/docs/build/WebDriver.js +183 -133
- package/docs/changelog.md +92 -0
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +2 -2
- package/docs/email.md +5 -0
- package/docs/helpers/ApiDataFactory.md +7 -3
- package/docs/helpers/Appium.md +113 -15
- package/docs/helpers/GraphQL.md +6 -0
- package/docs/helpers/GraphQLDataFactory.md +3 -3
- package/docs/helpers/JSONResponse.md +1 -1
- package/docs/helpers/MockRequest.md +8 -6
- package/docs/helpers/Nightmare.md +131 -29
- package/docs/helpers/Playwright.md +424 -215
- package/docs/helpers/Puppeteer.md +229 -92
- package/docs/helpers/REST.md +1 -1
- package/docs/helpers/TestCafe.md +166 -62
- package/docs/helpers/WebDriver.md +254 -103
- package/docs/index.md +1 -1
- package/docs/locators.md +1 -1
- package/docs/videos.md +2 -2
- package/docs/webapi/amOnPage.mustache +2 -1
- package/docs/webapi/appendField.mustache +2 -1
- package/docs/webapi/attachFile.mustache +2 -1
- package/docs/webapi/checkOption.mustache +2 -1
- package/docs/webapi/clearCookie.mustache +2 -1
- package/docs/webapi/clearField.mustache +1 -0
- package/docs/webapi/click.mustache +2 -1
- package/docs/webapi/clickLink.mustache +2 -1
- package/docs/webapi/closeCurrentTab.mustache +6 -4
- package/docs/webapi/closeOtherTabs.mustache +6 -4
- package/docs/webapi/dontSee.mustache +1 -0
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -0
- package/docs/webapi/dontSeeCookie.mustache +2 -1
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +2 -1
- package/docs/webapi/dontSeeElement.mustache +2 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +2 -1
- package/docs/webapi/dontSeeInCurrentUrl.mustache +2 -1
- package/docs/webapi/dontSeeInField.mustache +2 -1
- package/docs/webapi/dontSeeInSource.mustache +1 -0
- package/docs/webapi/dontSeeInTitle.mustache +2 -1
- package/docs/webapi/doubleClick.mustache +1 -0
- package/docs/webapi/downloadFile.mustache +2 -1
- package/docs/webapi/dragAndDrop.mustache +1 -0
- package/docs/webapi/dragSlider.mustache +2 -1
- package/docs/webapi/fillField.mustache +1 -0
- package/docs/webapi/forceClick.mustache +1 -0
- package/docs/webapi/forceRightClick.mustache +1 -0
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +2 -1
- package/docs/webapi/moveCursorTo.mustache +1 -0
- package/docs/webapi/openNewTab.mustache +6 -4
- package/docs/webapi/pressKey.mustache +2 -1
- package/docs/webapi/pressKeyDown.mustache +1 -0
- package/docs/webapi/pressKeyUp.mustache +1 -0
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -0
- package/docs/webapi/refreshPage.mustache +1 -0
- package/docs/webapi/resizeWindow.mustache +2 -1
- package/docs/webapi/rightClick.mustache +1 -0
- package/docs/webapi/saveElementScreenshot.mustache +1 -0
- package/docs/webapi/saveScreenshot.mustache +2 -1
- package/docs/webapi/say.mustache +2 -1
- package/docs/webapi/scrollIntoView.mustache +1 -0
- package/docs/webapi/scrollPageToBottom.mustache +1 -0
- package/docs/webapi/scrollPageToTop.mustache +1 -0
- package/docs/webapi/scrollTo.mustache +2 -1
- package/docs/webapi/see.mustache +2 -1
- package/docs/webapi/seeAttributesOnElements.mustache +2 -1
- package/docs/webapi/seeCheckboxIsChecked.mustache +1 -0
- package/docs/webapi/seeCookie.mustache +1 -0
- package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -1
- package/docs/webapi/seeCurrentUrlEquals.mustache +2 -1
- package/docs/webapi/seeElement.mustache +2 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -0
- package/docs/webapi/seeInCurrentUrl.mustache +2 -1
- package/docs/webapi/seeInField.mustache +1 -0
- package/docs/webapi/seeInPopup.mustache +1 -0
- package/docs/webapi/seeInSource.mustache +2 -1
- package/docs/webapi/seeInTitle.mustache +2 -1
- package/docs/webapi/seeNumberOfElements.mustache +1 -0
- package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -0
- package/docs/webapi/seeTextEquals.mustache +2 -1
- package/docs/webapi/seeTitleEquals.mustache +6 -5
- package/docs/webapi/selectOption.mustache +1 -0
- package/docs/webapi/setCookie.mustache +1 -0
- package/docs/webapi/setGeoLocation.mustache +1 -0
- package/docs/webapi/switchTo.mustache +2 -1
- package/docs/webapi/switchToNextTab.mustache +8 -7
- package/docs/webapi/switchToPreviousTab.mustache +8 -7
- package/docs/webapi/type.mustache +1 -0
- package/docs/webapi/uncheckOption.mustache +2 -1
- package/docs/webapi/wait.mustache +2 -1
- package/docs/webapi/waitForClickable.mustache +2 -1
- package/docs/webapi/waitForDetached.mustache +2 -1
- package/docs/webapi/waitForElement.mustache +2 -1
- package/docs/webapi/waitForEnabled.mustache +2 -1
- package/docs/webapi/waitForFunction.mustache +1 -0
- package/docs/webapi/waitForInvisible.mustache +2 -1
- package/docs/webapi/waitForText.mustache +2 -1
- package/docs/webapi/waitForValue.mustache +1 -0
- package/docs/webapi/waitForVisible.mustache +1 -0
- package/docs/webapi/waitInUrl.mustache +2 -1
- package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -1
- package/docs/webapi/waitToHide.mustache +2 -1
- package/docs/webapi/waitUrlEquals.mustache +2 -1
- package/lib/command/definitions.js +9 -0
- package/lib/command/run.js +2 -2
- package/lib/command/workers/runTests.js +40 -0
- package/lib/helper/ApiDataFactory.js +4 -3
- package/lib/helper/Appium.js +7 -2
- package/lib/helper/GraphQL.js +4 -2
- package/lib/helper/GraphQLDataFactory.js +3 -3
- package/lib/helper/JSONResponse.js +1 -1
- package/lib/helper/Playwright.js +49 -13
- package/lib/helper/REST.js +4 -1
- package/lib/helper/WebDriver.js +6 -0
- package/lib/interfaces/bdd.js +5 -0
- package/lib/listener/steps.js +1 -0
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/stepByStepReport.js +8 -6
- package/lib/workers.js +12 -0
- package/package.json +4 -3
- package/typings/types.d.ts +598 -600
|
@@ -43,7 +43,7 @@ To make this work you need
|
|
|
43
43
|
Install [Rosie][1] and [Faker][2] libraries.
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
npm i rosie faker --save-dev
|
|
46
|
+
npm i rosie @faker-js/faker --save-dev
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Create a factory file for a resource.
|
|
@@ -53,8 +53,8 @@ See the example for Users factories:
|
|
|
53
53
|
```js
|
|
54
54
|
// tests/factories/users.js
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const Factory = require('rosie').Factory;
|
|
57
|
+
const faker = require('@faker-js/faker');
|
|
58
58
|
|
|
59
59
|
// Used with a constructor function passed to Factory, so that the final build
|
|
60
60
|
// object matches the necessary pattern to be sent as the variables object.
|
|
@@ -207,7 +207,7 @@ Executes a callback function passing in `response` object and chai assertions wi
|
|
|
207
207
|
Use it to perform custom checks of response data
|
|
208
208
|
|
|
209
209
|
```js
|
|
210
|
-
I.seeResponseValidByCallback({ data, status, expect } => {
|
|
210
|
+
I.seeResponseValidByCallback(({ data, status, expect }) => {
|
|
211
211
|
expect(status).to.eql(200);
|
|
212
212
|
expect(data).keys.to.include(['user', 'company']);
|
|
213
213
|
});
|
|
@@ -244,13 +244,15 @@ I.mockRequest('GET', ['/secrets', '/v2/secrets'], 403);
|
|
|
244
244
|
Use PollyJS [Server Routes API][12] to declare mocks via callback function:
|
|
245
245
|
|
|
246
246
|
```js
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
247
|
+
I.mockServer((server) => {
|
|
248
|
+
// basic usage
|
|
249
|
+
server.get('/api/v2/users').intercept((req, res) => {
|
|
250
|
+
res.sendStatus(200).json({ users });
|
|
251
|
+
});
|
|
251
252
|
|
|
252
|
-
// passthrough requests to "/api/v2"
|
|
253
|
-
server.get('/api/v1').passthrough();
|
|
253
|
+
// passthrough requests to "/api/v2"
|
|
254
|
+
server.get('/api/v1').passthrough();
|
|
255
|
+
});
|
|
254
256
|
```
|
|
255
257
|
|
|
256
258
|
In record replay mode you can define which routes should be recorded and where to store them:
|
|
@@ -82,6 +82,8 @@ I.amOnPage('/login'); // opens a login page
|
|
|
82
82
|
- `url` **[string][3]** url path or global url.
|
|
83
83
|
- `headers` **[object][4]?** list of request headers can be passed
|
|
84
84
|
|
|
85
|
+
Returns **[Promise][5]<any>**
|
|
86
|
+
|
|
85
87
|
### appendField
|
|
86
88
|
|
|
87
89
|
Appends text to a input field or textarea.
|
|
@@ -96,6 +98,8 @@ I.appendField('#myTextField', 'appended');
|
|
|
96
98
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator
|
|
97
99
|
- `value` **[string][3]** text value to append.
|
|
98
100
|
|
|
101
|
+
Returns **[Promise][5]<any>**
|
|
102
|
+
|
|
99
103
|
### attachFile
|
|
100
104
|
|
|
101
105
|
Attaches a file to element located by label, name, CSS or XPath
|
|
@@ -110,7 +114,9 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
110
114
|
#### Parameters
|
|
111
115
|
|
|
112
116
|
- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
113
|
-
- `pathToFile` **[string][3]** local file path relative to codecept.json config file.
|
|
117
|
+
- `pathToFile` **[string][3]** local file path relative to codecept.json config file.
|
|
118
|
+
|
|
119
|
+
Returns **[Promise][5]<any>** Doesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more][6])
|
|
114
120
|
|
|
115
121
|
### checkOption
|
|
116
122
|
|
|
@@ -130,6 +136,8 @@ I.checkOption('agree', '//form');
|
|
|
130
136
|
- `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
131
137
|
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
132
138
|
|
|
139
|
+
Returns **[Promise][5]<any>**
|
|
140
|
+
|
|
133
141
|
### clearCookie
|
|
134
142
|
|
|
135
143
|
Clears a cookie by name,
|
|
@@ -144,6 +152,8 @@ I.clearCookie('test');
|
|
|
144
152
|
|
|
145
153
|
- `cookie` **[string][3]?** (optional, `null` by default) cookie name
|
|
146
154
|
|
|
155
|
+
Returns **[Promise][5]<any>**
|
|
156
|
+
|
|
147
157
|
### clearField
|
|
148
158
|
|
|
149
159
|
Clears a `<textarea>` or text `<input>` element's value.
|
|
@@ -159,6 +169,8 @@ I.clearField('#email');
|
|
|
159
169
|
- `field`
|
|
160
170
|
- `editable` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
161
171
|
|
|
172
|
+
Returns **[Promise][5]<any>**
|
|
173
|
+
|
|
162
174
|
### click
|
|
163
175
|
|
|
164
176
|
Perform a click on a link or a button, given by a locator.
|
|
@@ -186,7 +198,9 @@ I.click({css: 'nav a.login'});
|
|
|
186
198
|
#### Parameters
|
|
187
199
|
|
|
188
200
|
- `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
189
|
-
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
201
|
+
- `context` **([string][3]? | [object][4] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
202
|
+
|
|
203
|
+
Returns **[Promise][5]<any>**
|
|
190
204
|
|
|
191
205
|
### dontSee
|
|
192
206
|
|
|
@@ -203,6 +217,8 @@ I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
|
203
217
|
- `text` **[string][3]** which is not present.
|
|
204
218
|
- `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
205
219
|
|
|
220
|
+
Returns **[Promise][5]<any>**
|
|
221
|
+
|
|
206
222
|
### dontSeeCheckboxIsChecked
|
|
207
223
|
|
|
208
224
|
Verifies that the specified checkbox is not checked.
|
|
@@ -217,6 +233,8 @@ I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
|
217
233
|
|
|
218
234
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
219
235
|
|
|
236
|
+
Returns **[Promise][5]<any>**
|
|
237
|
+
|
|
220
238
|
### dontSeeCookie
|
|
221
239
|
|
|
222
240
|
Checks that cookie with given name does not exist.
|
|
@@ -229,6 +247,8 @@ I.dontSeeCookie('auth'); // no auth cookie
|
|
|
229
247
|
|
|
230
248
|
- `name` **[string][3]** cookie name.
|
|
231
249
|
|
|
250
|
+
Returns **[Promise][5]<any>**
|
|
251
|
+
|
|
232
252
|
### dontSeeCurrentUrlEquals
|
|
233
253
|
|
|
234
254
|
Checks that current url is not equal to provided one.
|
|
@@ -243,6 +263,8 @@ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also
|
|
|
243
263
|
|
|
244
264
|
- `url` **[string][3]** value to check.
|
|
245
265
|
|
|
266
|
+
Returns **[Promise][5]<any>**
|
|
267
|
+
|
|
246
268
|
### dontSeeElement
|
|
247
269
|
|
|
248
270
|
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
@@ -255,6 +277,8 @@ I.dontSeeElement('.modal'); // modal is not shown
|
|
|
255
277
|
|
|
256
278
|
- `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
|
|
257
279
|
|
|
280
|
+
Returns **[Promise][5]<any>**
|
|
281
|
+
|
|
258
282
|
### dontSeeElementInDOM
|
|
259
283
|
|
|
260
284
|
Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
@@ -267,6 +291,8 @@ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or
|
|
|
267
291
|
|
|
268
292
|
- `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
|
|
269
293
|
|
|
294
|
+
Returns **[Promise][5]<any>**
|
|
295
|
+
|
|
270
296
|
### dontSeeInCurrentUrl
|
|
271
297
|
|
|
272
298
|
Checks that current url does not contain a provided fragment.
|
|
@@ -275,6 +301,8 @@ Checks that current url does not contain a provided fragment.
|
|
|
275
301
|
|
|
276
302
|
- `url` **[string][3]** value to check.
|
|
277
303
|
|
|
304
|
+
Returns **[Promise][5]<any>**
|
|
305
|
+
|
|
278
306
|
### dontSeeInField
|
|
279
307
|
|
|
280
308
|
Checks that value of input field or textarea doesn't equal to given value
|
|
@@ -290,6 +318,8 @@ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
|
290
318
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
291
319
|
- `value` **[string][3]** value to check.
|
|
292
320
|
|
|
321
|
+
Returns **[Promise][5]<any>**
|
|
322
|
+
|
|
293
323
|
### dontSeeInSource
|
|
294
324
|
|
|
295
325
|
Checks that the current page does not contains the given string in its raw source code.
|
|
@@ -303,6 +333,8 @@ I.dontSeeInSource('<!--'); // no comments in source
|
|
|
303
333
|
- `text`
|
|
304
334
|
- `value` **[string][3]** to check.
|
|
305
335
|
|
|
336
|
+
Returns **[Promise][5]<any>**
|
|
337
|
+
|
|
306
338
|
### dontSeeInTitle
|
|
307
339
|
|
|
308
340
|
Checks that title does not contain text.
|
|
@@ -315,6 +347,8 @@ I.dontSeeInTitle('Error');
|
|
|
315
347
|
|
|
316
348
|
- `text` **[string][3]** value to check.
|
|
317
349
|
|
|
350
|
+
Returns **[Promise][5]<any>**
|
|
351
|
+
|
|
318
352
|
### doubleClick
|
|
319
353
|
|
|
320
354
|
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
@@ -332,12 +366,14 @@ I.doubleClick('.btn.edit');
|
|
|
332
366
|
- `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
333
367
|
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
334
368
|
|
|
369
|
+
Returns **[Promise][5]<any>**
|
|
370
|
+
|
|
335
371
|
### executeAsyncScript
|
|
336
372
|
|
|
337
373
|
Executes async script on page.
|
|
338
374
|
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
339
375
|
|
|
340
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][
|
|
376
|
+
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][7].
|
|
341
377
|
|
|
342
378
|
```js
|
|
343
379
|
I.executeAsyncScript(function(done) {
|
|
@@ -358,9 +394,9 @@ let val = await I.executeAsyncScript(function(url, done) {
|
|
|
358
394
|
#### Parameters
|
|
359
395
|
|
|
360
396
|
- `args` **...any** to be passed to function.
|
|
361
|
-
- `fn` **([string][3] | [function][
|
|
397
|
+
- `fn` **([string][3] | [function][8])** function to be executed in browser context.
|
|
362
398
|
|
|
363
|
-
Returns **[Promise][
|
|
399
|
+
Returns **[Promise][5]<any>** Wrapper for asynchronous [evaluate][9].
|
|
364
400
|
Unlike NightmareJS implementation calling `done` will return its first argument.
|
|
365
401
|
|
|
366
402
|
### executeScript
|
|
@@ -392,9 +428,9 @@ let date = await I.executeScript(function(el) {
|
|
|
392
428
|
#### Parameters
|
|
393
429
|
|
|
394
430
|
- `args` **...any** to be passed to function.
|
|
395
|
-
- `fn` **([string][3] | [function][
|
|
431
|
+
- `fn` **([string][3] | [function][8])** function to be executed in browser context.
|
|
396
432
|
|
|
397
|
-
Returns **[Promise][
|
|
433
|
+
Returns **[Promise][5]<any>** Wrapper for synchronous [evaluate][9]
|
|
398
434
|
|
|
399
435
|
### fillField
|
|
400
436
|
|
|
@@ -417,6 +453,8 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
417
453
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
418
454
|
- `value` **([string][3] | [object][4])** text value to fill.
|
|
419
455
|
|
|
456
|
+
Returns **[Promise][5]<any>**
|
|
457
|
+
|
|
420
458
|
### grabAttributeFrom
|
|
421
459
|
|
|
422
460
|
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
@@ -432,7 +470,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
432
470
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
433
471
|
- `attr` **[string][3]** attribute name.
|
|
434
472
|
|
|
435
|
-
Returns **[Promise][
|
|
473
|
+
Returns **[Promise][5]<[string][3]>** attribute value
|
|
436
474
|
|
|
437
475
|
### grabAttributeFromAll
|
|
438
476
|
|
|
@@ -448,7 +486,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
448
486
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
449
487
|
- `attr` **[string][3]** attribute name.
|
|
450
488
|
|
|
451
|
-
Returns **[Promise][
|
|
489
|
+
Returns **[Promise][5]<[Array][10]<[string][3]>>** attribute value
|
|
452
490
|
|
|
453
491
|
### grabCookie
|
|
454
492
|
|
|
@@ -465,7 +503,7 @@ assert(cookie.value, '123456');
|
|
|
465
503
|
|
|
466
504
|
- `name` **[string][3]?** cookie name.
|
|
467
505
|
|
|
468
|
-
Returns **([Promise][
|
|
506
|
+
Returns **([Promise][5]<[string][3]> | [Promise][5]<[Array][10]<[string][3]>>)** attribute valueCookie in JSON format. If name not passed returns all cookies for this domain.Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
|
|
469
507
|
|
|
470
508
|
### grabCssPropertyFrom
|
|
471
509
|
|
|
@@ -482,7 +520,7 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
482
520
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
483
521
|
- `cssProperty` **[string][3]** CSS property name.
|
|
484
522
|
|
|
485
|
-
Returns **[Promise][
|
|
523
|
+
Returns **[Promise][5]<[string][3]>** CSS value
|
|
486
524
|
|
|
487
525
|
### grabCurrentUrl
|
|
488
526
|
|
|
@@ -494,7 +532,7 @@ let url = await I.grabCurrentUrl();
|
|
|
494
532
|
console.log(`Current URL is [${url}]`);
|
|
495
533
|
```
|
|
496
534
|
|
|
497
|
-
Returns **[Promise][
|
|
535
|
+
Returns **[Promise][5]<[string][3]>** current URL
|
|
498
536
|
|
|
499
537
|
### grabElementBoundingRect
|
|
500
538
|
|
|
@@ -522,7 +560,7 @@ const width = await I.grabElementBoundingRect('h3', 'width');
|
|
|
522
560
|
- `prop`
|
|
523
561
|
- `elementSize` **[string][3]?** x, y, width or height of the given element.
|
|
524
562
|
|
|
525
|
-
Returns **([Promise][
|
|
563
|
+
Returns **([Promise][5]<DOMRect> | [Promise][5]<[number][11]>)** Element bounding rectangle
|
|
526
564
|
|
|
527
565
|
### grabHAR
|
|
528
566
|
|
|
@@ -548,7 +586,7 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
548
586
|
- `locator`
|
|
549
587
|
- `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
|
|
550
588
|
|
|
551
|
-
Returns **[Promise][
|
|
589
|
+
Returns **[Promise][5]<[string][3]>** HTML code for an element
|
|
552
590
|
|
|
553
591
|
### grabHTMLFromAll
|
|
554
592
|
|
|
@@ -564,7 +602,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
564
602
|
- `locator`
|
|
565
603
|
- `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
|
|
566
604
|
|
|
567
|
-
Returns **[Promise][
|
|
605
|
+
Returns **[Promise][5]<[Array][10]<[string][3]>>** HTML code for an element
|
|
568
606
|
|
|
569
607
|
### grabNumberOfVisibleElements
|
|
570
608
|
|
|
@@ -579,7 +617,7 @@ let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
|
579
617
|
|
|
580
618
|
- `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
|
|
581
619
|
|
|
582
|
-
Returns **[Promise][
|
|
620
|
+
Returns **[Promise][5]<[number][11]>** number of visible elements
|
|
583
621
|
|
|
584
622
|
### grabPageScrollPosition
|
|
585
623
|
|
|
@@ -590,7 +628,7 @@ Resumes test execution, so **should be used inside an async function with `await
|
|
|
590
628
|
let { x, y } = await I.grabPageScrollPosition();
|
|
591
629
|
```
|
|
592
630
|
|
|
593
|
-
Returns **[Promise][
|
|
631
|
+
Returns **[Promise][5]<PageScrollPosition>** scroll position
|
|
594
632
|
|
|
595
633
|
### grabTextFrom
|
|
596
634
|
|
|
@@ -607,7 +645,7 @@ If multiple elements found returns first element.
|
|
|
607
645
|
|
|
608
646
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
609
647
|
|
|
610
|
-
Returns **[Promise][
|
|
648
|
+
Returns **[Promise][5]<[string][3]>** attribute value
|
|
611
649
|
|
|
612
650
|
### grabTextFromAll
|
|
613
651
|
|
|
@@ -622,7 +660,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
622
660
|
|
|
623
661
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
624
662
|
|
|
625
|
-
Returns **[Promise][
|
|
663
|
+
Returns **[Promise][5]<[Array][10]<[string][3]>>** attribute value
|
|
626
664
|
|
|
627
665
|
### grabTitle
|
|
628
666
|
|
|
@@ -633,7 +671,7 @@ Resumes test execution, so **should be used inside async with `await`** operator
|
|
|
633
671
|
let title = await I.grabTitle();
|
|
634
672
|
```
|
|
635
673
|
|
|
636
|
-
Returns **[Promise][
|
|
674
|
+
Returns **[Promise][5]<[string][3]>** title
|
|
637
675
|
|
|
638
676
|
### grabValueFrom
|
|
639
677
|
|
|
@@ -649,7 +687,7 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
649
687
|
|
|
650
688
|
- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
651
689
|
|
|
652
|
-
Returns **[Promise][
|
|
690
|
+
Returns **[Promise][5]<[string][3]>** attribute value
|
|
653
691
|
|
|
654
692
|
### grabValueFromAll
|
|
655
693
|
|
|
@@ -664,7 +702,7 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
664
702
|
|
|
665
703
|
- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
666
704
|
|
|
667
|
-
Returns **[Promise][
|
|
705
|
+
Returns **[Promise][5]<[Array][10]<[string][3]>>** attribute value
|
|
668
706
|
|
|
669
707
|
### haveHeader
|
|
670
708
|
|
|
@@ -696,6 +734,8 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
696
734
|
- `offsetX` **[number][11]** (optional, `0` by default) X-axis offset.
|
|
697
735
|
- `offsetY` **[number][11]** (optional, `0` by default) Y-axis offset.
|
|
698
736
|
|
|
737
|
+
Returns **[Promise][5]<any>**
|
|
738
|
+
|
|
699
739
|
### pressKey
|
|
700
740
|
|
|
701
741
|
Sends [input event][12] on a page.
|
|
@@ -717,6 +757,8 @@ Reload the current page.
|
|
|
717
757
|
I.refreshPage();
|
|
718
758
|
```
|
|
719
759
|
|
|
760
|
+
Returns **[Promise][5]<any>**
|
|
761
|
+
|
|
720
762
|
### resizeWindow
|
|
721
763
|
|
|
722
764
|
Resize the current window to provided width and height.
|
|
@@ -727,6 +769,8 @@ First parameter can be set to `maximize`.
|
|
|
727
769
|
- `width` **[number][11]** width in pixels or `maximize`.
|
|
728
770
|
- `height` **[number][11]** height in pixels.
|
|
729
771
|
|
|
772
|
+
Returns **[Promise][5]<any>**
|
|
773
|
+
|
|
730
774
|
### rightClick
|
|
731
775
|
|
|
732
776
|
Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
@@ -745,6 +789,8 @@ I.rightClick('Click me', '.context');
|
|
|
745
789
|
- `locator` **([string][3] | [object][4])** clickable element located by CSS|XPath|strict locator.
|
|
746
790
|
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
747
791
|
|
|
792
|
+
Returns **[Promise][5]<any>**
|
|
793
|
+
|
|
748
794
|
### saveElementScreenshot
|
|
749
795
|
|
|
750
796
|
Saves screenshot of the specified locator to ouput folder (set in codecept.json or codecept.conf.js).
|
|
@@ -759,6 +805,8 @@ I.saveElementScreenshot(`#submit`,'debug.png');
|
|
|
759
805
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
760
806
|
- `fileName` **[string][3]** file name to save.
|
|
761
807
|
|
|
808
|
+
Returns **[Promise][5]<any>**
|
|
809
|
+
|
|
762
810
|
### saveScreenshot
|
|
763
811
|
|
|
764
812
|
Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
|
|
@@ -775,6 +823,8 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
775
823
|
- `fileName` **[string][3]** file name to save.
|
|
776
824
|
- `fullPage` **[boolean][13]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
777
825
|
|
|
826
|
+
Returns **[Promise][5]<any>**
|
|
827
|
+
|
|
778
828
|
### scrollPageToBottom
|
|
779
829
|
|
|
780
830
|
Scroll page to the bottom.
|
|
@@ -783,6 +833,8 @@ Scroll page to the bottom.
|
|
|
783
833
|
I.scrollPageToBottom();
|
|
784
834
|
```
|
|
785
835
|
|
|
836
|
+
Returns **[Promise][5]<any>**
|
|
837
|
+
|
|
786
838
|
### scrollPageToTop
|
|
787
839
|
|
|
788
840
|
Scroll page to the top.
|
|
@@ -791,6 +843,8 @@ Scroll page to the top.
|
|
|
791
843
|
I.scrollPageToTop();
|
|
792
844
|
```
|
|
793
845
|
|
|
846
|
+
Returns **[Promise][5]<any>**
|
|
847
|
+
|
|
794
848
|
### scrollTo
|
|
795
849
|
|
|
796
850
|
Scrolls to element matched by locator.
|
|
@@ -807,6 +861,8 @@ I.scrollTo('#submit', 5, 5);
|
|
|
807
861
|
- `offsetX` **[number][11]** (optional, `0` by default) X-axis offset.
|
|
808
862
|
- `offsetY` **[number][11]** (optional, `0` by default) Y-axis offset.
|
|
809
863
|
|
|
864
|
+
Returns **[Promise][5]<any>**
|
|
865
|
+
|
|
810
866
|
### see
|
|
811
867
|
|
|
812
868
|
Checks that a page contains a visible text.
|
|
@@ -823,6 +879,8 @@ I.see('Register', {css: 'form.register'}); // use strict locator
|
|
|
823
879
|
- `text` **[string][3]** expected on page.
|
|
824
880
|
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
825
881
|
|
|
882
|
+
Returns **[Promise][5]<any>**
|
|
883
|
+
|
|
826
884
|
### seeCheckboxIsChecked
|
|
827
885
|
|
|
828
886
|
Verifies that the specified checkbox is checked.
|
|
@@ -837,6 +895,8 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
|
837
895
|
|
|
838
896
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
839
897
|
|
|
898
|
+
Returns **[Promise][5]<any>**
|
|
899
|
+
|
|
840
900
|
### seeCookie
|
|
841
901
|
|
|
842
902
|
Checks that cookie with given name exists.
|
|
@@ -849,6 +909,8 @@ I.seeCookie('Auth');
|
|
|
849
909
|
|
|
850
910
|
- `name` **[string][3]** cookie name.
|
|
851
911
|
|
|
912
|
+
Returns **[Promise][5]<any>**
|
|
913
|
+
|
|
852
914
|
### seeCurrentUrlEquals
|
|
853
915
|
|
|
854
916
|
Checks that current url is equal to provided one.
|
|
@@ -864,6 +926,8 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
|
864
926
|
|
|
865
927
|
- `url` **[string][3]** value to check.
|
|
866
928
|
|
|
929
|
+
Returns **[Promise][5]<any>**
|
|
930
|
+
|
|
867
931
|
### seeElement
|
|
868
932
|
|
|
869
933
|
Checks that a given Element is visible
|
|
@@ -877,6 +941,8 @@ I.seeElement('#modal');
|
|
|
877
941
|
|
|
878
942
|
- `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
|
|
879
943
|
|
|
944
|
+
Returns **[Promise][5]<any>**
|
|
945
|
+
|
|
880
946
|
### seeElementInDOM
|
|
881
947
|
|
|
882
948
|
Checks that a given Element is present in the DOM
|
|
@@ -890,6 +956,8 @@ I.seeElementInDOM('#modal');
|
|
|
890
956
|
|
|
891
957
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
892
958
|
|
|
959
|
+
Returns **[Promise][5]<any>**
|
|
960
|
+
|
|
893
961
|
### seeInCurrentUrl
|
|
894
962
|
|
|
895
963
|
Checks that current url contains a provided fragment.
|
|
@@ -902,6 +970,8 @@ I.seeInCurrentUrl('/register'); // we are on registration page
|
|
|
902
970
|
|
|
903
971
|
- `url` **[string][3]** a fragment to check
|
|
904
972
|
|
|
973
|
+
Returns **[Promise][5]<any>**
|
|
974
|
+
|
|
905
975
|
### seeInField
|
|
906
976
|
|
|
907
977
|
Checks that the given input field or textarea equals to given value.
|
|
@@ -919,6 +989,8 @@ I.seeInField('#searchform input','Search');
|
|
|
919
989
|
- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
|
|
920
990
|
- `value` **[string][3]** value to check.
|
|
921
991
|
|
|
992
|
+
Returns **[Promise][5]<any>**
|
|
993
|
+
|
|
922
994
|
### seeInSource
|
|
923
995
|
|
|
924
996
|
Checks that the current page contains the given string in its raw source code.
|
|
@@ -931,6 +1003,8 @@ I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
|
931
1003
|
|
|
932
1004
|
- `text` **[string][3]** value to check.
|
|
933
1005
|
|
|
1006
|
+
Returns **[Promise][5]<any>**
|
|
1007
|
+
|
|
934
1008
|
### seeInTitle
|
|
935
1009
|
|
|
936
1010
|
Checks that title contains text.
|
|
@@ -943,6 +1017,8 @@ I.seeInTitle('Home Page');
|
|
|
943
1017
|
|
|
944
1018
|
- `text` **[string][3]** text value to check.
|
|
945
1019
|
|
|
1020
|
+
Returns **[Promise][5]<any>**
|
|
1021
|
+
|
|
946
1022
|
### seeNumberOfElements
|
|
947
1023
|
|
|
948
1024
|
Asserts that an element appears a given number of times in the DOM.
|
|
@@ -957,6 +1033,8 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
957
1033
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
958
1034
|
- `num` **[number][11]** number of elements.
|
|
959
1035
|
|
|
1036
|
+
Returns **[Promise][5]<any>**
|
|
1037
|
+
|
|
960
1038
|
### seeNumberOfVisibleElements
|
|
961
1039
|
|
|
962
1040
|
Asserts that an element is visible a given number of times.
|
|
@@ -971,6 +1049,8 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
971
1049
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
972
1050
|
- `num` **[number][11]** number of elements.
|
|
973
1051
|
|
|
1052
|
+
Returns **[Promise][5]<any>**
|
|
1053
|
+
|
|
974
1054
|
### selectOption
|
|
975
1055
|
|
|
976
1056
|
Selects an option in a drop-down select.
|
|
@@ -997,6 +1077,8 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
997
1077
|
- `select` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
998
1078
|
- `option` **([string][3] | [Array][10]<any>)** visible text or value of option.
|
|
999
1079
|
|
|
1080
|
+
Returns **[Promise][5]<any>**
|
|
1081
|
+
|
|
1000
1082
|
### setCookie
|
|
1001
1083
|
|
|
1002
1084
|
Sets cookie(s).
|
|
@@ -1015,8 +1097,10 @@ I.setCookie([
|
|
|
1015
1097
|
|
|
1016
1098
|
#### Parameters
|
|
1017
1099
|
|
|
1018
|
-
- `cookie` **(Cookie | [Array][10]<Cookie>)** a cookie object or array of cookie objects.
|
|
1019
|
-
|
|
1100
|
+
- `cookie` **(Cookie | [Array][10]<Cookie>)** a cookie object or array of cookie objects.
|
|
1101
|
+
|
|
1102
|
+
Returns **[Promise][5]<any>** Wrapper for `.cookies.set(cookie)`.
|
|
1103
|
+
[See more][14]
|
|
1020
1104
|
|
|
1021
1105
|
### triggerMouseEvent
|
|
1022
1106
|
|
|
@@ -1051,6 +1135,8 @@ I.uncheckOption('agree', '//form');
|
|
|
1051
1135
|
- `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
1052
1136
|
- `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1053
1137
|
|
|
1138
|
+
Returns **[Promise][5]<any>**
|
|
1139
|
+
|
|
1054
1140
|
### wait
|
|
1055
1141
|
|
|
1056
1142
|
Pauses execution for a number of seconds.
|
|
@@ -1063,6 +1149,8 @@ I.wait(2); // wait 2 secs
|
|
|
1063
1149
|
|
|
1064
1150
|
- `sec` **[number][11]** number of second to wait.
|
|
1065
1151
|
|
|
1152
|
+
Returns **[Promise][5]<any>**
|
|
1153
|
+
|
|
1066
1154
|
### waitForDetached
|
|
1067
1155
|
|
|
1068
1156
|
Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
@@ -1077,6 +1165,8 @@ I.waitForDetached('#popup');
|
|
|
1077
1165
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1078
1166
|
- `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
|
|
1079
1167
|
|
|
1168
|
+
Returns **[Promise][5]<any>**
|
|
1169
|
+
|
|
1080
1170
|
### waitForElement
|
|
1081
1171
|
|
|
1082
1172
|
Waits for element to be present on page (by default waits for 1sec).
|
|
@@ -1092,6 +1182,8 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
1092
1182
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1093
1183
|
- `sec` **[number][11]?** (optional, `1` by default) time in seconds to wait
|
|
1094
1184
|
|
|
1185
|
+
Returns **[Promise][5]<any>**
|
|
1186
|
+
|
|
1095
1187
|
### waitForFunction
|
|
1096
1188
|
|
|
1097
1189
|
Waits for a function to return true (waits for 1 sec by default).
|
|
@@ -1109,10 +1201,12 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
1109
1201
|
|
|
1110
1202
|
#### Parameters
|
|
1111
1203
|
|
|
1112
|
-
- `fn` **([string][3] | [function][
|
|
1204
|
+
- `fn` **([string][3] | [function][8])** to be executed in browser context.
|
|
1113
1205
|
- `argsOrSec` **([Array][10]<any> | [number][11])?** (optional, `1` by default) arguments for function or seconds.
|
|
1114
1206
|
- `sec` **[number][11]?** (optional, `1` by default) time in seconds to wait
|
|
1115
1207
|
|
|
1208
|
+
Returns **[Promise][5]<any>**
|
|
1209
|
+
|
|
1116
1210
|
### waitForInvisible
|
|
1117
1211
|
|
|
1118
1212
|
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
@@ -1127,6 +1221,8 @@ I.waitForInvisible('#popup');
|
|
|
1127
1221
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1128
1222
|
- `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
|
|
1129
1223
|
|
|
1224
|
+
Returns **[Promise][5]<any>**
|
|
1225
|
+
|
|
1130
1226
|
### waitForText
|
|
1131
1227
|
|
|
1132
1228
|
Waits for a text to appear (by default waits for 1sec).
|
|
@@ -1144,6 +1240,8 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
1144
1240
|
- `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
|
|
1145
1241
|
- `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator.
|
|
1146
1242
|
|
|
1243
|
+
Returns **[Promise][5]<any>**
|
|
1244
|
+
|
|
1147
1245
|
### waitForVisible
|
|
1148
1246
|
|
|
1149
1247
|
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
@@ -1158,6 +1256,8 @@ I.waitForVisible('#popup');
|
|
|
1158
1256
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1159
1257
|
- `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
|
|
1160
1258
|
|
|
1259
|
+
Returns **[Promise][5]<any>**
|
|
1260
|
+
|
|
1161
1261
|
### waitToHide
|
|
1162
1262
|
|
|
1163
1263
|
Waits for an element to hide (by default waits for 1sec).
|
|
@@ -1172,6 +1272,8 @@ I.waitToHide('#popup');
|
|
|
1172
1272
|
- `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
1173
1273
|
- `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
|
|
1174
1274
|
|
|
1275
|
+
Returns **[Promise][5]<any>**
|
|
1276
|
+
|
|
1175
1277
|
[1]: https://github.com/segmentio/nightmare
|
|
1176
1278
|
|
|
1177
1279
|
[2]: https://github.com/segmentio/nightmare#api
|
|
@@ -1180,13 +1282,13 @@ I.waitToHide('#popup');
|
|
|
1180
1282
|
|
|
1181
1283
|
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
1182
1284
|
|
|
1183
|
-
[5]: https://
|
|
1285
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1184
1286
|
|
|
1185
|
-
[6]: https://
|
|
1287
|
+
[6]: https://github.com/rosshinkley/nightmare-upload#important-note-about-setting-file-upload-inputs
|
|
1186
1288
|
|
|
1187
|
-
[7]: https://
|
|
1289
|
+
[7]: https://vuejs.org/v2/api/#Vue-nextTick
|
|
1188
1290
|
|
|
1189
|
-
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
1291
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1190
1292
|
|
|
1191
1293
|
[9]: https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2
|
|
1192
1294
|
|