codeceptjs 2.1.3 → 2.2.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 +125 -37
- package/README.md +15 -22
- package/bin/codecept.js +4 -1
- package/docs/acceptance.md +44 -1
- package/docs/advanced.md +1 -1
- package/docs/angular.md +6 -9
- package/docs/basics.md +388 -75
- package/docs/bdd.md +4 -3
- package/docs/best.md +1 -1
- package/docs/books.md +31 -0
- package/docs/build/Appium.js +215 -176
- package/docs/build/Nightmare.js +618 -489
- package/docs/build/Polly.js +189 -0
- package/docs/build/Protractor.js +747 -608
- package/docs/build/Puppeteer.js +914 -633
- package/docs/build/REST.js +1 -1
- package/docs/build/TestCafe.js +1835 -0
- package/docs/build/WebDriver.js +861 -805
- package/docs/build/WebDriverIO.js +616 -617
- package/docs/changelog.md +410 -316
- package/docs/commands.md +6 -6
- package/docs/community-helpers.md +2 -0
- package/docs/detox.md +235 -0
- package/docs/examples.md +23 -0
- package/docs/helpers/ApiDataFactory.md +11 -10
- package/docs/helpers/Appium.md +130 -61
- package/docs/helpers/Detox.md +579 -0
- package/docs/helpers/FileSystem.md +2 -1
- package/docs/helpers/Mochawesome.md +1 -0
- package/docs/helpers/Nightmare.md +348 -128
- package/docs/helpers/Polly.md +85 -0
- package/docs/helpers/Protractor.md +451 -184
- package/docs/helpers/Puppeteer-firefox.md +55 -0
- package/docs/helpers/Puppeteer.md +619 -183
- package/docs/helpers/REST.md +17 -16
- package/docs/helpers/SeleniumWebdriver.md +9 -8
- package/docs/helpers/TestCafe.md +1168 -0
- package/docs/helpers/WebDriver.md +600 -291
- package/docs/helpers/WebDriverIO.md +393 -278
- package/docs/helpers.md +37 -18
- package/docs/locators.md +2 -0
- package/docs/mobile-react-native-locators.md +64 -0
- package/docs/mobile.md +5 -0
- package/docs/plugins.md +54 -13
- package/docs/puppeteer.md +74 -26
- package/docs/quickstart.md +47 -12
- package/docs/react.md +67 -0
- package/docs/reports.md +1 -1
- package/docs/{webapi/_keys.mustache → shared/keys.mustache} +0 -0
- package/docs/shared/react.mustache +1 -0
- package/docs/testcafe.md +157 -0
- package/docs/videos.md +19 -0
- package/docs/webapi/amOnPage.mustache +1 -1
- package/docs/webapi/appendField.mustache +2 -2
- package/docs/webapi/attachFile.mustache +2 -2
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/clearField.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +3 -3
- package/docs/webapi/dontSee.mustache +6 -3
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +7 -1
- package/docs/webapi/dontSeeCookie.mustache +5 -1
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +6 -1
- package/docs/webapi/dontSeeElement.mustache +5 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +5 -1
- package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +7 -2
- package/docs/webapi/dontSeeInSource.mustache +5 -1
- package/docs/webapi/dontSeeInTitle.mustache +5 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +2 -2
- package/docs/webapi/dragAndDrop.mustache +2 -2
- package/docs/webapi/dragSlider.mustache +2 -2
- package/docs/webapi/executeAsyncScript.mustache +1 -1
- package/docs/webapi/executeScript.mustache +1 -1
- package/docs/webapi/fillField.mustache +2 -2
- package/docs/webapi/grabAttributeFrom.mustache +3 -2
- package/docs/webapi/grabBrowserLogs.mustache +3 -1
- package/docs/webapi/grabCookie.mustache +2 -1
- package/docs/webapi/grabCssPropertyFrom.mustache +3 -2
- package/docs/webapi/grabCurrentUrl.mustache +3 -1
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +19 -0
- package/docs/webapi/grabHTMLFrom.mustache +2 -1
- package/docs/webapi/grabNumberOfOpenTabs.mustache +4 -2
- package/docs/webapi/grabNumberOfVisibleElements.mustache +3 -2
- package/docs/webapi/grabPageScrollPosition.mustache +3 -1
- package/docs/webapi/grabSource.mustache +3 -1
- package/docs/webapi/grabTextFrom.mustache +2 -1
- package/docs/webapi/grabTitle.mustache +3 -1
- package/docs/webapi/grabValueFrom.mustache +2 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/resizeWindow.mustache +2 -2
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +3 -3
- package/docs/webapi/say.mustache +2 -2
- package/docs/webapi/scrollPageToBottom.mustache +1 -1
- package/docs/webapi/scrollPageToTop.mustache +1 -1
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +2 -2
- package/docs/webapi/seeAttributesOnElements.mustache +3 -3
- package/docs/webapi/seeCheckboxIsChecked.mustache +2 -1
- package/docs/webapi/seeCookie.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -2
- package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInCurrentUrl.mustache +1 -1
- package/docs/webapi/seeInField.mustache +2 -2
- package/docs/webapi/seeInSource.mustache +1 -1
- package/docs/webapi/seeInTitle.mustache +5 -1
- package/docs/webapi/seeNumberOfElements.mustache +10 -0
- package/docs/webapi/seeNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/setCookie.mustache +1 -1
- package/docs/webapi/switchTo.mustache +6 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/wait.mustache +1 -2
- package/docs/webapi/waitForDetached.mustache +3 -3
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +1 -1
- package/docs/webapi/waitForFunction.mustache +3 -3
- package/docs/webapi/waitForInvisible.mustache +3 -3
- package/docs/webapi/waitForText.mustache +3 -3
- package/docs/webapi/waitForValue.mustache +3 -3
- package/docs/webapi/waitForVisible.mustache +3 -3
- package/docs/webapi/waitInUrl.mustache +2 -2
- package/docs/webapi/waitNumberOfVisibleElements.mustache +3 -3
- package/docs/webapi/waitToHide.mustache +3 -3
- package/docs/webapi/waitUntil.mustache +3 -3
- package/docs/webapi/waitUrlEquals.mustache +2 -2
- package/docs/webdriver.md +453 -0
- package/lib/codecept.js +11 -9
- package/lib/command/definitions.js +183 -30
- package/lib/command/gherkin/snippets.js +29 -9
- package/lib/command/init.js +31 -9
- package/lib/command/run-multiple.js +46 -59
- package/lib/command/utils.js +1 -1
- package/lib/container.js +30 -4
- package/lib/data/dataScenarioConfig.js +18 -0
- package/lib/helper/Appium.js +24 -24
- package/lib/helper/Nightmare.js +81 -84
- package/lib/helper/Polly.js +189 -0
- package/lib/helper/Protractor.js +96 -86
- package/lib/helper/Puppeteer.js +238 -113
- package/lib/helper/REST.js +1 -1
- package/lib/helper/TestCafe.js +1257 -0
- package/lib/helper/WebDriver.js +217 -277
- package/lib/helper/WebDriverIO.js +75 -75
- package/lib/helper/clientscripts/nightmare.js +8 -0
- package/lib/helper/extras/React.js +55 -0
- package/lib/helper/testcafe/testControllerHolder.js +42 -0
- package/lib/helper/testcafe/testcafe-utils.js +63 -0
- package/lib/history.js +39 -0
- package/lib/hooks.js +25 -1
- package/lib/interfaces/gherkin.js +17 -1
- package/lib/interfaces/scenarioConfig.js +2 -2
- package/lib/listener/config.js +3 -3
- package/lib/locator.js +6 -0
- package/lib/pause.js +22 -1
- package/lib/plugin/allure.js +63 -0
- package/lib/plugin/autoLogin.js +65 -16
- package/lib/plugin/puppeteerCoverage.js +6 -1
- package/lib/plugin/stepByStepReport.js +4 -3
- package/lib/scenario.js +23 -17
- package/lib/step.js +5 -2
- package/lib/ui.js +1 -1
- package/lib/utils.js +70 -20
- package/package.json +20 -19
- package/translations/de-DE.js +69 -0
- package/translations/index.js +1 -0
- package/docs/video.md +0 -26
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
id: Nightmare
|
|
3
3
|
title: Nightmare
|
|
4
4
|
---
|
|
5
|
+
|
|
5
6
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
6
7
|
|
|
7
8
|
## Nightmare
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Extends Helper
|
|
10
11
|
|
|
11
12
|
Nightmare helper wraps [Nightmare][1] library to provide
|
|
12
13
|
fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
|
|
@@ -20,14 +21,14 @@ Requires `nightmare` package to be installed.
|
|
|
20
21
|
This helper should be configured in codecept.json or codecept.conf.js
|
|
21
22
|
|
|
22
23
|
- `url` - base url of website to be tested
|
|
23
|
-
- `restart`
|
|
24
|
-
- `disableScreenshots`
|
|
25
|
-
- `uniqueScreenshotNames`
|
|
26
|
-
- `fullPageScreenshots`
|
|
27
|
-
- `keepBrowserState`
|
|
28
|
-
- `keepCookies`
|
|
24
|
+
- `restart` - restart browser between tests.
|
|
25
|
+
- `disableScreenshots` - don't save screenshot on failure.
|
|
26
|
+
- `uniqueScreenshotNames` - option to prevent screenshot override if you have scenarios with the same name in different suites.
|
|
27
|
+
- `fullPageScreenshots` - make full page screenshots on failure.
|
|
28
|
+
- `keepBrowserState` - keep browser state between tests when `restart` set to false.
|
|
29
|
+
- `keepCookies` - keep cookies between tests when `restart` set to false.
|
|
29
30
|
- `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 500.
|
|
30
|
-
- `waitForTimeout`: (optional) default wait
|
|
31
|
+
- `waitForTimeout`: (optional) default wait\ timeout in ms. Default: 1000.
|
|
31
32
|
- `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
32
33
|
|
|
33
34
|
|
|
@@ -76,10 +77,10 @@ I.amOnPage('/login'); // opens a login page
|
|
|
76
77
|
|
|
77
78
|
#### Parameters
|
|
78
79
|
|
|
79
|
-
- `url`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- `headers`
|
|
80
|
+
- `url` [string][3] url path or global url.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
- `headers` {object} list of request headers can be passed
|
|
83
84
|
|
|
84
85
|
### appendField
|
|
85
86
|
|
|
@@ -92,8 +93,10 @@ I.appendField('#myTextField', 'appended');
|
|
|
92
93
|
|
|
93
94
|
#### Parameters
|
|
94
95
|
|
|
95
|
-
- `field`
|
|
96
|
-
- `value`
|
|
96
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator
|
|
97
|
+
- `value` [string][3] text value to append.
|
|
98
|
+
|
|
99
|
+
|
|
97
100
|
|
|
98
101
|
### attachFile
|
|
99
102
|
|
|
@@ -108,9 +111,10 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
108
111
|
|
|
109
112
|
#### Parameters
|
|
110
113
|
|
|
111
|
-
- `locator`
|
|
112
|
-
- `pathToFile`
|
|
113
|
-
|
|
114
|
+
- `locator` CSS locator (XPath not allowed)
|
|
115
|
+
- `pathToFile` [string][3] local file path relative to codecept.json config file.
|
|
116
|
+
|
|
117
|
+
Doesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more][5])
|
|
114
118
|
|
|
115
119
|
### checkOption
|
|
116
120
|
|
|
@@ -127,8 +131,10 @@ I.checkOption('agree', '//form');
|
|
|
127
131
|
|
|
128
132
|
#### Parameters
|
|
129
133
|
|
|
130
|
-
- `field`
|
|
131
|
-
- `context`
|
|
134
|
+
- `field` ([string][3] \| [object][4]) checkbox located by label | name | CSS | XPath | strict locator.
|
|
135
|
+
- `context` [string][3] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
136
|
+
|
|
137
|
+
|
|
132
138
|
|
|
133
139
|
### clearCookie
|
|
134
140
|
|
|
@@ -142,7 +148,9 @@ I.clearCookie('test');
|
|
|
142
148
|
|
|
143
149
|
#### Parameters
|
|
144
150
|
|
|
145
|
-
- `cookie`
|
|
151
|
+
- `cookie` [string][3] (optional, `null` by default) cookie name
|
|
152
|
+
|
|
153
|
+
|
|
146
154
|
|
|
147
155
|
### clearField
|
|
148
156
|
|
|
@@ -156,7 +164,10 @@ I.clearField('#email');
|
|
|
156
164
|
|
|
157
165
|
#### Parameters
|
|
158
166
|
|
|
159
|
-
- `field`
|
|
167
|
+
- `field`
|
|
168
|
+
- `editable` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
|
|
169
|
+
|
|
170
|
+
|
|
160
171
|
|
|
161
172
|
### click
|
|
162
173
|
|
|
@@ -175,7 +186,7 @@ I.click('Submit');
|
|
|
175
186
|
// CSS button
|
|
176
187
|
I.click('#form input[type=submit]');
|
|
177
188
|
// XPath
|
|
178
|
-
I.click('//form
|
|
189
|
+
I.click('//form/[@type=submit]');
|
|
179
190
|
// link in context
|
|
180
191
|
I.click('Logout', '#nav');
|
|
181
192
|
// using strict locator
|
|
@@ -184,8 +195,10 @@ I.click({css: 'nav a.login'});
|
|
|
184
195
|
|
|
185
196
|
#### Parameters
|
|
186
197
|
|
|
187
|
-
- `locator`
|
|
188
|
-
- `context`
|
|
198
|
+
- `locator` ([string][3] \| [object][4]) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
199
|
+
- `context` ([string][3] \| [object][4]) (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
200
|
+
|
|
201
|
+
|
|
189
202
|
|
|
190
203
|
### dontSee
|
|
191
204
|
|
|
@@ -193,54 +206,89 @@ Opposite to `see`. Checks that a text is not present on a page.
|
|
|
193
206
|
Use context parameter to narrow down the search.
|
|
194
207
|
|
|
195
208
|
```js
|
|
196
|
-
I.dontSee('Login'); // assume we are already logged in
|
|
209
|
+
I.dontSee('Login'); // assume we are already logged in.
|
|
210
|
+
I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
197
211
|
```
|
|
198
212
|
|
|
199
213
|
#### Parameters
|
|
200
214
|
|
|
201
|
-
- `text`
|
|
202
|
-
- `context`
|
|
215
|
+
- `text` [string][3] which is not present.
|
|
216
|
+
- `context` ([string][3] \| [object][4]) (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
217
|
+
|
|
203
218
|
|
|
204
219
|
### dontSeeCheckboxIsChecked
|
|
205
220
|
|
|
206
221
|
Verifies that the specified checkbox is not checked.
|
|
207
222
|
|
|
223
|
+
```js
|
|
224
|
+
I.dontSeeeCheckboxIsChedcked('#agree'); // located by ID
|
|
225
|
+
I.dontSeeeCheckboxIsChedcked('I agree to terms'); // located by label
|
|
226
|
+
I.dontSeeeCheckboxIsChedcked('agree'); // located by name
|
|
227
|
+
```
|
|
228
|
+
|
|
208
229
|
#### Parameters
|
|
209
230
|
|
|
210
|
-
- `field`
|
|
231
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
|
|
232
|
+
|
|
233
|
+
|
|
211
234
|
|
|
212
235
|
### dontSeeCookie
|
|
213
236
|
|
|
214
237
|
Checks that cookie with given name does not exist.
|
|
215
238
|
|
|
239
|
+
```js
|
|
240
|
+
I.dontSeeCookie('auth'); // no auth cookie
|
|
241
|
+
```
|
|
242
|
+
|
|
216
243
|
#### Parameters
|
|
217
244
|
|
|
218
|
-
- `name`
|
|
245
|
+
- `name` [string][3] cookie name.
|
|
246
|
+
|
|
247
|
+
|
|
219
248
|
|
|
220
249
|
### dontSeeCurrentUrlEquals
|
|
221
250
|
|
|
222
251
|
Checks that current url is not equal to provided one.
|
|
223
252
|
If a relative url provided, a configured url will be prepended to it.
|
|
224
253
|
|
|
254
|
+
```js
|
|
255
|
+
I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
|
|
256
|
+
I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
|
|
257
|
+
```
|
|
258
|
+
|
|
225
259
|
#### Parameters
|
|
226
260
|
|
|
227
|
-
- `url`
|
|
261
|
+
- `url` [string][3] value to check.
|
|
262
|
+
|
|
263
|
+
|
|
228
264
|
|
|
229
265
|
### dontSeeElement
|
|
230
266
|
|
|
231
267
|
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
232
268
|
|
|
269
|
+
```js
|
|
270
|
+
I.dontSeeElement('.modal'); // modal is not shown
|
|
271
|
+
```
|
|
272
|
+
|
|
233
273
|
#### Parameters
|
|
234
274
|
|
|
235
|
-
- `locator`
|
|
275
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|Strict locator.
|
|
276
|
+
|
|
277
|
+
|
|
236
278
|
|
|
237
279
|
### dontSeeElementInDOM
|
|
238
280
|
|
|
239
281
|
Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
240
282
|
|
|
283
|
+
```js
|
|
284
|
+
I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
285
|
+
```
|
|
286
|
+
|
|
241
287
|
#### Parameters
|
|
242
288
|
|
|
243
|
-
- `locator`
|
|
289
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|Strict locator.
|
|
290
|
+
|
|
291
|
+
|
|
244
292
|
|
|
245
293
|
### dontSeeInCurrentUrl
|
|
246
294
|
|
|
@@ -248,33 +296,55 @@ Checks that current url does not contain a provided fragment.
|
|
|
248
296
|
|
|
249
297
|
#### Parameters
|
|
250
298
|
|
|
251
|
-
- `url`
|
|
299
|
+
- `url` [string][3] value to check.
|
|
300
|
+
|
|
301
|
+
|
|
252
302
|
|
|
253
303
|
### dontSeeInField
|
|
254
304
|
|
|
255
305
|
Checks that value of input field or textare doesn't equal to given value
|
|
256
306
|
Opposite to `seeInField`.
|
|
257
307
|
|
|
308
|
+
```js
|
|
309
|
+
I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
310
|
+
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
311
|
+
```
|
|
312
|
+
|
|
258
313
|
#### Parameters
|
|
259
314
|
|
|
260
|
-
- `field`
|
|
261
|
-
- `value`
|
|
315
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
|
|
316
|
+
- `value` [string][3] value to check.
|
|
317
|
+
|
|
318
|
+
|
|
262
319
|
|
|
263
320
|
### dontSeeInSource
|
|
264
321
|
|
|
265
322
|
Checks that the current page does not contains the given string in its raw source code.
|
|
266
323
|
|
|
324
|
+
```js
|
|
325
|
+
I.dontSeeInSource('<!--'); // no comments in source
|
|
326
|
+
```
|
|
327
|
+
|
|
267
328
|
#### Parameters
|
|
268
329
|
|
|
269
|
-
- `text`
|
|
330
|
+
- `text`
|
|
331
|
+
- `value` [string][3] to check.
|
|
332
|
+
|
|
333
|
+
|
|
270
334
|
|
|
271
335
|
### dontSeeInTitle
|
|
272
336
|
|
|
273
337
|
Checks that title does not contain text.
|
|
274
338
|
|
|
339
|
+
```js
|
|
340
|
+
I.dontSeeInTitle('Error');
|
|
341
|
+
```
|
|
342
|
+
|
|
275
343
|
#### Parameters
|
|
276
344
|
|
|
277
|
-
- `text`
|
|
345
|
+
- `text` [string][3] value to check.
|
|
346
|
+
|
|
347
|
+
|
|
278
348
|
|
|
279
349
|
### doubleClick
|
|
280
350
|
|
|
@@ -290,19 +360,21 @@ I.doubleClick('.btn.edit');
|
|
|
290
360
|
|
|
291
361
|
#### Parameters
|
|
292
362
|
|
|
293
|
-
- `locator`
|
|
294
|
-
- `context`
|
|
363
|
+
- `locator` ([string][3] \| [object][4]) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
364
|
+
- `context` ([string][3] \| [object][4]) (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
365
|
+
|
|
366
|
+
|
|
295
367
|
|
|
296
368
|
### executeAsyncScript
|
|
297
369
|
|
|
298
370
|
Executes async script on page.
|
|
299
371
|
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
300
372
|
|
|
301
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][
|
|
373
|
+
Example: In Vue.js to make components completely rendered we are waiting for [nextTick][6].
|
|
302
374
|
|
|
303
375
|
```js
|
|
304
376
|
I.executeAsyncScript(function(done) {
|
|
305
|
-
Vue.nextTick(done); // waiting for next tick
|
|
377
|
+
Vue.nextTick(done); // waiting for next tick
|
|
306
378
|
});
|
|
307
379
|
```
|
|
308
380
|
|
|
@@ -311,14 +383,14 @@ Additional arguments can be passed as well, while `done` function is always last
|
|
|
311
383
|
|
|
312
384
|
```js
|
|
313
385
|
let val = await I.executeAsyncScript(function(url, done) {
|
|
314
|
-
// in browser context
|
|
315
|
-
$.ajax(url, { success: (data) => done(data); }
|
|
386
|
+
// in browser context
|
|
387
|
+
$.ajax(url, { success: (data) => done(data); }
|
|
316
388
|
}, 'http://ajax.callback.url/');
|
|
317
389
|
```
|
|
318
390
|
|
|
319
391
|
#### Parameters
|
|
320
392
|
|
|
321
|
-
- `fn`
|
|
393
|
+
- `fn` ([string][3] \| [function][7]) function to be executed in browser context.
|
|
322
394
|
|
|
323
395
|
### executeScript
|
|
324
396
|
|
|
@@ -332,8 +404,8 @@ Example with jQuery DatePicker:
|
|
|
332
404
|
```js
|
|
333
405
|
// change date of jQuery DatePicker
|
|
334
406
|
I.executeScript(function() {
|
|
335
|
-
// now we are inside browser context
|
|
336
|
-
$('date').datetimepicker('setDate', new Date());
|
|
407
|
+
// now we are inside browser context
|
|
408
|
+
$('date').datetimepicker('setDate', new Date());
|
|
337
409
|
});
|
|
338
410
|
```
|
|
339
411
|
|
|
@@ -341,14 +413,14 @@ Can return values. Don't forget to use `await` to get them.
|
|
|
341
413
|
|
|
342
414
|
```js
|
|
343
415
|
let date = await I.executeScript(function(el) {
|
|
344
|
-
// only basic types can be returned
|
|
345
|
-
return $(el).datetimepicker('getDate').toString();
|
|
416
|
+
// only basic types can be returned
|
|
417
|
+
return $(el).datetimepicker('getDate').toString();
|
|
346
418
|
}, '#date'); // passing jquery selector
|
|
347
419
|
```
|
|
348
420
|
|
|
349
421
|
#### Parameters
|
|
350
422
|
|
|
351
|
-
- `fn`
|
|
423
|
+
- `fn` ([string][3] \| [function][7]) function to be executed in browser context.
|
|
352
424
|
|
|
353
425
|
### fillField
|
|
354
426
|
|
|
@@ -368,14 +440,16 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
368
440
|
|
|
369
441
|
#### Parameters
|
|
370
442
|
|
|
371
|
-
- `field`
|
|
372
|
-
- `value`
|
|
443
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
|
|
444
|
+
- `value` [string][3] text value to fill.
|
|
445
|
+
|
|
446
|
+
|
|
373
447
|
|
|
374
448
|
### grabAttributeFrom
|
|
375
449
|
|
|
376
450
|
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
377
451
|
An array as a result will be returned if there are more than one matched element.
|
|
378
|
-
Resumes test execution, so
|
|
452
|
+
Resumes test execution, so should be used inside async with `await` operator.
|
|
379
453
|
|
|
380
454
|
```js
|
|
381
455
|
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
@@ -383,14 +457,19 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
383
457
|
|
|
384
458
|
#### Parameters
|
|
385
459
|
|
|
386
|
-
- `locator`
|
|
387
|
-
- `attr`
|
|
460
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
461
|
+
- `attr` [string][3] attribute name.
|
|
462
|
+
|
|
463
|
+
Returns [Promise][8]<[string][3]> attribute value
|
|
464
|
+
|
|
465
|
+
|
|
388
466
|
|
|
389
467
|
### grabCookie
|
|
390
468
|
|
|
391
469
|
Gets a cookie object by name.
|
|
392
470
|
If none provided gets all cookies.
|
|
393
|
-
|
|
471
|
+
|
|
472
|
+
- Resumes test execution, so should be used inside async with `await` operator.
|
|
394
473
|
|
|
395
474
|
```js
|
|
396
475
|
let cookie = await I.grabCookie('auth');
|
|
@@ -399,9 +478,13 @@ assert(cookie.value, '123456');
|
|
|
399
478
|
|
|
400
479
|
#### Parameters
|
|
401
480
|
|
|
402
|
-
- `name`
|
|
403
|
-
|
|
404
|
-
|
|
481
|
+
- `name` cookie name.
|
|
482
|
+
|
|
483
|
+
Returns [Promise][8]<[string][3]> attribute value
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
Returns any Promise<object> Cookie 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 }).`
|
|
405
488
|
|
|
406
489
|
### grabCurrentUrl
|
|
407
490
|
|
|
@@ -413,6 +496,10 @@ let url = await I.grabCurrentUrl();
|
|
|
413
496
|
console.log(`Current URL is [${url}]`);
|
|
414
497
|
```
|
|
415
498
|
|
|
499
|
+
Returns [Promise][8]<[string][3]> current URL
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
416
503
|
### grabHAR
|
|
417
504
|
|
|
418
505
|
Get HAR
|
|
@@ -425,7 +512,7 @@ fs.writeFileSync('sample.har', JSON.stringify({log: har}));
|
|
|
425
512
|
### grabHTMLFrom
|
|
426
513
|
|
|
427
514
|
Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
428
|
-
Resumes test execution, so
|
|
515
|
+
Resumes test execution, so should be used inside async function with `await` operator.
|
|
429
516
|
If more than one element is found - an array of HTMLs returned.
|
|
430
517
|
|
|
431
518
|
```js
|
|
@@ -436,31 +523,43 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
436
523
|
|
|
437
524
|
- `locator` element located by CSS|XPath|strict locator.
|
|
438
525
|
|
|
526
|
+
Returns [Promise][8]<[string][3]> HTML code for an element
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
439
530
|
### grabNumberOfVisibleElements
|
|
440
531
|
|
|
441
532
|
Grab number of visible elements by locator.
|
|
442
533
|
|
|
443
534
|
```js
|
|
444
|
-
I.grabNumberOfVisibleElements('p');
|
|
535
|
+
let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
445
536
|
```
|
|
446
537
|
|
|
447
538
|
#### Parameters
|
|
448
539
|
|
|
449
|
-
- `locator`
|
|
540
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
|
|
541
|
+
|
|
542
|
+
Returns [Promise][8]<[number][9]> number of visible elements
|
|
543
|
+
|
|
544
|
+
|
|
450
545
|
|
|
451
546
|
### grabPageScrollPosition
|
|
452
547
|
|
|
453
548
|
Retrieves a page scroll position and returns it to test.
|
|
454
|
-
Resumes test execution, so
|
|
549
|
+
Resumes test execution, so should be used inside an async function with `await` operator.
|
|
455
550
|
|
|
456
551
|
```js
|
|
457
552
|
let { x, y } = await I.grabPageScrollPosition();
|
|
458
553
|
```
|
|
459
554
|
|
|
555
|
+
Returns [Promise][8]<[object][4]> scroll position
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
460
559
|
### grabTextFrom
|
|
461
560
|
|
|
462
561
|
Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
463
|
-
Resumes test execution, so
|
|
562
|
+
Resumes test execution, so should be used inside async with `await` operator.
|
|
464
563
|
|
|
465
564
|
```js
|
|
466
565
|
let pin = await I.grabTextFrom('#pin');
|
|
@@ -472,19 +571,27 @@ If multiple elements found returns an array of texts.
|
|
|
472
571
|
|
|
473
572
|
- `locator` element located by CSS|XPath|strict locator.
|
|
474
573
|
|
|
574
|
+
Returns [Promise][8]<[string][3]> attribute value
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
475
578
|
### grabTitle
|
|
476
579
|
|
|
477
580
|
Retrieves a page title and returns it to test.
|
|
478
|
-
Resumes test execution, so
|
|
581
|
+
Resumes test execution, so should be used inside async with `await` operator.
|
|
479
582
|
|
|
480
583
|
```js
|
|
481
584
|
let title = await I.grabTitle();
|
|
482
585
|
```
|
|
483
586
|
|
|
587
|
+
Returns [Promise][8]<[string][3]> title
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
484
591
|
### grabValueFrom
|
|
485
592
|
|
|
486
593
|
Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
487
|
-
Resumes test execution, so
|
|
594
|
+
Resumes test execution, so should be used inside async function with `await` operator.
|
|
488
595
|
|
|
489
596
|
```js
|
|
490
597
|
let email = await I.grabValueFrom('input[name=email]');
|
|
@@ -492,7 +599,11 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
492
599
|
|
|
493
600
|
#### Parameters
|
|
494
601
|
|
|
495
|
-
- `locator`
|
|
602
|
+
- `locator` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
|
|
603
|
+
|
|
604
|
+
Returns [Promise][8]<[string][3]> attribute value
|
|
605
|
+
|
|
606
|
+
|
|
496
607
|
|
|
497
608
|
### haveHeader
|
|
498
609
|
|
|
@@ -520,13 +631,15 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
520
631
|
|
|
521
632
|
#### Parameters
|
|
522
633
|
|
|
523
|
-
- `locator`
|
|
524
|
-
- `offsetX`
|
|
525
|
-
- `offsetY`
|
|
634
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
|
|
635
|
+
- `offsetX` [number][9] (optional, `0` by default) X-axis offset.
|
|
636
|
+
- `offsetY` [number][9] (optional, `0` by default) Y-axis offset.
|
|
637
|
+
|
|
638
|
+
|
|
526
639
|
|
|
527
640
|
### pressKey
|
|
528
641
|
|
|
529
|
-
Sends [input event][
|
|
642
|
+
Sends [input event][10] on a page.
|
|
530
643
|
Can submit special keys like 'Enter', 'Backspace', etc
|
|
531
644
|
|
|
532
645
|
#### Parameters
|
|
@@ -545,6 +658,9 @@ Reload the current page.
|
|
|
545
658
|
I.refreshPage();
|
|
546
659
|
```
|
|
547
660
|
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
548
664
|
### resizeWindow
|
|
549
665
|
|
|
550
666
|
Resize the current window to provided width and height.
|
|
@@ -552,8 +668,10 @@ First parameter can be set to `maximize`.
|
|
|
552
668
|
|
|
553
669
|
#### Parameters
|
|
554
670
|
|
|
555
|
-
- `width`
|
|
556
|
-
- `height`
|
|
671
|
+
- `width` [number][9] width in pixels or `maximize`.
|
|
672
|
+
- `height` [number][9] height in pixels.
|
|
673
|
+
|
|
674
|
+
|
|
557
675
|
|
|
558
676
|
### rightClick
|
|
559
677
|
|
|
@@ -570,13 +688,15 @@ I.rightClick('Click me', '.context');
|
|
|
570
688
|
|
|
571
689
|
#### Parameters
|
|
572
690
|
|
|
573
|
-
- `locator`
|
|
574
|
-
- `context`
|
|
691
|
+
- `locator` ([string][3] \| [object][4]) clickable element located by CSS|XPath|strict locator.
|
|
692
|
+
- `context` ([string][3] \| [object][4]) (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
693
|
+
|
|
694
|
+
|
|
575
695
|
|
|
576
696
|
### saveScreenshot
|
|
577
697
|
|
|
578
698
|
Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
|
|
579
|
-
Filename is relative to output folder.
|
|
699
|
+
Filename is relative to output folder.
|
|
580
700
|
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.
|
|
581
701
|
|
|
582
702
|
```js
|
|
@@ -586,8 +706,10 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
586
706
|
|
|
587
707
|
#### Parameters
|
|
588
708
|
|
|
589
|
-
- `fileName`
|
|
590
|
-
- `fullPage`
|
|
709
|
+
- `fileName` [string][3] file name to save.
|
|
710
|
+
- `fullPage` [boolean][11] (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
711
|
+
|
|
712
|
+
|
|
591
713
|
|
|
592
714
|
### scrollPageToBottom
|
|
593
715
|
|
|
@@ -597,6 +719,9 @@ Scroll page to the bottom.
|
|
|
597
719
|
I.scrollPageToBottom();
|
|
598
720
|
```
|
|
599
721
|
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
600
725
|
### scrollPageToTop
|
|
601
726
|
|
|
602
727
|
Scroll page to the top.
|
|
@@ -605,6 +730,9 @@ Scroll page to the top.
|
|
|
605
730
|
I.scrollPageToTop();
|
|
606
731
|
```
|
|
607
732
|
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
608
736
|
### scrollTo
|
|
609
737
|
|
|
610
738
|
Scrolls to element matched by locator.
|
|
@@ -617,9 +745,11 @@ I.scrollTo('#submit', 5, 5);
|
|
|
617
745
|
|
|
618
746
|
#### Parameters
|
|
619
747
|
|
|
620
|
-
- `locator`
|
|
621
|
-
- `offsetX`
|
|
622
|
-
- `offsetY`
|
|
748
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
|
|
749
|
+
- `offsetX` [number][9] (optional, `0` by default) X-axis offset.
|
|
750
|
+
- `offsetY` [number][9] (optional, `0` by default) Y-axis offset.
|
|
751
|
+
|
|
752
|
+
|
|
623
753
|
|
|
624
754
|
### see
|
|
625
755
|
|
|
@@ -634,8 +764,10 @@ I.see('Register', {css: 'form.register'}); // use strict locator
|
|
|
634
764
|
|
|
635
765
|
#### Parameters
|
|
636
766
|
|
|
637
|
-
- `text`
|
|
638
|
-
- `context`
|
|
767
|
+
- `text` [string][3] expected on page.
|
|
768
|
+
- `context` ([string][3] \| [object][4]) (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
769
|
+
|
|
770
|
+
|
|
639
771
|
|
|
640
772
|
### seeCheckboxIsChecked
|
|
641
773
|
|
|
@@ -649,7 +781,9 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
|
649
781
|
|
|
650
782
|
#### Parameters
|
|
651
783
|
|
|
652
|
-
- `field`
|
|
784
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
|
|
785
|
+
|
|
786
|
+
|
|
653
787
|
|
|
654
788
|
### seeCookie
|
|
655
789
|
|
|
@@ -661,7 +795,9 @@ I.seeCookie('Auth');
|
|
|
661
795
|
|
|
662
796
|
#### Parameters
|
|
663
797
|
|
|
664
|
-
- `name`
|
|
798
|
+
- `name` [string][3] cookie name.
|
|
799
|
+
|
|
800
|
+
|
|
665
801
|
|
|
666
802
|
### seeCurrentUrlEquals
|
|
667
803
|
|
|
@@ -676,7 +812,9 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
|
676
812
|
|
|
677
813
|
#### Parameters
|
|
678
814
|
|
|
679
|
-
- `url`
|
|
815
|
+
- `url` [string][3] value to check.
|
|
816
|
+
|
|
817
|
+
|
|
680
818
|
|
|
681
819
|
### seeElement
|
|
682
820
|
|
|
@@ -689,7 +827,9 @@ I.seeElement('#modal');
|
|
|
689
827
|
|
|
690
828
|
#### Parameters
|
|
691
829
|
|
|
692
|
-
- `locator`
|
|
830
|
+
- `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
|
|
831
|
+
|
|
832
|
+
|
|
693
833
|
|
|
694
834
|
### seeElementInDOM
|
|
695
835
|
|
|
@@ -702,7 +842,9 @@ I.seeElementInDOM('#modal');
|
|
|
702
842
|
|
|
703
843
|
#### Parameters
|
|
704
844
|
|
|
705
|
-
- `locator`
|
|
845
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
846
|
+
|
|
847
|
+
|
|
706
848
|
|
|
707
849
|
### seeInCurrentUrl
|
|
708
850
|
|
|
@@ -714,7 +856,9 @@ I.seeInCurrentUrl('/register'); // we are on registration page
|
|
|
714
856
|
|
|
715
857
|
#### Parameters
|
|
716
858
|
|
|
717
|
-
- `url`
|
|
859
|
+
- `url` [string][3] a fragment to check
|
|
860
|
+
|
|
861
|
+
|
|
718
862
|
|
|
719
863
|
### seeInField
|
|
720
864
|
|
|
@@ -730,8 +874,10 @@ I.seeInField('#searchform input','Search');
|
|
|
730
874
|
|
|
731
875
|
#### Parameters
|
|
732
876
|
|
|
733
|
-
- `field`
|
|
734
|
-
- `value`
|
|
877
|
+
- `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
|
|
878
|
+
- `value` [string][3] value to check.
|
|
879
|
+
|
|
880
|
+
|
|
735
881
|
|
|
736
882
|
### seeInSource
|
|
737
883
|
|
|
@@ -743,19 +889,27 @@ I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
|
743
889
|
|
|
744
890
|
#### Parameters
|
|
745
891
|
|
|
746
|
-
- `text`
|
|
892
|
+
- `text` [string][3] value to check.
|
|
893
|
+
|
|
894
|
+
|
|
747
895
|
|
|
748
896
|
### seeInTitle
|
|
749
897
|
|
|
750
898
|
Checks that title contains text.
|
|
751
899
|
|
|
900
|
+
```js
|
|
901
|
+
I.seeInTitle('Home Page');
|
|
902
|
+
```
|
|
903
|
+
|
|
752
904
|
#### Parameters
|
|
753
905
|
|
|
754
|
-
- `text`
|
|
906
|
+
- `text` [string][3] text value to check.
|
|
907
|
+
|
|
908
|
+
|
|
755
909
|
|
|
756
910
|
### seeNumberOfElements
|
|
757
911
|
|
|
758
|
-
|
|
912
|
+
Asserts that an element appears a given number of times in the DOM.
|
|
759
913
|
Element is located by label or name or CSS or XPath.
|
|
760
914
|
|
|
761
915
|
```js
|
|
@@ -764,8 +918,10 @@ I.seeNumberOfElements('#submitBtn', 1);
|
|
|
764
918
|
|
|
765
919
|
#### Parameters
|
|
766
920
|
|
|
767
|
-
- `
|
|
768
|
-
- `num`
|
|
921
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
922
|
+
- `num` [number][9] number of elements.
|
|
923
|
+
|
|
924
|
+
|
|
769
925
|
|
|
770
926
|
### seeNumberOfVisibleElements
|
|
771
927
|
|
|
@@ -778,8 +934,10 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
778
934
|
|
|
779
935
|
#### Parameters
|
|
780
936
|
|
|
781
|
-
- `locator`
|
|
782
|
-
- `num`
|
|
937
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
938
|
+
- `num` [number][9] number of elements.
|
|
939
|
+
|
|
940
|
+
|
|
783
941
|
|
|
784
942
|
### selectOption
|
|
785
943
|
|
|
@@ -804,8 +962,10 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
804
962
|
|
|
805
963
|
#### Parameters
|
|
806
964
|
|
|
807
|
-
- `select`
|
|
808
|
-
- `option`
|
|
965
|
+
- `select` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
|
|
966
|
+
- `option` ([string][3] \| [array][12]) visible text or value of option.
|
|
967
|
+
|
|
968
|
+
|
|
809
969
|
|
|
810
970
|
### setCookie
|
|
811
971
|
|
|
@@ -817,12 +977,14 @@ I.setCookie({name: 'auth', value: true});
|
|
|
817
977
|
|
|
818
978
|
#### Parameters
|
|
819
979
|
|
|
820
|
-
- `cookie`
|
|
821
|
-
|
|
980
|
+
- `cookie` [object][4] a cookie object.
|
|
981
|
+
|
|
982
|
+
Wrapper for `.cookies.set(cookie)`.
|
|
983
|
+
[See more][13]
|
|
822
984
|
|
|
823
985
|
### triggerMouseEvent
|
|
824
986
|
|
|
825
|
-
Sends [input event][
|
|
987
|
+
Sends [input event][14] on a page.
|
|
826
988
|
Should be a mouse event like:
|
|
827
989
|
{
|
|
828
990
|
type: 'mouseDown',
|
|
@@ -835,6 +997,26 @@ button: "left"
|
|
|
835
997
|
|
|
836
998
|
- `event`
|
|
837
999
|
|
|
1000
|
+
### uncheckOption
|
|
1001
|
+
|
|
1002
|
+
Unselects a checkbox or radio button.
|
|
1003
|
+
Element is located by label or name or CSS or XPath.
|
|
1004
|
+
|
|
1005
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1006
|
+
|
|
1007
|
+
```js
|
|
1008
|
+
I.uncheckOption('#agree');
|
|
1009
|
+
I.uncheckOption('I Agree to Terms and Conditions');
|
|
1010
|
+
I.uncheckOption('agree', '//form');
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
#### Parameters
|
|
1014
|
+
|
|
1015
|
+
- `field` ([string][3] \| [object][4]) checkbox located by label | name | CSS | XPath | strict locator.
|
|
1016
|
+
- `context` [string][3] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
838
1020
|
### wait
|
|
839
1021
|
|
|
840
1022
|
Pauses execution for a number of seconds.
|
|
@@ -845,19 +1027,25 @@ I.wait(2); // wait 2 secs
|
|
|
845
1027
|
|
|
846
1028
|
#### Parameters
|
|
847
1029
|
|
|
848
|
-
- `sec`
|
|
1030
|
+
- `sec` [number][9] number of second to wait.
|
|
1031
|
+
|
|
1032
|
+
|
|
849
1033
|
|
|
850
1034
|
### waitForDetached
|
|
851
1035
|
|
|
852
1036
|
Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
853
1037
|
Element can be located by CSS or XPath.
|
|
854
1038
|
|
|
855
|
-
|
|
1039
|
+
```js
|
|
1040
|
+
I.waitForDetached('#popup');
|
|
1041
|
+
```
|
|
856
1042
|
|
|
857
1043
|
#### Parameters
|
|
858
1044
|
|
|
859
|
-
- `locator`
|
|
860
|
-
- `sec`
|
|
1045
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
1046
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1047
|
+
|
|
1048
|
+
|
|
861
1049
|
|
|
862
1050
|
### waitForElement
|
|
863
1051
|
|
|
@@ -871,8 +1059,10 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
871
1059
|
|
|
872
1060
|
#### Parameters
|
|
873
1061
|
|
|
874
|
-
- `locator`
|
|
875
|
-
- `sec`
|
|
1062
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
1063
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1064
|
+
|
|
1065
|
+
|
|
876
1066
|
|
|
877
1067
|
### waitForFunction
|
|
878
1068
|
|
|
@@ -891,21 +1081,27 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
891
1081
|
|
|
892
1082
|
#### Parameters
|
|
893
1083
|
|
|
894
|
-
- `fn`
|
|
895
|
-
- `argsOrSec`
|
|
896
|
-
- `sec`
|
|
1084
|
+
- `fn` ([string][3] \| [function][7]) to be executed in browser context.
|
|
1085
|
+
- `argsOrSec` ([array][12] \| [number][9]) (optional, `1` by default) arguments for function or seconds.
|
|
1086
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1087
|
+
|
|
1088
|
+
|
|
897
1089
|
|
|
898
1090
|
### waitForInvisible
|
|
899
1091
|
|
|
900
1092
|
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
901
1093
|
Element can be located by CSS or XPath.
|
|
902
1094
|
|
|
903
|
-
|
|
1095
|
+
```js
|
|
1096
|
+
I.waitForInvisible('#popup');
|
|
1097
|
+
```
|
|
904
1098
|
|
|
905
1099
|
#### Parameters
|
|
906
1100
|
|
|
907
|
-
- `locator`
|
|
908
|
-
- `sec`
|
|
1101
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
1102
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1103
|
+
|
|
1104
|
+
|
|
909
1105
|
|
|
910
1106
|
### waitForText
|
|
911
1107
|
|
|
@@ -920,44 +1116,68 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
920
1116
|
|
|
921
1117
|
#### Parameters
|
|
922
1118
|
|
|
923
|
-
- `text`
|
|
924
|
-
- `sec`
|
|
925
|
-
- `context`
|
|
1119
|
+
- `text` [string][3] to wait for.
|
|
1120
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1121
|
+
- `context` ([string][3] \| [object][4]) (optional) element located by CSS|XPath|strict locator.
|
|
1122
|
+
|
|
1123
|
+
|
|
926
1124
|
|
|
927
1125
|
### waitForVisible
|
|
928
1126
|
|
|
929
1127
|
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
930
1128
|
Element can be located by CSS or XPath.
|
|
931
1129
|
|
|
932
|
-
|
|
1130
|
+
```js
|
|
1131
|
+
I.waitForVisible('#popup');
|
|
1132
|
+
```
|
|
933
1133
|
|
|
934
1134
|
#### Parameters
|
|
935
1135
|
|
|
936
|
-
- `locator`
|
|
937
|
-
- `sec`
|
|
1136
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
1137
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1138
|
+
|
|
1139
|
+
|
|
938
1140
|
|
|
939
1141
|
### waitToHide
|
|
940
1142
|
|
|
941
1143
|
Waits for an element to hide (by default waits for 1sec).
|
|
942
1144
|
Element can be located by CSS or XPath.
|
|
943
1145
|
|
|
944
|
-
|
|
1146
|
+
```js
|
|
1147
|
+
I.waitToHide('#popup');
|
|
1148
|
+
```
|
|
945
1149
|
|
|
946
1150
|
#### Parameters
|
|
947
1151
|
|
|
948
|
-
- `locator`
|
|
949
|
-
- `sec`
|
|
1152
|
+
- `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
|
|
1153
|
+
- `sec` [number][9] (optional, `1` by default) time in seconds to wait
|
|
1154
|
+
|
|
1155
|
+
|
|
950
1156
|
|
|
951
1157
|
[1]: https://github.com/segmentio/nightmare
|
|
952
1158
|
|
|
953
1159
|
[2]: https://github.com/segmentio/nightmare#api
|
|
954
1160
|
|
|
955
|
-
[3]: https://
|
|
1161
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1162
|
+
|
|
1163
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
1164
|
+
|
|
1165
|
+
[5]: https://github.com/rosshinkley/nightmare-upload#important-note-about-setting-file-upload-inputs
|
|
1166
|
+
|
|
1167
|
+
[6]: https://vuejs.org/v2/api/#Vue-nextTick
|
|
1168
|
+
|
|
1169
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1170
|
+
|
|
1171
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1172
|
+
|
|
1173
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
1174
|
+
|
|
1175
|
+
[10]: http://electron.atom.io/docs/api/web-contents/#webcontentssendinputeventevent
|
|
956
1176
|
|
|
957
|
-
[
|
|
1177
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
958
1178
|
|
|
959
|
-
[
|
|
1179
|
+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
960
1180
|
|
|
961
|
-
[
|
|
1181
|
+
[13]: https://github.com/segmentio/nightmare/blob/master/Readme.md#cookiessetcookie
|
|
962
1182
|
|
|
963
|
-
[
|
|
1183
|
+
[14]: http://electron.atom.io/docs/api/web-contents/#contentssendinputeventevent
|