codeceptjs 4.2.0-beta.4 → 4.2.1-beta.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/README.md +2 -0
- package/bin/codecept.js +11 -0
- package/docs/agents.md +26 -1
- package/docs/ai.md +57 -0
- package/docs/alternative-browsers.md +175 -148
- package/docs/assertions.md +74 -0
- package/docs/bootstrap.md +2 -0
- package/docs/commands.md +45 -0
- package/docs/configuration.md +37 -0
- package/docs/debugging.md +1 -1
- package/docs/helpers/ApiDataFactory.md +20 -20
- package/docs/helpers/Appium.md +1615 -670
- package/docs/helpers/Decision.md +146 -0
- package/docs/helpers/GraphQL.md +31 -31
- package/docs/helpers/GraphQLDataFactory.md +20 -20
- package/docs/helpers/Kitesurf.md +1808 -25
- package/docs/helpers/Lightpanda.md +139 -0
- package/docs/helpers/Obscura.md +1799 -74
- package/docs/helpers/Playwright.md +490 -428
- package/docs/helpers/Puppeteer.md +317 -255
- package/docs/helpers/REST.md +43 -43
- package/docs/helpers/WebDriver.md +237 -175
- package/docs/installation.md +16 -0
- package/docs/mcp.md +7 -1
- package/docs/parallel.md +35 -1
- package/docs/plugins/pause.md +2 -1
- package/docs/plugins/sitemap.md +48 -0
- package/docs/plugins.md +4 -0
- package/lib/ai.js +81 -2
- package/lib/codecept.js +32 -2
- package/lib/command/init.js +22 -0
- package/lib/command/initAgent.js +78 -0
- package/lib/command/run-multiple.js +3 -0
- package/lib/command/run-workers.js +10 -3
- package/lib/command/run.js +3 -2
- package/lib/command/utils.js +15 -0
- package/lib/command/workers/runTests.js +10 -10
- package/lib/container.js +4 -2
- package/lib/effects.js +19 -1
- package/lib/helper/Appium.js +23 -0
- package/lib/helper/CDPBrowser.js +387 -1338
- package/lib/helper/Decision.js +256 -0
- package/lib/helper/Kitesurf.js +3 -21
- package/lib/helper/Lightpanda.js +137 -0
- package/lib/helper/Obscura.js +21 -238
- package/lib/helper/Playwright.js +50 -4
- package/lib/helper/Puppeteer.js +62 -8
- package/lib/helper/WebDriver.js +45 -1
- package/lib/helper/extras/clipboard.js +31 -0
- package/lib/listener/result.js +4 -0
- package/lib/mocha/bdd.js +19 -1
- package/lib/plugin/junitReporter.js +4 -1
- package/lib/plugin/pause.js +4 -1
- package/lib/plugin/sitemap.js +228 -0
- package/lib/recorder.js +19 -18
- package/lib/result.js +16 -0
- package/lib/step/base.js +12 -0
- package/lib/utils.js +2 -10
- package/lib/webServer.js +193 -0
- package/lib/workers.js +118 -31
- package/package.json +4 -2
- package/typings/index.d.ts +60 -7
- package/typings/promiseBasedTypes.d.ts +985 -814
- package/typings/types.d.ts +1084 -815
- package/docs/helpers/CDPBrowser.md +0 -2138
package/docs/helpers/Appium.md
CHANGED
|
@@ -38,7 +38,7 @@ This helper should be configured in codecept.conf.ts or codecept.conf.js
|
|
|
38
38
|
* `port`: (default: '4723') Appium port
|
|
39
39
|
* `platform`: (Android or IOS), which mobile OS to use; alias to desiredCapabilities.platformName
|
|
40
40
|
* `restart`: restart browser or app between tests (default: true), if set to false cookies will be cleaned but browser window will be kept and for apps nothing will be changed.
|
|
41
|
-
* `desiredCapabilities`:
|
|
41
|
+
* `desiredCapabilities`: [], Appium capabilities, see below
|
|
42
42
|
* `platformName` - Which mobile OS platform to use
|
|
43
43
|
* `appPackage` - Java package of the Android app you want to run
|
|
44
44
|
* `appActivity` - Activity name for the Android activity you want to launch from your package.
|
|
@@ -159,89 +159,103 @@ let browser = this.helpers['Appium'].browser
|
|
|
159
159
|
|
|
160
160
|
* `config`  
|
|
161
161
|
|
|
162
|
-
###
|
|
162
|
+
### amOnPage
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
Opens a web page in a browser. Requires relative or absolute url.
|
|
165
|
+
If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
165
166
|
|
|
166
167
|
```js
|
|
167
|
-
I.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
168
|
+
I.amOnPage('/'); // opens main page of website
|
|
169
|
+
I.amOnPage('https://github.com'); // opens github
|
|
170
|
+
I.amOnPage('/login'); // opens a login page
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
For instance, this code will be executed only on iPhone 5s:
|
|
173
|
+
#### Parameters
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
I.runOnIOS({deviceName: 'iPhone 5s'},() => {
|
|
178
|
-
// ...
|
|
179
|
-
});
|
|
180
|
-
```
|
|
175
|
+
* `url` **[string][5]** url path or global url.
|
|
181
176
|
|
|
182
|
-
|
|
177
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
178
|
+
|
|
179
|
+
### appendField
|
|
180
|
+
|
|
181
|
+
Appends text to a input field or textarea.
|
|
182
|
+
Field is located by name, label, CSS or XPath
|
|
183
|
+
|
|
184
|
+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
183
185
|
|
|
184
186
|
```js
|
|
185
|
-
I.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
187
|
+
I.appendField('#myTextField', 'appended');
|
|
188
|
+
// typing secret
|
|
189
|
+
I.appendField('password', secret('123456'));
|
|
190
|
+
// within a context
|
|
191
|
+
I.appendField('name', 'John', '.form-container');
|
|
191
192
|
```
|
|
192
193
|
|
|
193
194
|
#### Parameters
|
|
194
195
|
|
|
195
|
-
* `
|
|
196
|
-
* `
|
|
196
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator
|
|
197
|
+
* `value` **[string][5]** text value to append.
|
|
198
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
199
201
|
|
|
200
|
-
|
|
202
|
+
### attachFile
|
|
201
203
|
|
|
202
|
-
|
|
203
|
-
I.runOnAndroid(() => {
|
|
204
|
-
I.click('io.selendroid.testapp:id/buttonTest');
|
|
205
|
-
});
|
|
206
|
-
```
|
|
204
|
+
Appium: not tested
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
Attaches a file to element located by label, name, CSS or XPath
|
|
207
|
+
Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
|
|
208
|
+
File will be uploaded to remote system (if tests are running remotely).
|
|
209
|
+
|
|
210
|
+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
210
211
|
|
|
211
212
|
```js
|
|
212
|
-
I.
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
I.attachFile('Avatar', 'data/avatar.jpg');
|
|
214
|
+
I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
215
|
+
// within a context
|
|
216
|
+
I.attachFile('Avatar', 'data/avatar.jpg', '.form-container');
|
|
215
217
|
```
|
|
216
218
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
If the locator points to a non-file-input element (e.g., a dropzone area),
|
|
220
|
+
the file will be dropped onto that element using drag-and-drop events.
|
|
219
221
|
|
|
220
222
|
```js
|
|
221
|
-
I.
|
|
222
|
-
// caps is current config of desiredCapabiliites
|
|
223
|
-
return caps.platformVersion >= 6
|
|
224
|
-
},() => {
|
|
225
|
-
// ...
|
|
226
|
-
});
|
|
223
|
+
I.attachFile('#dropzone', 'data/avatar.jpg');
|
|
227
224
|
```
|
|
228
225
|
|
|
229
226
|
#### Parameters
|
|
230
227
|
|
|
231
|
-
* `
|
|
232
|
-
* `
|
|
228
|
+
* `locator` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
229
|
+
* `pathToFile` **[string][5]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
230
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
233
231
|
|
|
234
|
-
|
|
232
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
235
233
|
|
|
236
|
-
|
|
234
|
+
### blur
|
|
235
|
+
|
|
236
|
+
Remove focus from a text input, button, etc.
|
|
237
|
+
Calls [blur][7] on the element.
|
|
238
|
+
|
|
239
|
+
Examples:
|
|
237
240
|
|
|
238
241
|
```js
|
|
239
|
-
I.
|
|
240
|
-
I.waitForElement('#data');
|
|
241
|
-
I.seeInCurrentUrl('/data');
|
|
242
|
-
});
|
|
242
|
+
I.blur('.text-area')
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
+
```js
|
|
246
|
+
//element `#product-tile` is focused
|
|
247
|
+
I.see('#add-to-cart-btn');
|
|
248
|
+
I.blur('#product-tile')
|
|
249
|
+
I.dontSee('#add-to-cart-btn');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Parameters
|
|
253
|
+
|
|
254
|
+
* `locator` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
255
|
+
* `options` **any?** Playwright only: [Additional options][8] for available options object as 2nd argument.
|
|
256
|
+
|
|
257
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
258
|
+
|
|
245
259
|
### checkIfAppIsInstalled
|
|
246
260
|
|
|
247
261
|
Returns app installation status.
|
|
@@ -254,1133 +268,2048 @@ I.checkIfAppIsInstalled("com.example.android.apis");
|
|
|
254
268
|
|
|
255
269
|
* `bundleId` **[string][5]** String ID of bundled app
|
|
256
270
|
|
|
257
|
-
Returns **[Promise][
|
|
271
|
+
Returns **[Promise][9]<[boolean][10]>** Appium: support only Android
|
|
258
272
|
|
|
259
|
-
###
|
|
273
|
+
### checkOption
|
|
260
274
|
|
|
261
|
-
|
|
275
|
+
Selects a checkbox or radio button.
|
|
276
|
+
Element is located by label or name or CSS or XPath.
|
|
277
|
+
|
|
278
|
+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
262
279
|
|
|
263
280
|
```js
|
|
264
|
-
I.
|
|
281
|
+
I.checkOption('#agree');
|
|
282
|
+
I.checkOption('I Agree to Terms and Conditions');
|
|
283
|
+
I.checkOption('agree', '//form');
|
|
265
284
|
```
|
|
266
285
|
|
|
267
286
|
#### Parameters
|
|
268
287
|
|
|
269
|
-
* `
|
|
288
|
+
* `field` **([string][5] | [object][6])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
289
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
270
290
|
|
|
271
|
-
Returns **
|
|
291
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
272
292
|
|
|
273
|
-
###
|
|
293
|
+
### clearClipboard
|
|
274
294
|
|
|
275
|
-
|
|
295
|
+
Clears the system clipboard.
|
|
276
296
|
|
|
277
297
|
```js
|
|
278
|
-
I.
|
|
298
|
+
I.clearClipboard();
|
|
299
|
+
I.seeClipboardEquals('');
|
|
279
300
|
```
|
|
280
301
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
* `bundleId` **[string][5]** String ID of bundled app
|
|
302
|
+
Returns **void** automatically synchronized promise through #recorderAppium: support both Android and iOS
|
|
284
303
|
|
|
285
|
-
|
|
304
|
+
### clearField
|
|
286
305
|
|
|
287
|
-
|
|
306
|
+
Clears a `<textarea>` or text `<input>` element's value.
|
|
288
307
|
|
|
289
|
-
|
|
308
|
+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
290
309
|
|
|
291
310
|
```js
|
|
292
|
-
I.
|
|
311
|
+
I.clearField('Email');
|
|
312
|
+
I.clearField('user[email]');
|
|
313
|
+
I.clearField('#email');
|
|
314
|
+
// within a context
|
|
315
|
+
I.clearField('Email', '.form-container');
|
|
293
316
|
```
|
|
294
317
|
|
|
295
318
|
#### Parameters
|
|
296
319
|
|
|
297
|
-
* `
|
|
320
|
+
* `field`  
|
|
321
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
322
|
+
* `editable` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
298
323
|
|
|
299
|
-
Returns **
|
|
324
|
+
Returns **void** automatically synchronized promise through #recorder.
|
|
300
325
|
|
|
301
|
-
###
|
|
326
|
+
### click
|
|
302
327
|
|
|
303
|
-
|
|
328
|
+
Perform a click on a link or a button, given by a locator.
|
|
329
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
330
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
331
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
332
|
+
|
|
333
|
+
If no locator is provided, defaults to clicking the body element (`'//body'`).
|
|
334
|
+
|
|
335
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
304
336
|
|
|
305
337
|
```js
|
|
306
|
-
|
|
338
|
+
// click body element (default)
|
|
339
|
+
I.click();
|
|
340
|
+
// simple link
|
|
341
|
+
I.click('Logout');
|
|
342
|
+
// button of form
|
|
343
|
+
I.click('Submit');
|
|
344
|
+
// CSS button
|
|
345
|
+
I.click('#form input[type=submit]');
|
|
346
|
+
// XPath
|
|
347
|
+
I.click('//form/*[@type=submit]');
|
|
348
|
+
// link in context
|
|
349
|
+
I.click('Logout', '#nav');
|
|
350
|
+
// using strict locator
|
|
351
|
+
I.click({css: 'nav a.login'});
|
|
352
|
+
// using ARIA role locator
|
|
353
|
+
I.click({role: 'button', name: 'Submit'});
|
|
307
354
|
```
|
|
308
355
|
|
|
309
|
-
|
|
356
|
+
> ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][11].
|
|
310
357
|
|
|
311
358
|
#### Parameters
|
|
312
359
|
|
|
313
|
-
* `
|
|
314
|
-
* `
|
|
315
|
-
|
|
316
|
-
### resetApp
|
|
317
|
-
|
|
318
|
-
Reset the currently running app for current session.
|
|
360
|
+
* `locator` **([string][5] | [object][6])** (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
361
|
+
* `context` **([string][5]? | [object][6] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
319
362
|
|
|
320
|
-
|
|
321
|
-
I.resetApp();
|
|
322
|
-
```
|
|
363
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
323
364
|
|
|
324
|
-
###
|
|
365
|
+
### clickXY
|
|
325
366
|
|
|
326
|
-
|
|
367
|
+
Performs click at specific coordinates.
|
|
368
|
+
If locator is provided, the coordinates are relative to the element's top-left corner.
|
|
369
|
+
If locator is not provided, the coordinates are relative to the body element.
|
|
327
370
|
|
|
328
371
|
```js
|
|
329
|
-
|
|
372
|
+
// Click at coordinates (100, 200) relative to body
|
|
373
|
+
I.clickXY(100, 200);
|
|
374
|
+
|
|
375
|
+
// Click at coordinates (50, 30) relative to element's top-left corner
|
|
376
|
+
I.clickXY('#someElement', 50, 30);
|
|
330
377
|
```
|
|
331
378
|
|
|
332
379
|
#### Parameters
|
|
333
380
|
|
|
334
|
-
* `
|
|
381
|
+
* `locator` **([string][5] | [object][6] | [number][12])** Element to click on or X coordinate if no element.
|
|
382
|
+
* `x` **[number][12]?** X coordinate relative to element's top-left, or Y coordinate if locator is a number.
|
|
383
|
+
* `y` **[number][12]?** Y coordinate relative to element's top-left.
|
|
335
384
|
|
|
336
|
-
Returns **[Promise][
|
|
385
|
+
Returns **[Promise][9]<void>** 
|
|
337
386
|
|
|
338
|
-
###
|
|
387
|
+
### closeApp
|
|
339
388
|
|
|
340
|
-
|
|
389
|
+
Close the given application.
|
|
341
390
|
|
|
342
391
|
```js
|
|
343
|
-
I.
|
|
392
|
+
I.closeApp();
|
|
344
393
|
```
|
|
345
394
|
|
|
346
|
-
Returns **[Promise][
|
|
395
|
+
Returns **[Promise][9]<void>** Appium: support both Android and iOS
|
|
347
396
|
|
|
348
|
-
###
|
|
397
|
+
### closeOtherTabs
|
|
349
398
|
|
|
350
|
-
|
|
399
|
+
Close all tabs except for the current one.
|
|
351
400
|
|
|
352
401
|
```js
|
|
353
|
-
I.
|
|
402
|
+
I.closeOtherTabs();
|
|
354
403
|
```
|
|
355
404
|
|
|
356
|
-
Returns **
|
|
405
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
357
406
|
|
|
358
|
-
###
|
|
407
|
+
### defineTimeout
|
|
359
408
|
|
|
360
|
-
|
|
409
|
+
Set [WebDriver timeouts][13] in realtime.
|
|
410
|
+
|
|
411
|
+
Timeouts are expected to be passed as object:
|
|
361
412
|
|
|
362
413
|
```js
|
|
363
|
-
I.
|
|
364
|
-
I.
|
|
414
|
+
I.defineTimeout({ script: 5000 });
|
|
415
|
+
I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
|
|
365
416
|
```
|
|
366
417
|
|
|
367
418
|
#### Parameters
|
|
368
419
|
|
|
369
|
-
* `
|
|
370
|
-
|
|
371
|
-
Returns **[Promise][6]\<void>** 
|
|
420
|
+
* `timeouts` **any** WebDriver timeouts object.
|
|
372
421
|
|
|
373
|
-
###
|
|
422
|
+
### dontSee
|
|
374
423
|
|
|
375
|
-
|
|
424
|
+
Opposite to `see`. Checks that a text is not present on a page.
|
|
425
|
+
Use context parameter to narrow down the search.
|
|
376
426
|
|
|
377
427
|
```js
|
|
378
|
-
I.
|
|
379
|
-
I.
|
|
428
|
+
I.dontSee('Login'); // assume we are already logged in.
|
|
429
|
+
I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
380
430
|
```
|
|
381
431
|
|
|
382
432
|
#### Parameters
|
|
383
433
|
|
|
384
|
-
* `
|
|
385
|
-
|
|
386
|
-
### grabAllContexts
|
|
387
|
-
|
|
388
|
-
Get list of all available contexts
|
|
389
|
-
|
|
390
|
-
let contexts = await I.grabAllContexts();
|
|
434
|
+
* `text` **[string][5]** which is not present.
|
|
435
|
+
* `context` **([string][5] | [object][6])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
391
436
|
|
|
392
|
-
Returns **
|
|
437
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
393
438
|
|
|
394
|
-
###
|
|
439
|
+
### dontSeeCheckboxIsChecked
|
|
395
440
|
|
|
396
|
-
|
|
441
|
+
Verifies that the specified checkbox is not checked.
|
|
397
442
|
|
|
398
443
|
```js
|
|
399
|
-
|
|
444
|
+
I.dontSeeCheckboxIsChecked('#agree'); // located by ID
|
|
445
|
+
I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
446
|
+
I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
400
447
|
```
|
|
401
448
|
|
|
402
|
-
|
|
449
|
+
#### Parameters
|
|
403
450
|
|
|
404
|
-
|
|
451
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
405
452
|
|
|
406
|
-
|
|
453
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
454
|
+
|
|
455
|
+
### dontSeeCurrentPathEquals
|
|
456
|
+
|
|
457
|
+
Checks that current URL path does NOT match the expected path.
|
|
458
|
+
Query strings and URL fragments are ignored.
|
|
407
459
|
|
|
408
460
|
```js
|
|
409
|
-
|
|
461
|
+
I.dontSeeCurrentPathEquals('/form'); // fails for '/form', '/form?user=1', '/form#section'
|
|
462
|
+
I.dontSeeCurrentPathEquals('/'); // fails for '/', '/?user=ok', '/#top'
|
|
410
463
|
```
|
|
411
464
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
### grabNetworkConnection
|
|
465
|
+
#### Parameters
|
|
415
466
|
|
|
416
|
-
|
|
417
|
-
The actual server value will be a number. However WebdriverIO additional
|
|
418
|
-
properties to the response object to allow easier assertions.
|
|
467
|
+
* `path` **[string][5]** value to check.
|
|
419
468
|
|
|
420
|
-
|
|
421
|
-
let con = await I.grabNetworkConnection();
|
|
422
|
-
```
|
|
469
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
423
470
|
|
|
424
|
-
|
|
471
|
+
### dontSeeElement
|
|
425
472
|
|
|
426
|
-
|
|
473
|
+
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
|
|
427
474
|
|
|
428
|
-
|
|
475
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
429
476
|
|
|
430
477
|
```js
|
|
431
|
-
|
|
478
|
+
I.dontSeeElement('.modal'); // modal is not shown
|
|
479
|
+
I.dontSeeElement('.modal', '#container');
|
|
432
480
|
```
|
|
433
481
|
|
|
434
|
-
|
|
482
|
+
#### Parameters
|
|
435
483
|
|
|
436
|
-
|
|
484
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|Strict locator.
|
|
485
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
437
486
|
|
|
438
|
-
|
|
487
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
488
|
+
|
|
489
|
+
### dontSeeElementInDOM
|
|
490
|
+
|
|
491
|
+
Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
439
492
|
|
|
440
493
|
```js
|
|
441
|
-
|
|
494
|
+
I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
442
495
|
```
|
|
443
496
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
### switchToContext
|
|
497
|
+
#### Parameters
|
|
447
498
|
|
|
448
|
-
|
|
499
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|Strict locator.
|
|
449
500
|
|
|
450
|
-
|
|
501
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
451
502
|
|
|
452
|
-
|
|
503
|
+
### dontSeeInField
|
|
453
504
|
|
|
454
|
-
|
|
505
|
+
Checks that value of input field or textarea doesn't equal to given value
|
|
506
|
+
Opposite to `seeInField`.
|
|
455
507
|
|
|
456
|
-
|
|
457
|
-
If no context is provided switches to the first detected web context
|
|
508
|
+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
458
509
|
|
|
459
510
|
```js
|
|
460
|
-
|
|
461
|
-
I.
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
I.switchToWeb('WEBVIEW_io.selendroid.testapp');
|
|
511
|
+
I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
512
|
+
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
513
|
+
// within a context
|
|
514
|
+
I.dontSeeInField('Name', 'old_value', '.form-container');
|
|
465
515
|
```
|
|
466
516
|
|
|
467
517
|
#### Parameters
|
|
468
518
|
|
|
469
|
-
* `
|
|
519
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
520
|
+
* `value` **([string][5] | [object][6])** value to check.
|
|
521
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
470
522
|
|
|
471
|
-
Returns **
|
|
523
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
472
524
|
|
|
473
|
-
###
|
|
525
|
+
### dontSeeInSource
|
|
474
526
|
|
|
475
|
-
|
|
476
|
-
By default switches to NATIVE\_APP context unless other specified.
|
|
527
|
+
Checks that the current page does not contains the given string in its raw source code.
|
|
477
528
|
|
|
478
529
|
```js
|
|
479
|
-
I.
|
|
480
|
-
|
|
481
|
-
// or set context explicitly
|
|
482
|
-
I.switchToNative('SOME_OTHER_CONTEXT');
|
|
530
|
+
I.dontSeeInSource('<!--'); // no comments in source
|
|
483
531
|
```
|
|
484
532
|
|
|
485
533
|
#### Parameters
|
|
486
534
|
|
|
487
|
-
* `
|
|
535
|
+
* `text`  
|
|
536
|
+
* `value` **[string][5]** to check.
|
|
488
537
|
|
|
489
|
-
Returns **
|
|
538
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
490
539
|
|
|
491
|
-
###
|
|
540
|
+
### doubleClick
|
|
492
541
|
|
|
493
|
-
|
|
542
|
+
Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
543
|
+
Context can be specified as second parameter to narrow search.
|
|
494
544
|
|
|
495
545
|
```js
|
|
496
|
-
I.
|
|
546
|
+
I.doubleClick('Edit');
|
|
547
|
+
I.doubleClick('Edit', '.actions');
|
|
548
|
+
I.doubleClick({css: 'button.accept'});
|
|
549
|
+
I.doubleClick('.btn.edit');
|
|
497
550
|
```
|
|
498
551
|
|
|
499
|
-
Appium: support only Android
|
|
500
|
-
|
|
501
552
|
#### Parameters
|
|
502
553
|
|
|
503
|
-
* `
|
|
504
|
-
* `
|
|
505
|
-
|
|
506
|
-
Returns **[Promise][6]\<void>** 
|
|
554
|
+
* `locator` **([string][5] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
555
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
507
556
|
|
|
508
|
-
|
|
557
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
509
558
|
|
|
510
|
-
|
|
559
|
+
### dragAndDrop
|
|
511
560
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
* data data
|
|
561
|
+
Appium: not tested
|
|
562
|
+
Drag an item to a destination element.
|
|
515
563
|
|
|
516
564
|
```js
|
|
517
|
-
I.
|
|
518
|
-
I.setNetworkConnection(1) // airplane mode on, wifi off, data off
|
|
519
|
-
I.setNetworkConnection(2) // airplane mode off, wifi on, data off
|
|
520
|
-
I.setNetworkConnection(4) // airplane mode off, wifi off, data on
|
|
521
|
-
I.setNetworkConnection(6) // airplane mode off, wifi on, data on
|
|
565
|
+
I.dragAndDrop('#dragHandle', '#container');
|
|
522
566
|
```
|
|
523
567
|
|
|
524
|
-
See corresponding [webdriverio reference][9].
|
|
525
|
-
|
|
526
|
-
Appium: support only Android
|
|
527
|
-
|
|
528
568
|
#### Parameters
|
|
529
569
|
|
|
530
|
-
* `
|
|
570
|
+
* `srcElement` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
571
|
+
* `destElement` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
531
572
|
|
|
532
|
-
Returns **
|
|
573
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
533
574
|
|
|
534
|
-
###
|
|
575
|
+
### dragSlider
|
|
535
576
|
|
|
536
|
-
|
|
577
|
+
Drag the scrubber of a slider to a given position
|
|
578
|
+
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
537
579
|
|
|
538
580
|
```js
|
|
539
|
-
I.
|
|
581
|
+
I.dragSlider('#slider', 30);
|
|
582
|
+
I.dragSlider('#slider', -70);
|
|
540
583
|
```
|
|
541
584
|
|
|
542
585
|
#### Parameters
|
|
543
586
|
|
|
544
|
-
* `
|
|
545
|
-
|
|
546
|
-
### hideDeviceKeyboard
|
|
547
|
-
|
|
548
|
-
Hide the keyboard.
|
|
587
|
+
* `locator` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
588
|
+
* `offsetX` **[number][12]** position to drag.
|
|
549
589
|
|
|
550
|
-
|
|
551
|
-
// taps outside to hide keyboard per default
|
|
552
|
-
I.hideDeviceKeyboard();
|
|
553
|
-
```
|
|
590
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
554
591
|
|
|
555
|
-
|
|
592
|
+
### fillField
|
|
556
593
|
|
|
557
|
-
|
|
594
|
+
Fills a text field or textarea, after clearing its value, with the given string.
|
|
595
|
+
Field is located by name, label, CSS, or XPath.
|
|
558
596
|
|
|
559
|
-
|
|
560
|
-
List of keys: [https://developer.android.com/reference/android/view/KeyEvent.html][12]
|
|
597
|
+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
561
598
|
|
|
562
599
|
```js
|
|
563
|
-
|
|
600
|
+
// by label
|
|
601
|
+
I.fillField('Email', 'hello@world.com');
|
|
602
|
+
// by name
|
|
603
|
+
I.fillField('password', secret('123456'));
|
|
604
|
+
// by CSS
|
|
605
|
+
I.fillField('form#login input[name=username]', 'John');
|
|
606
|
+
// or by strict locator
|
|
607
|
+
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
608
|
+
// by ARIA role locator
|
|
609
|
+
I.fillField({role: 'textbox', name: 'Email'}, 'hello@world.com');
|
|
610
|
+
// within a context
|
|
611
|
+
I.fillField('Name', 'John', '#section2');
|
|
564
612
|
```
|
|
565
613
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
* `keyValue` **[number][10]** Device specific key value
|
|
614
|
+
> ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators][11].
|
|
569
615
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
### openNotifications
|
|
616
|
+
#### Parameters
|
|
573
617
|
|
|
574
|
-
|
|
618
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
619
|
+
* `value` **([string][5] | [object][6])** text value to fill.
|
|
620
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
575
621
|
|
|
576
|
-
|
|
577
|
-
I.openNotifications();
|
|
578
|
-
```
|
|
622
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
579
623
|
|
|
580
|
-
|
|
624
|
+
### focus
|
|
581
625
|
|
|
582
|
-
|
|
626
|
+
Calls [focus][7] on the matching element.
|
|
583
627
|
|
|
584
|
-
|
|
585
|
-
automated in Appium. At its core is the ability to chain together ad hoc
|
|
586
|
-
individual actions, which will then be applied to an element in the
|
|
587
|
-
application on the device.
|
|
588
|
-
[See complete documentation][13]
|
|
628
|
+
Examples:
|
|
589
629
|
|
|
590
630
|
```js
|
|
591
|
-
I.
|
|
631
|
+
I.dontSee('#add-to-cart-btn');
|
|
632
|
+
I.focus('#product-tile')
|
|
633
|
+
I.see('#add-to-cart-bnt');
|
|
592
634
|
```
|
|
593
635
|
|
|
594
636
|
#### Parameters
|
|
595
637
|
|
|
596
|
-
* `locator`
|
|
597
|
-
* `
|
|
638
|
+
* `locator` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
639
|
+
* `options` **any?** Playwright only: [Additional options][14] for available options object as 2nd argument.
|
|
598
640
|
|
|
599
|
-
Returns **
|
|
641
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
600
642
|
|
|
601
|
-
###
|
|
643
|
+
### forceClick
|
|
602
644
|
|
|
603
|
-
|
|
645
|
+
Perform an emulated click on a link or a button, given by a locator.
|
|
646
|
+
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
647
|
+
This works on hidden, animated or inactive elements as well.
|
|
648
|
+
|
|
649
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
650
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
651
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
652
|
+
|
|
653
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
604
654
|
|
|
605
655
|
```js
|
|
606
|
-
|
|
656
|
+
// simple link
|
|
657
|
+
I.forceClick('Logout');
|
|
658
|
+
// button of form
|
|
659
|
+
I.forceClick('Submit');
|
|
660
|
+
// CSS button
|
|
661
|
+
I.forceClick('#form input[type=submit]');
|
|
662
|
+
// XPath
|
|
663
|
+
I.forceClick('//form/*[@type=submit]');
|
|
664
|
+
// link in context
|
|
665
|
+
I.forceClick('Logout', '#nav');
|
|
666
|
+
// using strict locator
|
|
667
|
+
I.forceClick({css: 'nav a.login'});
|
|
607
668
|
```
|
|
608
669
|
|
|
609
|
-
Shortcut for `makeTouchAction`
|
|
610
|
-
|
|
611
670
|
#### Parameters
|
|
612
671
|
|
|
613
|
-
* `locator` **any
|
|
672
|
+
* `locator` **([string][5] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
673
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
614
674
|
|
|
615
|
-
Returns **
|
|
675
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
616
676
|
|
|
617
|
-
###
|
|
677
|
+
### forceRightClick
|
|
618
678
|
|
|
619
|
-
|
|
679
|
+
Emulates right click on an element.
|
|
680
|
+
Unlike normal click instead of sending native event, emulates a click with JavaScript.
|
|
681
|
+
This works on hidden, animated or inactive elements as well.
|
|
682
|
+
|
|
683
|
+
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
684
|
+
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
685
|
+
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
686
|
+
|
|
687
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
620
688
|
|
|
621
689
|
```js
|
|
622
|
-
|
|
623
|
-
I.
|
|
690
|
+
// simple link
|
|
691
|
+
I.forceRightClick('Menu');
|
|
624
692
|
```
|
|
625
693
|
|
|
626
|
-
[See complete reference][14]
|
|
627
|
-
|
|
628
694
|
#### Parameters
|
|
629
695
|
|
|
630
|
-
* `locator` **([string][5] | [object][
|
|
631
|
-
* `
|
|
632
|
-
* `yoffset` **[number][10]** 
|
|
633
|
-
* `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
696
|
+
* `locator` **([string][5] | [object][6])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
697
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
634
698
|
|
|
635
|
-
Returns **
|
|
636
|
-
|
|
637
|
-
### performSwipe
|
|
699
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
638
700
|
|
|
639
|
-
|
|
701
|
+
### grabAllContexts
|
|
640
702
|
|
|
641
|
-
|
|
642
|
-
I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 });
|
|
643
|
-
```
|
|
703
|
+
Get list of all available contexts
|
|
644
704
|
|
|
645
|
-
|
|
705
|
+
let contexts = await I.grabAllContexts();
|
|
646
706
|
|
|
647
|
-
|
|
648
|
-
* `to` **[object][11]** Appium: support Android and iOS
|
|
707
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** Appium: support Android and iOS
|
|
649
708
|
|
|
650
|
-
###
|
|
709
|
+
### grabAllWindowHandles
|
|
651
710
|
|
|
652
|
-
|
|
711
|
+
Get all Window Handles.
|
|
712
|
+
Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
|
|
653
713
|
|
|
654
714
|
```js
|
|
655
|
-
|
|
656
|
-
I.swipeDown(locator); // simple swipe
|
|
657
|
-
I.swipeDown(locator, 500); // set speed
|
|
658
|
-
I.swipeDown(locator, 1200, 1000); // set offset and speed
|
|
715
|
+
const windows = await I.grabAllWindowHandles();
|
|
659
716
|
```
|
|
660
717
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
* `locator` **([string][5] | [object][11])** 
|
|
664
|
-
* `yoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
665
|
-
* `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
718
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** 
|
|
666
719
|
|
|
667
|
-
|
|
720
|
+
### grabAttributeFrom
|
|
668
721
|
|
|
669
|
-
|
|
722
|
+
Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
670
723
|
|
|
671
|
-
|
|
724
|
+
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
725
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
726
|
+
If more than one element is found - attribute of first element is returned.
|
|
672
727
|
|
|
673
728
|
```js
|
|
674
|
-
let
|
|
675
|
-
I.swipeLeft(locator); // simple swipe
|
|
676
|
-
I.swipeLeft(locator, 500); // set speed
|
|
677
|
-
I.swipeLeft(locator, 1200, 1000); // set offset and speed
|
|
729
|
+
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
678
730
|
```
|
|
679
731
|
|
|
680
732
|
#### Parameters
|
|
681
733
|
|
|
682
|
-
* `locator` **([string][5] | [object][
|
|
683
|
-
* `
|
|
684
|
-
* `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
734
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
735
|
+
* `attr` **[string][5]** attribute name.
|
|
685
736
|
|
|
686
|
-
Returns **[Promise][
|
|
737
|
+
Returns **[Promise][9]<[string][5]>** attribute value
|
|
687
738
|
|
|
688
|
-
###
|
|
739
|
+
### grabAttributeFromAll
|
|
689
740
|
|
|
690
|
-
|
|
741
|
+
Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
742
|
+
Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
|
|
743
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
691
744
|
|
|
692
745
|
```js
|
|
693
|
-
let
|
|
694
|
-
I.swipeRight(locator); // simple swipe
|
|
695
|
-
I.swipeRight(locator, 500); // set speed
|
|
696
|
-
I.swipeRight(locator, 1200, 1000); // set offset and speed
|
|
746
|
+
let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
697
747
|
```
|
|
698
748
|
|
|
699
749
|
#### Parameters
|
|
700
750
|
|
|
701
|
-
* `locator` **([string][5] | [object][
|
|
702
|
-
* `
|
|
703
|
-
* `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
751
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
752
|
+
* `attr` **[string][5]** attribute name.
|
|
704
753
|
|
|
705
|
-
Returns **[Promise][
|
|
754
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** attribute value
|
|
706
755
|
|
|
707
|
-
###
|
|
756
|
+
### grabBrowserLogs
|
|
708
757
|
|
|
709
|
-
|
|
758
|
+
Get JS log from browser. Log buffer is reset after each request.
|
|
759
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
710
760
|
|
|
711
761
|
```js
|
|
712
|
-
let
|
|
713
|
-
|
|
714
|
-
I.swipeUp(locator, 500); // set speed
|
|
715
|
-
I.swipeUp(locator, 1200, 1000); // set offset and speed
|
|
762
|
+
let logs = await I.grabBrowserLogs();
|
|
763
|
+
console.log(JSON.stringify(logs))
|
|
716
764
|
```
|
|
717
765
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
* `locator` **([string][5] | [object][11])** 
|
|
721
|
-
* `yoffset` **[number][10]?** (optional) (optional, default `1000`)
|
|
722
|
-
* `speed` **[number][10]** (optional), 1000 by default (optional, default `1000`)
|
|
766
|
+
Returns **([Promise][9]<[Array][15]<[object][6]>> | [undefined][16])** all browser logs
|
|
723
767
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
### swipeTo
|
|
768
|
+
### grabContext
|
|
727
769
|
|
|
728
|
-
|
|
770
|
+
Retrieve current context
|
|
729
771
|
|
|
730
772
|
```js
|
|
731
|
-
I.
|
|
732
|
-
"android.widget.CheckBox", // searchable element
|
|
733
|
-
"//android.widget.ScrollView/android.widget.LinearLayout", // scroll element
|
|
734
|
-
"up", // direction
|
|
735
|
-
30,
|
|
736
|
-
100,
|
|
737
|
-
500);
|
|
773
|
+
let context = await I.grabContext();
|
|
738
774
|
```
|
|
739
775
|
|
|
740
|
-
|
|
776
|
+
Returns **[Promise][9]<([string][5] | null)>** Appium: support Android and iOS
|
|
741
777
|
|
|
742
|
-
|
|
743
|
-
* `scrollLocator` **[string][5]** 
|
|
744
|
-
* `direction` **[string][5]** 
|
|
745
|
-
* `timeout` **[number][10]** 
|
|
746
|
-
* `offset` **[number][10]** 
|
|
747
|
-
* `speed` **[number][10]** 
|
|
778
|
+
### grabCurrentActivity
|
|
748
779
|
|
|
749
|
-
|
|
780
|
+
Get current device activity.
|
|
750
781
|
|
|
751
|
-
|
|
782
|
+
```js
|
|
783
|
+
let activity = await I.grabCurrentActivity();
|
|
784
|
+
```
|
|
752
785
|
|
|
753
|
-
|
|
754
|
-
The action object need to contain the action name, x/y coordinates
|
|
786
|
+
Returns **[Promise][9]<[string][5]>** Appium: support only Android
|
|
755
787
|
|
|
756
|
-
|
|
757
|
-
I.touchPerform([{
|
|
758
|
-
action: 'press',
|
|
759
|
-
options: {
|
|
760
|
-
x: 100,
|
|
761
|
-
y: 200
|
|
762
|
-
}
|
|
763
|
-
}, {action: 'release'}])
|
|
788
|
+
### grabCurrentWindowHandle
|
|
764
789
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
y: 20, // y offset
|
|
771
|
-
count: 1 // number of touches
|
|
772
|
-
}
|
|
773
|
-
}]);
|
|
790
|
+
Get the current Window Handle.
|
|
791
|
+
Useful for referencing it when calling `I.switchToWindow(handle)`
|
|
792
|
+
|
|
793
|
+
```js
|
|
794
|
+
const window = await I.grabCurrentWindowHandle();
|
|
774
795
|
```
|
|
775
796
|
|
|
776
|
-
|
|
797
|
+
Returns **[Promise][9]<[string][5]>** 
|
|
777
798
|
|
|
778
|
-
|
|
799
|
+
### grabElementBoundingRect
|
|
779
800
|
|
|
780
|
-
|
|
801
|
+
Grab the width, height, location of given locator.
|
|
802
|
+
Provide `width` or `height`as second param to get your desired prop.
|
|
803
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
781
804
|
|
|
782
|
-
|
|
805
|
+
Returns an object with `x`, `y`, `width`, `height` keys.
|
|
783
806
|
|
|
784
|
-
|
|
807
|
+
```js
|
|
808
|
+
const value = await I.grabElementBoundingRect('h3');
|
|
809
|
+
// value is like { x: 226.5, y: 89, width: 527, height: 220 }
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
To get only one metric use second parameter:
|
|
785
813
|
|
|
786
814
|
```js
|
|
787
|
-
I.
|
|
788
|
-
//
|
|
789
|
-
I.pullFile('/storage/emulated/0/DCIM/logo.png', output_dir);
|
|
815
|
+
const width = await I.grabElementBoundingRect('h3', 'width');
|
|
816
|
+
// width == 527
|
|
790
817
|
```
|
|
791
818
|
|
|
792
819
|
#### Parameters
|
|
793
820
|
|
|
794
|
-
* `
|
|
795
|
-
* `
|
|
821
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
822
|
+
* `prop`  
|
|
823
|
+
* `elementSize` **[string][5]?** x, y, width or height of the given element.
|
|
796
824
|
|
|
797
|
-
Returns **[Promise][
|
|
825
|
+
Returns **([Promise][9]<DOMRect> | [Promise][9]<[number][12]>)** Element bounding rectangle
|
|
798
826
|
|
|
799
|
-
###
|
|
827
|
+
### grabFromClipboard
|
|
800
828
|
|
|
801
|
-
|
|
829
|
+
Grabs the text content of the system clipboard and returns it to test.
|
|
830
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
802
831
|
|
|
803
832
|
```js
|
|
804
|
-
I.
|
|
833
|
+
I.click('Copy to clipboard');
|
|
834
|
+
let url = await I.grabFromClipboard();
|
|
805
835
|
```
|
|
806
836
|
|
|
807
|
-
|
|
837
|
+
Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
838
|
+
in Chromium-based browsers, where read access is granted automatically.
|
|
808
839
|
|
|
809
|
-
|
|
840
|
+
Returns **[Promise][9]<[string][5]>** the system clipboard contents.Appium: support both Android and iOS
|
|
810
841
|
|
|
811
|
-
|
|
842
|
+
### grabHTMLFrom
|
|
843
|
+
|
|
844
|
+
Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
845
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
846
|
+
If more than one element is found - HTML of first element is returned.
|
|
812
847
|
|
|
813
848
|
```js
|
|
814
|
-
I.
|
|
849
|
+
let postHTML = await I.grabHTMLFrom('#post');
|
|
815
850
|
```
|
|
816
851
|
|
|
817
|
-
See corresponding [webdriverio reference][15].
|
|
818
|
-
|
|
819
852
|
#### Parameters
|
|
820
853
|
|
|
821
|
-
* `
|
|
822
|
-
* `
|
|
823
|
-
* `duration`  
|
|
824
|
-
* `radius`  
|
|
825
|
-
* `rotation`  
|
|
826
|
-
* `touchCount`  
|
|
854
|
+
* `locator`  
|
|
855
|
+
* `element` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
827
856
|
|
|
828
|
-
Returns **[Promise][
|
|
857
|
+
Returns **[Promise][9]<[string][5]>** HTML code for an element
|
|
829
858
|
|
|
830
|
-
###
|
|
859
|
+
### grabHTMLFromAll
|
|
831
860
|
|
|
832
|
-
|
|
861
|
+
Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
|
|
862
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
833
863
|
|
|
834
|
-
|
|
864
|
+
```js
|
|
865
|
+
let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
866
|
+
```
|
|
835
867
|
|
|
836
868
|
#### Parameters
|
|
837
869
|
|
|
838
|
-
* `
|
|
839
|
-
* `
|
|
870
|
+
* `locator`  
|
|
871
|
+
* `element` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
840
872
|
|
|
841
|
-
Returns **[Promise][
|
|
873
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** HTML code for an element
|
|
842
874
|
|
|
843
|
-
###
|
|
875
|
+
### grabNetworkConnection
|
|
844
876
|
|
|
845
|
-
|
|
877
|
+
Get information about the current network connection (Data/WIFI/Airplane).
|
|
878
|
+
The actual server value will be a number. However WebdriverIO additional
|
|
879
|
+
properties to the response object to allow easier assertions.
|
|
846
880
|
|
|
847
881
|
```js
|
|
848
|
-
I.
|
|
849
|
-
I.touchId(true); // simulates valid fingerprint
|
|
850
|
-
I.touchId(false); // simulates invalid fingerprint
|
|
882
|
+
let con = await I.grabNetworkConnection();
|
|
851
883
|
```
|
|
852
884
|
|
|
853
|
-
|
|
885
|
+
Returns **[Promise][9]<{}>** Appium: support only Android
|
|
854
886
|
|
|
855
|
-
|
|
887
|
+
### grabNumberOfOpenTabs
|
|
856
888
|
|
|
857
|
-
|
|
858
|
-
|
|
889
|
+
Grab number of open tabs.
|
|
890
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
859
891
|
|
|
860
|
-
|
|
892
|
+
```js
|
|
893
|
+
let tabs = await I.grabNumberOfOpenTabs();
|
|
894
|
+
```
|
|
861
895
|
|
|
862
|
-
|
|
896
|
+
Returns **[Promise][9]<[number][12]>** number of open tabs
|
|
897
|
+
|
|
898
|
+
### grabNumberOfVisibleElements
|
|
899
|
+
|
|
900
|
+
Grab number of visible elements by locator.
|
|
901
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
902
|
+
|
|
903
|
+
```js
|
|
904
|
+
let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### Parameters
|
|
908
|
+
|
|
909
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
910
|
+
|
|
911
|
+
Returns **[Promise][9]<[number][12]>** number of visible elements
|
|
912
|
+
|
|
913
|
+
### grabOrientation
|
|
914
|
+
|
|
915
|
+
Get current orientation.
|
|
916
|
+
|
|
917
|
+
```js
|
|
918
|
+
let orientation = await I.grabOrientation();
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
Returns **[Promise][9]<[string][5]>** Appium: support Android and iOS
|
|
922
|
+
|
|
923
|
+
### grabPageScrollPosition
|
|
924
|
+
|
|
925
|
+
Retrieves a page scroll position and returns it to test.
|
|
926
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
927
|
+
|
|
928
|
+
```js
|
|
929
|
+
let { x, y } = await I.grabPageScrollPosition();
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
Returns **[Promise][9]<PageScrollPosition>** scroll position
|
|
933
|
+
|
|
934
|
+
### grabSettings
|
|
935
|
+
|
|
936
|
+
Get all the currently specified settings.
|
|
937
|
+
|
|
938
|
+
```js
|
|
939
|
+
let settings = await I.grabSettings();
|
|
940
|
+
```
|
|
941
|
+
|
|
942
|
+
Returns **[Promise][9]<[string][5]>** Appium: support Android and iOS
|
|
943
|
+
|
|
944
|
+
### grabSource
|
|
945
|
+
|
|
946
|
+
Retrieves page source and returns it to test.
|
|
947
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
948
|
+
|
|
949
|
+
```js
|
|
950
|
+
let pageSource = await I.grabSource();
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
Returns **[Promise][9]<[string][5]>** source code
|
|
954
|
+
|
|
955
|
+
### grabTextFrom
|
|
956
|
+
|
|
957
|
+
Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
958
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
959
|
+
|
|
960
|
+
```js
|
|
961
|
+
let pin = await I.grabTextFrom('#pin');
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
If multiple elements found returns first element.
|
|
965
|
+
|
|
966
|
+
#### Parameters
|
|
967
|
+
|
|
968
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
969
|
+
|
|
970
|
+
Returns **[Promise][9]<[string][5]>** attribute value
|
|
971
|
+
|
|
972
|
+
### grabTextFromAll
|
|
973
|
+
|
|
974
|
+
Retrieves all texts from an element located by CSS or XPath and returns it to test.
|
|
975
|
+
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
976
|
+
|
|
977
|
+
```js
|
|
978
|
+
let pins = await I.grabTextFromAll('#pin li');
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
#### Parameters
|
|
982
|
+
|
|
983
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
984
|
+
|
|
985
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** attribute value
|
|
986
|
+
|
|
987
|
+
### grabValueFrom
|
|
988
|
+
|
|
989
|
+
Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
990
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
991
|
+
If more than one element is found - value of first element is returned.
|
|
992
|
+
|
|
993
|
+
```js
|
|
994
|
+
let email = await I.grabValueFrom('input[name=email]');
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
#### Parameters
|
|
998
|
+
|
|
999
|
+
* `locator` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1000
|
+
|
|
1001
|
+
Returns **[Promise][9]<[string][5]>** attribute value
|
|
1002
|
+
|
|
1003
|
+
### grabValueFromAll
|
|
1004
|
+
|
|
1005
|
+
Retrieves an array of value from a form located by CSS or XPath and returns it to test.
|
|
1006
|
+
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
1007
|
+
|
|
1008
|
+
```js
|
|
1009
|
+
let inputs = await I.grabValueFromAll('//form/input');
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
#### Parameters
|
|
1013
|
+
|
|
1014
|
+
* `locator` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1015
|
+
|
|
1016
|
+
Returns **[Promise][9]<[Array][15]<[string][5]>>** attribute value
|
|
1017
|
+
|
|
1018
|
+
### grabWebElement
|
|
1019
|
+
|
|
1020
|
+
Grab WebElement for given locator
|
|
1021
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1022
|
+
|
|
1023
|
+
```js
|
|
1024
|
+
const webElement = await I.grabWebElement('#button');
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
#### Parameters
|
|
1028
|
+
|
|
1029
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1030
|
+
|
|
1031
|
+
Returns **[Promise][9]<any>** WebElement of being used Web helper
|
|
1032
|
+
|
|
1033
|
+
### grabWebElements
|
|
1034
|
+
|
|
1035
|
+
Grab WebElements for given locator
|
|
1036
|
+
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
1037
|
+
|
|
1038
|
+
```js
|
|
1039
|
+
const webElements = await I.grabWebElements('#button');
|
|
1040
|
+
```
|
|
1041
|
+
|
|
1042
|
+
#### Parameters
|
|
1043
|
+
|
|
1044
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1045
|
+
|
|
1046
|
+
Returns **[Promise][9]<any>** WebElement of being used Web helper
|
|
1047
|
+
|
|
1048
|
+
### hideDeviceKeyboard
|
|
1049
|
+
|
|
1050
|
+
Hide the keyboard.
|
|
1051
|
+
|
|
1052
|
+
```js
|
|
1053
|
+
// taps outside to hide keyboard per default
|
|
1054
|
+
I.hideDeviceKeyboard();
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
Appium: support Android and iOS
|
|
1058
|
+
|
|
1059
|
+
### installApp
|
|
1060
|
+
|
|
1061
|
+
Install an app on device.
|
|
1062
|
+
|
|
1063
|
+
```js
|
|
1064
|
+
I.installApp('/path/to/file.apk');
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
#### Parameters
|
|
1068
|
+
|
|
1069
|
+
* `path` **[string][5]** path to apk file
|
|
1070
|
+
|
|
1071
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1072
|
+
|
|
1073
|
+
### makeTouchAction
|
|
1074
|
+
|
|
1075
|
+
The Touch Action API provides the basis of all gestures that can be
|
|
1076
|
+
automated in Appium. At its core is the ability to chain together ad hoc
|
|
1077
|
+
individual actions, which will then be applied to an element in the
|
|
1078
|
+
application on the device.
|
|
1079
|
+
[See complete documentation][17]
|
|
1080
|
+
|
|
1081
|
+
```js
|
|
1082
|
+
I.makeTouchAction("~buttonStartWebviewCD", 'tap');
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
#### Parameters
|
|
1086
|
+
|
|
1087
|
+
* `locator`  
|
|
1088
|
+
* `action`  
|
|
1089
|
+
|
|
1090
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1091
|
+
|
|
1092
|
+
### moveCursorTo
|
|
1093
|
+
|
|
1094
|
+
Moves cursor to element matched by locator.
|
|
1095
|
+
Extra shift can be set with offsetX and offsetY options.
|
|
1096
|
+
|
|
1097
|
+
An optional `context` (as a second parameter) can be specified to narrow the search to an element within a parent.
|
|
1098
|
+
When the second argument is a non-number (string or locator object), it is treated as context.
|
|
1099
|
+
|
|
1100
|
+
```js
|
|
1101
|
+
I.moveCursorTo('.tooltip');
|
|
1102
|
+
I.moveCursorTo('#submit', 5,5);
|
|
1103
|
+
I.moveCursorTo('#submit', '.container');
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
#### Parameters
|
|
1107
|
+
|
|
1108
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
1109
|
+
* `xOffset`  
|
|
1110
|
+
* `yOffset`  
|
|
1111
|
+
* `offsetX` **([number][12] | [string][5] | [object][6])** (optional, `0` by default) X-axis offset or context locator.
|
|
1112
|
+
* `offsetY` **[number][12]** (optional, `0` by default) Y-axis offset.
|
|
1113
|
+
|
|
1114
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1115
|
+
|
|
1116
|
+
### openNotifications
|
|
1117
|
+
|
|
1118
|
+
Open the notifications panel on the device.
|
|
1119
|
+
|
|
1120
|
+
```js
|
|
1121
|
+
I.openNotifications();
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1125
|
+
|
|
1126
|
+
### performSwipe
|
|
1127
|
+
|
|
1128
|
+
Perform a swipe on the screen.
|
|
1129
|
+
|
|
1130
|
+
```js
|
|
1131
|
+
I.performSwipe({ x: 300, y: 100 }, { x: 200, y: 100 });
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
#### Parameters
|
|
1135
|
+
|
|
1136
|
+
* `from` **[object][6]** 
|
|
1137
|
+
* `to` **[object][6]** Appium: support Android and iOS
|
|
1138
|
+
|
|
1139
|
+
### pullFile
|
|
1140
|
+
|
|
1141
|
+
Pulls a file from the device.
|
|
1142
|
+
|
|
1143
|
+
```js
|
|
1144
|
+
I.pullFile('/storage/emulated/0/DCIM/logo.png', 'my/path');
|
|
1145
|
+
// save file to output dir
|
|
1146
|
+
I.pullFile('/storage/emulated/0/DCIM/logo.png', output_dir);
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
#### Parameters
|
|
1150
|
+
|
|
1151
|
+
* `path` **[string][5]** 
|
|
1152
|
+
* `dest` **[string][5]** 
|
|
1153
|
+
|
|
1154
|
+
Returns **[Promise][9]<[string][5]>** Appium: support Android and iOS
|
|
1155
|
+
|
|
1156
|
+
### removeApp
|
|
1157
|
+
|
|
1158
|
+
Remove an app from the device.
|
|
1159
|
+
|
|
1160
|
+
```js
|
|
1161
|
+
I.removeApp('appName', 'com.example.android.apis');
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
Appium: support only Android
|
|
1165
|
+
|
|
1166
|
+
#### Parameters
|
|
1167
|
+
|
|
1168
|
+
* `appId` **[string][5]** 
|
|
1169
|
+
* `bundleId` **[string][5]?** ID of bundle
|
|
1170
|
+
|
|
1171
|
+
### resetApp
|
|
1172
|
+
|
|
1173
|
+
Reset the currently running app for current session.
|
|
1174
|
+
|
|
1175
|
+
```js
|
|
1176
|
+
I.resetApp();
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
### rightClick
|
|
1180
|
+
|
|
1181
|
+
Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
1182
|
+
|
|
1183
|
+
```js
|
|
1184
|
+
// right click element with id el
|
|
1185
|
+
I.rightClick('#el');
|
|
1186
|
+
// right click link or button with text "Click me"
|
|
1187
|
+
I.rightClick('Click me');
|
|
1188
|
+
// right click button with text "Click me" inside .context
|
|
1189
|
+
I.rightClick('Click me', '.context');
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
#### Parameters
|
|
1193
|
+
|
|
1194
|
+
* `locator` **([string][5] | [object][6])** clickable element located by CSS|XPath|strict locator.
|
|
1195
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1196
|
+
|
|
1197
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1198
|
+
|
|
1199
|
+
### rotate
|
|
1200
|
+
|
|
1201
|
+
Perform a rotation gesture centered on the specified element.
|
|
1202
|
+
|
|
1203
|
+
```js
|
|
1204
|
+
I.rotate(120, 120)
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
See corresponding [webdriverio reference][18].
|
|
1208
|
+
|
|
1209
|
+
#### Parameters
|
|
1210
|
+
|
|
1211
|
+
* `x`  
|
|
1212
|
+
* `y`  
|
|
1213
|
+
* `duration`  
|
|
1214
|
+
* `radius`  
|
|
1215
|
+
* `rotation`  
|
|
1216
|
+
* `touchCount`  
|
|
1217
|
+
|
|
1218
|
+
Returns **[Promise][9]<void>** Appium: support only iOS
|
|
1219
|
+
|
|
1220
|
+
### runInWeb
|
|
1221
|
+
|
|
1222
|
+
Execute code only in Web mode.
|
|
1223
|
+
|
|
1224
|
+
```js
|
|
1225
|
+
I.runInWeb(() => {
|
|
1226
|
+
I.waitForElement('#data');
|
|
1227
|
+
I.seeInCurrentUrl('/data');
|
|
1228
|
+
});
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
### runOnAndroid
|
|
1232
|
+
|
|
1233
|
+
Execute code only on Android
|
|
1234
|
+
|
|
1235
|
+
```js
|
|
1236
|
+
I.runOnAndroid(() => {
|
|
1237
|
+
I.click('io.selendroid.testapp:id/buttonTest');
|
|
1238
|
+
});
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
Additional filter can be applied by checking for capabilities.
|
|
1242
|
+
For instance, this code will be executed only on Android 6.0:
|
|
1243
|
+
|
|
1244
|
+
```js
|
|
1245
|
+
I.runOnAndroid({platformVersion: '6.0'},() => {
|
|
1246
|
+
// ...
|
|
1247
|
+
});
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
Also capabilities can be checked by a function.
|
|
1251
|
+
In this case, code will be executed only on Android >= 6.
|
|
1252
|
+
|
|
1253
|
+
```js
|
|
1254
|
+
I.runOnAndroid((caps) => {
|
|
1255
|
+
// caps is current config of desiredCapabiliites
|
|
1256
|
+
return caps.platformVersion >= 6
|
|
1257
|
+
},() => {
|
|
1258
|
+
// ...
|
|
1259
|
+
});
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
#### Parameters
|
|
1263
|
+
|
|
1264
|
+
* `caps` **any** 
|
|
1265
|
+
* `fn` **any** 
|
|
1266
|
+
|
|
1267
|
+
### runOnIOS
|
|
1268
|
+
|
|
1269
|
+
Execute code only on iOS
|
|
1270
|
+
|
|
1271
|
+
```js
|
|
1272
|
+
I.runOnIOS(() => {
|
|
1273
|
+
I.click('//UIAApplication[1]/UIAWindow[1]/UIAButton[1]');
|
|
1274
|
+
I.see('Hi, IOS', '~welcome');
|
|
1275
|
+
});
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
Additional filter can be applied by checking for capabilities.
|
|
1279
|
+
For instance, this code will be executed only on iPhone 5s:
|
|
1280
|
+
|
|
1281
|
+
```js
|
|
1282
|
+
I.runOnIOS({deviceName: 'iPhone 5s'},() => {
|
|
1283
|
+
// ...
|
|
1284
|
+
});
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
Also capabilities can be checked by a function.
|
|
1288
|
+
|
|
1289
|
+
```js
|
|
1290
|
+
I.runOnAndroid((caps) => {
|
|
1291
|
+
// caps is current config of desiredCapabiliites
|
|
1292
|
+
return caps.platformVersion >= 6
|
|
1293
|
+
},() => {
|
|
1294
|
+
// ...
|
|
1295
|
+
});
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
#### Parameters
|
|
1299
|
+
|
|
1300
|
+
* `caps` **any** 
|
|
1301
|
+
* `fn` **any** 
|
|
1302
|
+
|
|
1303
|
+
### saveElementScreenshot
|
|
1304
|
+
|
|
1305
|
+
Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
1306
|
+
Filename is relative to output folder.
|
|
1307
|
+
|
|
1308
|
+
```js
|
|
1309
|
+
I.saveElementScreenshot(`#submit`,'debug.png');
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
#### Parameters
|
|
1313
|
+
|
|
1314
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1315
|
+
* `fileName` **[string][5]** file name to save.
|
|
1316
|
+
|
|
1317
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1318
|
+
|
|
1319
|
+
### saveScreenshot
|
|
1320
|
+
|
|
1321
|
+
Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
|
|
1322
|
+
Filename is relative to output folder.
|
|
1323
|
+
|
|
1324
|
+
```js
|
|
1325
|
+
I.saveScreenshot('debug.png');
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
#### Parameters
|
|
1329
|
+
|
|
1330
|
+
* `fileName` **[string][5]** file name to save.
|
|
1331
|
+
|
|
1332
|
+
Returns **[Promise][9]<void>** 
|
|
1333
|
+
|
|
1334
|
+
### scrollIntoView
|
|
1335
|
+
|
|
1336
|
+
Scroll element into viewport.
|
|
1337
|
+
|
|
1338
|
+
```js
|
|
1339
|
+
I.scrollIntoView('#submit');
|
|
1340
|
+
I.scrollIntoView('#submit', true);
|
|
1341
|
+
I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
#### Parameters
|
|
1345
|
+
|
|
1346
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
1347
|
+
* `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][10])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][19].
|
|
1348
|
+
|
|
1349
|
+
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
|
|
1350
|
+
|
|
1351
|
+
### scrollPageToBottom
|
|
1352
|
+
|
|
1353
|
+
Scroll page to the bottom.
|
|
1354
|
+
|
|
1355
|
+
```js
|
|
1356
|
+
I.scrollPageToBottom();
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1360
|
+
|
|
1361
|
+
### scrollPageToTop
|
|
1362
|
+
|
|
1363
|
+
Scroll page to the top.
|
|
1364
|
+
|
|
1365
|
+
```js
|
|
1366
|
+
I.scrollPageToTop();
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1370
|
+
|
|
1371
|
+
### scrollTo
|
|
1372
|
+
|
|
1373
|
+
Scrolls to element matched by locator.
|
|
1374
|
+
Extra shift can be set with offsetX and offsetY options.
|
|
1375
|
+
|
|
1376
|
+
```js
|
|
1377
|
+
I.scrollTo('footer');
|
|
1378
|
+
I.scrollTo('#submit', 5, 5);
|
|
1379
|
+
```
|
|
1380
|
+
|
|
1381
|
+
#### Parameters
|
|
1382
|
+
|
|
1383
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
1384
|
+
* `offsetX` **[number][12]** (optional, `0` by default) X-axis offset.
|
|
1385
|
+
* `offsetY` **[number][12]** (optional, `0` by default) Y-axis offset.
|
|
1386
|
+
|
|
1387
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1388
|
+
|
|
1389
|
+
### see
|
|
1390
|
+
|
|
1391
|
+
Checks that a page contains a visible text.
|
|
1392
|
+
Use context parameter to narrow down the search.
|
|
1393
|
+
|
|
1394
|
+
```js
|
|
1395
|
+
I.see('Welcome'); // text welcome on a page
|
|
1396
|
+
I.see('Welcome', '.content'); // text inside .content div
|
|
1397
|
+
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1398
|
+
```
|
|
1399
|
+
|
|
1400
|
+
#### Parameters
|
|
1401
|
+
|
|
1402
|
+
* `text` **[string][5]** expected on page.
|
|
1403
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1404
|
+
|
|
1405
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1406
|
+
|
|
1407
|
+
### seeAppIsInstalled
|
|
1408
|
+
|
|
1409
|
+
Check if an app is installed.
|
|
1410
|
+
|
|
1411
|
+
```js
|
|
1412
|
+
I.seeAppIsInstalled("com.example.android.apis");
|
|
1413
|
+
```
|
|
1414
|
+
|
|
1415
|
+
#### Parameters
|
|
1416
|
+
|
|
1417
|
+
* `bundleId` **[string][5]** String ID of bundled app
|
|
1418
|
+
|
|
1419
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1420
|
+
|
|
1421
|
+
### seeAppIsNotInstalled
|
|
1422
|
+
|
|
1423
|
+
Check if an app is not installed.
|
|
1424
|
+
|
|
1425
|
+
```js
|
|
1426
|
+
I.seeAppIsNotInstalled("com.example.android.apis");
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
#### Parameters
|
|
1430
|
+
|
|
1431
|
+
* `bundleId` **[string][5]** String ID of bundled app
|
|
1432
|
+
|
|
1433
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1434
|
+
|
|
1435
|
+
### seeAttributesOnElements
|
|
1436
|
+
|
|
1437
|
+
Checks that all elements with given locator have given attributes.
|
|
1438
|
+
|
|
1439
|
+
```js
|
|
1440
|
+
I.seeAttributesOnElements('//form', { method: "post"});
|
|
1441
|
+
```
|
|
1442
|
+
|
|
1443
|
+
#### Parameters
|
|
1444
|
+
|
|
1445
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
1446
|
+
* `attributes` **[object][6]** attributes and their values to check.
|
|
1447
|
+
|
|
1448
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1449
|
+
|
|
1450
|
+
### seeCheckboxIsChecked
|
|
1451
|
+
|
|
1452
|
+
Verifies that the specified checkbox is checked.
|
|
1453
|
+
|
|
1454
|
+
```js
|
|
1455
|
+
I.seeCheckboxIsChecked('Agree');
|
|
1456
|
+
I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1457
|
+
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1458
|
+
```
|
|
1459
|
+
|
|
1460
|
+
#### Parameters
|
|
1461
|
+
|
|
1462
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
1463
|
+
|
|
1464
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1465
|
+
|
|
1466
|
+
### seeClipboardEquals
|
|
1467
|
+
|
|
1468
|
+
Checks that the system clipboard is equal to the given text.
|
|
1469
|
+
|
|
1470
|
+
```js
|
|
1471
|
+
I.click('Copy to clipboard');
|
|
1472
|
+
I.seeClipboardEquals('https://codecept.io');
|
|
1473
|
+
```
|
|
1474
|
+
|
|
1475
|
+
Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
1476
|
+
in Chromium-based browsers, where read access is granted automatically.
|
|
1477
|
+
|
|
1478
|
+
#### Parameters
|
|
1479
|
+
|
|
1480
|
+
* `text` **[string][5]** value to check.
|
|
1481
|
+
|
|
1482
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1483
|
+
|
|
1484
|
+
### seeCurrentActivityIs
|
|
1485
|
+
|
|
1486
|
+
Check current activity on an Android device.
|
|
1487
|
+
|
|
1488
|
+
```js
|
|
1489
|
+
I.seeCurrentActivityIs(".HomeScreenActivity")
|
|
1490
|
+
```
|
|
1491
|
+
|
|
1492
|
+
#### Parameters
|
|
1493
|
+
|
|
1494
|
+
* `currentActivity` **[string][5]** 
|
|
1495
|
+
|
|
1496
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1497
|
+
|
|
1498
|
+
### seeCurrentPathEquals
|
|
1499
|
+
|
|
1500
|
+
Checks that current URL path matches the expected path.
|
|
1501
|
+
Query strings and URL fragments are ignored.
|
|
1502
|
+
|
|
1503
|
+
```js
|
|
1504
|
+
I.seeCurrentPathEquals('/info'); // passes for '/info', '/info?user=1', '/info#section'
|
|
1505
|
+
I.seeCurrentPathEquals('/'); // passes for '/', '/?user=ok', '/#top'
|
|
1506
|
+
```
|
|
1507
|
+
|
|
1508
|
+
#### Parameters
|
|
1509
|
+
|
|
1510
|
+
* `path` **[string][5]** value to check.
|
|
1511
|
+
|
|
1512
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1513
|
+
|
|
1514
|
+
### seeDeviceIsLocked
|
|
1515
|
+
|
|
1516
|
+
Check whether the device is locked.
|
|
1517
|
+
|
|
1518
|
+
```js
|
|
1519
|
+
I.seeDeviceIsLocked();
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1523
|
+
|
|
1524
|
+
### seeDeviceIsUnlocked
|
|
1525
|
+
|
|
1526
|
+
Check whether the device is not locked.
|
|
1527
|
+
|
|
1528
|
+
```js
|
|
1529
|
+
I.seeDeviceIsUnlocked();
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1533
|
+
|
|
1534
|
+
### seeElement
|
|
1535
|
+
|
|
1536
|
+
Checks that a given Element is visible
|
|
1537
|
+
Element is located by CSS or XPath.
|
|
1538
|
+
|
|
1539
|
+
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
1540
|
+
|
|
1541
|
+
```js
|
|
1542
|
+
I.seeElement('#modal');
|
|
1543
|
+
I.seeElement('#modal', '#container');
|
|
1544
|
+
// using ARIA role locator
|
|
1545
|
+
I.seeElement({role: 'dialog'});
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
> ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][11].
|
|
1549
|
+
|
|
1550
|
+
#### Parameters
|
|
1551
|
+
|
|
1552
|
+
* `locator` **([string][5] | [object][6])** located by CSS|XPath|strict locator.
|
|
1553
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1554
|
+
|
|
1555
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1556
|
+
|
|
1557
|
+
### seeElementInDOM
|
|
1558
|
+
|
|
1559
|
+
Checks that a given Element is present in the DOM
|
|
1560
|
+
Element is located by CSS or XPath.
|
|
1561
|
+
|
|
1562
|
+
```js
|
|
1563
|
+
I.seeElementInDOM('#modal');
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
#### Parameters
|
|
1567
|
+
|
|
1568
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1569
|
+
|
|
1570
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1571
|
+
|
|
1572
|
+
### seeInClipboard
|
|
1573
|
+
|
|
1574
|
+
Checks that the system clipboard contains the given text.
|
|
1575
|
+
|
|
1576
|
+
```js
|
|
1577
|
+
I.click('Copy to clipboard');
|
|
1578
|
+
I.seeInClipboard('https://codecept.io');
|
|
1579
|
+
```
|
|
1580
|
+
|
|
1581
|
+
Reading the clipboard requires a secure context (`https` or `localhost`) and is supported
|
|
1582
|
+
in Chromium-based browsers, where read access is granted automatically.
|
|
1583
|
+
|
|
1584
|
+
#### Parameters
|
|
1585
|
+
|
|
1586
|
+
* `text` **[string][5]** value to check.
|
|
1587
|
+
|
|
1588
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1589
|
+
|
|
1590
|
+
### seeInField
|
|
1591
|
+
|
|
1592
|
+
Checks that the given input field or textarea equals to given value.
|
|
1593
|
+
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1594
|
+
|
|
1595
|
+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1596
|
+
|
|
1597
|
+
```js
|
|
1598
|
+
I.seeInField('Username', 'davert');
|
|
1599
|
+
I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1600
|
+
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1601
|
+
I.seeInField('#searchform input','Search');
|
|
1602
|
+
// within a context
|
|
1603
|
+
I.seeInField('Name', 'John', '.form-container');
|
|
1604
|
+
```
|
|
1605
|
+
|
|
1606
|
+
#### Parameters
|
|
1607
|
+
|
|
1608
|
+
* `field` **([string][5] | [object][6])** located by label|name|CSS|XPath|strict locator.
|
|
1609
|
+
* `value` **([string][5] | [object][6])** value to check.
|
|
1610
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1611
|
+
|
|
1612
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1613
|
+
|
|
1614
|
+
### seeInSource
|
|
1615
|
+
|
|
1616
|
+
Checks that the current page contains the given string in its raw source code.
|
|
1617
|
+
|
|
1618
|
+
```js
|
|
1619
|
+
I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1620
|
+
```
|
|
1621
|
+
|
|
1622
|
+
#### Parameters
|
|
1623
|
+
|
|
1624
|
+
* `text` **[string][5]** value to check.
|
|
1625
|
+
|
|
1626
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1627
|
+
|
|
1628
|
+
### seeNumberOfElements
|
|
1629
|
+
|
|
1630
|
+
Asserts that an element appears a given number of times in the DOM.
|
|
1631
|
+
Element is located by label or name or CSS or XPath.
|
|
1632
|
+
|
|
1633
|
+
```js
|
|
1634
|
+
I.seeNumberOfElements('#submitBtn', 1);
|
|
1635
|
+
```
|
|
1636
|
+
|
|
1637
|
+
#### Parameters
|
|
1638
|
+
|
|
1639
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1640
|
+
* `num` **[number][12]** number of elements.
|
|
1641
|
+
|
|
1642
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1643
|
+
|
|
1644
|
+
### seeNumberOfVisibleElements
|
|
1645
|
+
|
|
1646
|
+
Asserts that an element is visible a given number of times.
|
|
1647
|
+
Element is located by CSS or XPath.
|
|
863
1648
|
|
|
864
1649
|
```js
|
|
865
|
-
I.
|
|
1650
|
+
I.seeNumberOfVisibleElements('.buttons', 3);
|
|
866
1651
|
```
|
|
867
1652
|
|
|
868
|
-
|
|
1653
|
+
#### Parameters
|
|
869
1654
|
|
|
870
|
-
|
|
1655
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1656
|
+
* `num` **[number][12]** number of elements.
|
|
871
1657
|
|
|
872
|
-
|
|
873
|
-
|
|
1658
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1659
|
+
|
|
1660
|
+
### seeOrientationIs
|
|
1661
|
+
|
|
1662
|
+
Check the device orientation
|
|
1663
|
+
|
|
1664
|
+
```js
|
|
1665
|
+
I.seeOrientationIs('PORTRAIT');
|
|
1666
|
+
I.seeOrientationIs('LANDSCAPE')
|
|
1667
|
+
```
|
|
1668
|
+
|
|
1669
|
+
#### Parameters
|
|
1670
|
+
|
|
1671
|
+
* `orientation` **(`"LANDSCAPE"` | `"PORTRAIT"`)** LANDSCAPE or PORTRAITAppium: support Android and iOS
|
|
1672
|
+
|
|
1673
|
+
Returns **[Promise][9]<void>** 
|
|
1674
|
+
|
|
1675
|
+
### seeTextEquals
|
|
1676
|
+
|
|
1677
|
+
Checks that text is equal to provided one.
|
|
1678
|
+
|
|
1679
|
+
```js
|
|
1680
|
+
I.seeTextEquals('text', 'h1');
|
|
1681
|
+
```
|
|
1682
|
+
|
|
1683
|
+
#### Parameters
|
|
1684
|
+
|
|
1685
|
+
* `text` **[string][5]** element value to check.
|
|
1686
|
+
* `context` **([string][5] | [object][6])?** element located by CSS|XPath|strict locator.
|
|
1687
|
+
|
|
1688
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1689
|
+
|
|
1690
|
+
### selectOption
|
|
1691
|
+
|
|
1692
|
+
Selects an option in a drop-down select.
|
|
1693
|
+
Field is searched by label | name | CSS | XPath.
|
|
1694
|
+
Option is selected by visible text or by value.
|
|
874
1695
|
|
|
875
1696
|
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
876
1697
|
|
|
877
1698
|
```js
|
|
878
|
-
I.
|
|
879
|
-
//
|
|
880
|
-
I.
|
|
1699
|
+
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
1700
|
+
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
1701
|
+
I.selectOption('subscription', '0'); // or by value
|
|
1702
|
+
I.selectOption('//form/select[@name=account]','Premium');
|
|
1703
|
+
I.selectOption('form select[name=account]', 'Premium');
|
|
1704
|
+
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
881
1705
|
// within a context
|
|
882
|
-
I.
|
|
1706
|
+
I.selectOption('age', '21-60', '#section2');
|
|
1707
|
+
```
|
|
1708
|
+
|
|
1709
|
+
Provide an array for the second argument to select multiple options.
|
|
1710
|
+
|
|
1711
|
+
```js
|
|
1712
|
+
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
883
1713
|
```
|
|
884
1714
|
|
|
885
1715
|
#### Parameters
|
|
886
1716
|
|
|
887
|
-
* `
|
|
888
|
-
* `
|
|
889
|
-
* `context` **([string][5]? | [object][
|
|
1717
|
+
* `select` **([string][5] | [object][6])** field located by label|name|CSS|XPath|strict locator.
|
|
1718
|
+
* `option` **([string][5] | [Array][15]<any>)** visible text or value of option.
|
|
1719
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
890
1720
|
|
|
891
|
-
Returns **void** automatically synchronized promise through #
|
|
1721
|
+
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
|
|
892
1722
|
|
|
893
|
-
###
|
|
1723
|
+
### sendDeviceKeyEvent
|
|
894
1724
|
|
|
895
|
-
|
|
896
|
-
|
|
1725
|
+
Send a key event to the device.
|
|
1726
|
+
List of keys: [https://developer.android.com/reference/android/view/KeyEvent.html][20]
|
|
897
1727
|
|
|
898
|
-
|
|
1728
|
+
```js
|
|
1729
|
+
I.sendDeviceKeyEvent(3);
|
|
1730
|
+
```
|
|
1731
|
+
|
|
1732
|
+
#### Parameters
|
|
1733
|
+
|
|
1734
|
+
* `keyValue` **[number][12]** Device specific key value
|
|
1735
|
+
|
|
1736
|
+
Returns **[Promise][9]<void>** Appium: support only Android
|
|
1737
|
+
|
|
1738
|
+
### setImmediateValue
|
|
1739
|
+
|
|
1740
|
+
Set immediate value in app.
|
|
1741
|
+
|
|
1742
|
+
See corresponding [webdriverio reference][21].
|
|
1743
|
+
|
|
1744
|
+
#### Parameters
|
|
1745
|
+
|
|
1746
|
+
* `id`  
|
|
1747
|
+
* `value`  
|
|
1748
|
+
|
|
1749
|
+
Returns **[Promise][9]<void>** Appium: support only iOS
|
|
1750
|
+
|
|
1751
|
+
### setNetworkConnection
|
|
1752
|
+
|
|
1753
|
+
Set network connection mode.
|
|
1754
|
+
|
|
1755
|
+
* airplane mode
|
|
1756
|
+
* wifi mode
|
|
1757
|
+
* data data
|
|
899
1758
|
|
|
900
1759
|
```js
|
|
901
|
-
I.
|
|
902
|
-
I.
|
|
903
|
-
I.
|
|
1760
|
+
I.setNetworkConnection(0) // airplane mode off, wifi off, data off
|
|
1761
|
+
I.setNetworkConnection(1) // airplane mode on, wifi off, data off
|
|
1762
|
+
I.setNetworkConnection(2) // airplane mode off, wifi on, data off
|
|
1763
|
+
I.setNetworkConnection(4) // airplane mode off, wifi off, data on
|
|
1764
|
+
I.setNetworkConnection(6) // airplane mode off, wifi on, data on
|
|
904
1765
|
```
|
|
905
1766
|
|
|
1767
|
+
See corresponding [webdriverio reference][22].
|
|
1768
|
+
|
|
1769
|
+
Appium: support only Android
|
|
1770
|
+
|
|
906
1771
|
#### Parameters
|
|
907
1772
|
|
|
908
|
-
* `
|
|
909
|
-
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
|
|
1773
|
+
* `value` **[number][12]** The network connection mode bitmask
|
|
910
1774
|
|
|
911
|
-
Returns **
|
|
1775
|
+
Returns **[Promise][9]<[number][12]>** 
|
|
912
1776
|
|
|
913
|
-
###
|
|
1777
|
+
### setOrientation
|
|
914
1778
|
|
|
915
|
-
|
|
916
|
-
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
917
|
-
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
918
|
-
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
1779
|
+
Set a device orientation. Will fail, if app will not set orientation
|
|
919
1780
|
|
|
920
|
-
|
|
1781
|
+
```js
|
|
1782
|
+
I.setOrientation('PORTRAIT');
|
|
1783
|
+
I.setOrientation('LANDSCAPE')
|
|
1784
|
+
```
|
|
921
1785
|
|
|
922
|
-
|
|
1786
|
+
#### Parameters
|
|
1787
|
+
|
|
1788
|
+
* `orientation` **(`"LANDSCAPE"` | `"PORTRAIT"`)** LANDSCAPE or PORTRAITAppium: support Android and iOS
|
|
1789
|
+
|
|
1790
|
+
### setSettings
|
|
1791
|
+
|
|
1792
|
+
Update the current setting on the device
|
|
923
1793
|
|
|
924
1794
|
```js
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
I.click({css: 'nav a.login'});
|
|
939
|
-
// using ARIA role locator
|
|
940
|
-
I.click({role: 'button', name: 'Submit'});
|
|
1795
|
+
I.setSettings({cyberdelia: 'open'});
|
|
1796
|
+
```
|
|
1797
|
+
|
|
1798
|
+
#### Parameters
|
|
1799
|
+
|
|
1800
|
+
* `settings` **[object][6]** objectAppium: support Android and iOS
|
|
1801
|
+
|
|
1802
|
+
### shakeDevice
|
|
1803
|
+
|
|
1804
|
+
Perform a shake action on the device.
|
|
1805
|
+
|
|
1806
|
+
```js
|
|
1807
|
+
I.shakeDevice();
|
|
941
1808
|
```
|
|
942
1809
|
|
|
943
|
-
|
|
1810
|
+
Returns **[Promise][9]<void>** Appium: support only iOS
|
|
1811
|
+
|
|
1812
|
+
### simulateTouchId
|
|
1813
|
+
|
|
1814
|
+
Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
|
|
1815
|
+
|
|
1816
|
+
```js
|
|
1817
|
+
I.touchId(); // simulates valid fingerprint
|
|
1818
|
+
I.touchId(true); // simulates valid fingerprint
|
|
1819
|
+
I.touchId(false); // simulates invalid fingerprint
|
|
1820
|
+
```
|
|
944
1821
|
|
|
945
1822
|
#### Parameters
|
|
946
1823
|
|
|
947
|
-
* `
|
|
948
|
-
* `context` **([string][5]? | [object][11] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator. (optional, default `null`)
|
|
1824
|
+
* `match`  
|
|
949
1825
|
|
|
950
|
-
Returns **void
|
|
1826
|
+
Returns **[Promise][9]<void>** Appium: support only iOS
|
|
1827
|
+
TODO: not tested
|
|
951
1828
|
|
|
952
|
-
###
|
|
1829
|
+
### startActivity
|
|
953
1830
|
|
|
954
|
-
|
|
1831
|
+
Start an arbitrary Android activity during a session.
|
|
955
1832
|
|
|
956
1833
|
```js
|
|
957
|
-
I.
|
|
958
|
-
I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
|
|
959
|
-
I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1834
|
+
I.startActivity('io.selendroid.testapp', '.RegisterUserActivity');
|
|
960
1835
|
```
|
|
961
1836
|
|
|
1837
|
+
Appium: support only Android
|
|
1838
|
+
|
|
962
1839
|
#### Parameters
|
|
963
1840
|
|
|
964
|
-
* `
|
|
1841
|
+
* `appPackage` **[string][5]** 
|
|
1842
|
+
* `appActivity` **[string][5]** 
|
|
965
1843
|
|
|
966
|
-
Returns **void
|
|
1844
|
+
Returns **[Promise][9]<void>** 
|
|
967
1845
|
|
|
968
|
-
###
|
|
1846
|
+
### swipe
|
|
969
1847
|
|
|
970
|
-
|
|
1848
|
+
Perform a swipe on the screen or an element.
|
|
971
1849
|
|
|
972
|
-
|
|
1850
|
+
```js
|
|
1851
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
1852
|
+
I.swipe(locator, 800, 1200, 1000);
|
|
1853
|
+
```
|
|
1854
|
+
|
|
1855
|
+
[See complete reference][23]
|
|
1856
|
+
|
|
1857
|
+
#### Parameters
|
|
1858
|
+
|
|
1859
|
+
* `locator` **([string][5] | [object][6])** 
|
|
1860
|
+
* `xoffset` **[number][12]** 
|
|
1861
|
+
* `yoffset` **[number][12]** 
|
|
1862
|
+
* `speed` **[number][12]** (optional), 1000 by default
|
|
1863
|
+
|
|
1864
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1865
|
+
|
|
1866
|
+
### swipeDown
|
|
1867
|
+
|
|
1868
|
+
Perform a swipe down on an element.
|
|
973
1869
|
|
|
974
1870
|
```js
|
|
975
|
-
|
|
976
|
-
I.
|
|
1871
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
1872
|
+
I.swipeDown(locator); // simple swipe
|
|
1873
|
+
I.swipeDown(locator, 500); // set speed
|
|
1874
|
+
I.swipeDown(locator, 1200, 1000); // set offset and speed
|
|
977
1875
|
```
|
|
978
1876
|
|
|
979
1877
|
#### Parameters
|
|
980
1878
|
|
|
981
|
-
* `locator` **([string][5] | [object][
|
|
982
|
-
* `
|
|
1879
|
+
* `locator` **([string][5] | [object][6])** 
|
|
1880
|
+
* `yoffset` **[number][12]?** (optional)
|
|
1881
|
+
* `speed` **[number][12]** (optional), 1000 by default
|
|
983
1882
|
|
|
984
|
-
Returns **void
|
|
1883
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
985
1884
|
|
|
986
|
-
###
|
|
1885
|
+
### swipeLeft
|
|
987
1886
|
|
|
988
|
-
|
|
989
|
-
Opposite to `seeInField`.
|
|
1887
|
+
Perform a swipe left on an element.
|
|
990
1888
|
|
|
991
|
-
|
|
1889
|
+
```js
|
|
1890
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
1891
|
+
I.swipeLeft(locator); // simple swipe
|
|
1892
|
+
I.swipeLeft(locator, 500); // set speed
|
|
1893
|
+
I.swipeLeft(locator, 1200, 1000); // set offset and speed
|
|
1894
|
+
```
|
|
1895
|
+
|
|
1896
|
+
#### Parameters
|
|
1897
|
+
|
|
1898
|
+
* `locator` **([string][5] | [object][6])** 
|
|
1899
|
+
* `xoffset` **[number][12]?** (optional)
|
|
1900
|
+
* `speed` **[number][12]** (optional), 1000 by default
|
|
1901
|
+
|
|
1902
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1903
|
+
|
|
1904
|
+
### swipeRight
|
|
1905
|
+
|
|
1906
|
+
Perform a swipe right on an element.
|
|
992
1907
|
|
|
993
1908
|
```js
|
|
994
|
-
|
|
995
|
-
I.
|
|
996
|
-
//
|
|
997
|
-
I.
|
|
1909
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
1910
|
+
I.swipeRight(locator); // simple swipe
|
|
1911
|
+
I.swipeRight(locator, 500); // set speed
|
|
1912
|
+
I.swipeRight(locator, 1200, 1000); // set offset and speed
|
|
998
1913
|
```
|
|
999
1914
|
|
|
1000
1915
|
#### Parameters
|
|
1001
1916
|
|
|
1002
|
-
* `
|
|
1003
|
-
* `
|
|
1004
|
-
* `
|
|
1917
|
+
* `locator` **([string][5] | [object][6])** 
|
|
1918
|
+
* `xoffset` **[number][12]?** (optional)
|
|
1919
|
+
* `speed` **[number][12]** (optional), 1000 by default
|
|
1005
1920
|
|
|
1006
|
-
Returns **void
|
|
1921
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1007
1922
|
|
|
1008
|
-
###
|
|
1923
|
+
### swipeTo
|
|
1009
1924
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1925
|
+
Perform a swipe in selected direction on an element to searchable element.
|
|
1926
|
+
|
|
1927
|
+
```js
|
|
1928
|
+
I.swipeTo(
|
|
1929
|
+
"android.widget.CheckBox", // searchable element
|
|
1930
|
+
"//android.widget.ScrollView/android.widget.LinearLayout", // scroll element
|
|
1931
|
+
"up", // direction
|
|
1932
|
+
30,
|
|
1933
|
+
100,
|
|
1934
|
+
500);
|
|
1935
|
+
```
|
|
1936
|
+
|
|
1937
|
+
#### Parameters
|
|
1938
|
+
|
|
1939
|
+
* `searchableLocator` **[string][5]** 
|
|
1940
|
+
* `scrollLocator` **[string][5]** 
|
|
1941
|
+
* `direction` **[string][5]** 
|
|
1942
|
+
* `timeout` **[number][12]** 
|
|
1943
|
+
* `offset` **[number][12]** 
|
|
1944
|
+
* `speed` **[number][12]** 
|
|
1945
|
+
|
|
1946
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1947
|
+
|
|
1948
|
+
### swipeUp
|
|
1949
|
+
|
|
1950
|
+
Perform a swipe up on an element.
|
|
1012
1951
|
|
|
1013
1952
|
```js
|
|
1014
|
-
|
|
1015
|
-
I.
|
|
1953
|
+
let locator = "#io.selendroid.testapp:id/LinearLayout1";
|
|
1954
|
+
I.swipeUp(locator); // simple swipe
|
|
1955
|
+
I.swipeUp(locator, 500); // set speed
|
|
1956
|
+
I.swipeUp(locator, 1200, 1000); // set offset and speed
|
|
1016
1957
|
```
|
|
1017
1958
|
|
|
1018
1959
|
#### Parameters
|
|
1019
1960
|
|
|
1020
|
-
* `
|
|
1021
|
-
* `
|
|
1022
|
-
|
|
1023
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
1961
|
+
* `locator` **([string][5] | [object][6])** 
|
|
1962
|
+
* `yoffset` **[number][12]?** (optional)
|
|
1963
|
+
* `speed` **[number][12]** (optional), 1000 by default
|
|
1024
1964
|
|
|
1025
|
-
|
|
1965
|
+
Returns **[Promise][9]<void>** Appium: support Android and iOS
|
|
1026
1966
|
|
|
1027
|
-
|
|
1028
|
-
Field is located by name, label, CSS, or XPath.
|
|
1967
|
+
### switchTo
|
|
1029
1968
|
|
|
1030
|
-
|
|
1969
|
+
Switches frame or in case of null locator reverts to parent.
|
|
1031
1970
|
|
|
1032
1971
|
```js
|
|
1033
|
-
//
|
|
1034
|
-
I.
|
|
1035
|
-
// by name
|
|
1036
|
-
I.fillField('password', secret('123456'));
|
|
1037
|
-
// by CSS
|
|
1038
|
-
I.fillField('form#login input[name=username]', 'John');
|
|
1039
|
-
// or by strict locator
|
|
1040
|
-
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1041
|
-
// by ARIA role locator
|
|
1042
|
-
I.fillField({role: 'textbox', name: 'Email'}, 'hello@world.com');
|
|
1043
|
-
// within a context
|
|
1044
|
-
I.fillField('Name', 'John', '#section2');
|
|
1972
|
+
I.switchTo('iframe'); // switch to first iframe
|
|
1973
|
+
I.switchTo(); // switch back to main page
|
|
1045
1974
|
```
|
|
1046
1975
|
|
|
1047
|
-
> ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators][17].
|
|
1048
|
-
|
|
1049
1976
|
#### Parameters
|
|
1050
1977
|
|
|
1051
|
-
* `
|
|
1052
|
-
* `value` **([string][5] | [object][11])** text value to fill.
|
|
1053
|
-
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
|
|
1978
|
+
* `locator` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1054
1979
|
|
|
1055
1980
|
Returns **void** automatically synchronized promise through #recorder
|
|
1056
1981
|
|
|
1057
|
-
###
|
|
1058
|
-
|
|
1059
|
-
Retrieves all texts from an element located by CSS or XPath and returns it to test.
|
|
1060
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1982
|
+
### switchToContext
|
|
1061
1983
|
|
|
1062
|
-
|
|
1063
|
-
let pins = await I.grabTextFromAll('#pin li');
|
|
1064
|
-
```
|
|
1984
|
+
Switch to the specified context.
|
|
1065
1985
|
|
|
1066
1986
|
#### Parameters
|
|
1067
1987
|
|
|
1068
|
-
* `
|
|
1069
|
-
|
|
1070
|
-
Returns **[Promise][6]<[Array][8]<[string][5]>>** attribute value
|
|
1988
|
+
* `context` **any** the context to switch to
|
|
1071
1989
|
|
|
1072
|
-
###
|
|
1990
|
+
### switchToNative
|
|
1073
1991
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1992
|
+
Switches to native context.
|
|
1993
|
+
By default switches to NATIVE_APP context unless other specified.
|
|
1076
1994
|
|
|
1077
1995
|
```js
|
|
1078
|
-
|
|
1079
|
-
```
|
|
1996
|
+
I.switchToNative();
|
|
1080
1997
|
|
|
1081
|
-
|
|
1998
|
+
// or set context explicitly
|
|
1999
|
+
I.switchToNative('SOME_OTHER_CONTEXT');
|
|
2000
|
+
```
|
|
1082
2001
|
|
|
1083
2002
|
#### Parameters
|
|
1084
2003
|
|
|
1085
|
-
* `
|
|
2004
|
+
* `context` **any?**
|
|
1086
2005
|
|
|
1087
|
-
Returns **[Promise][
|
|
2006
|
+
Returns **[Promise][9]<void>** 
|
|
1088
2007
|
|
|
1089
|
-
###
|
|
2008
|
+
### switchToWeb
|
|
1090
2009
|
|
|
1091
|
-
|
|
1092
|
-
|
|
2010
|
+
Switches to web context.
|
|
2011
|
+
If no context is provided switches to the first detected web context
|
|
1093
2012
|
|
|
1094
2013
|
```js
|
|
1095
|
-
|
|
2014
|
+
// switch to first web context
|
|
2015
|
+
I.switchToWeb();
|
|
2016
|
+
|
|
2017
|
+
// or set the context explicitly
|
|
2018
|
+
I.switchToWeb('WEBVIEW_io.selendroid.testapp');
|
|
1096
2019
|
```
|
|
1097
2020
|
|
|
1098
2021
|
#### Parameters
|
|
1099
2022
|
|
|
1100
|
-
* `
|
|
1101
|
-
|
|
1102
|
-
Returns **[Promise][6]<[number][10]>** number of visible elements
|
|
2023
|
+
* `context` **[string][5]?** 
|
|
1103
2024
|
|
|
1104
|
-
|
|
2025
|
+
Returns **[Promise][9]<void>** 
|
|
1105
2026
|
|
|
1106
|
-
|
|
2027
|
+
### switchToWindow
|
|
1107
2028
|
|
|
1108
|
-
|
|
1109
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1110
|
-
If more than one element is found - attribute of first element is returned.
|
|
2029
|
+
Switch to the window with a specified handle.
|
|
1111
2030
|
|
|
1112
2031
|
```js
|
|
1113
|
-
|
|
2032
|
+
const windows = await I.grabAllWindowHandles();
|
|
2033
|
+
// ... do something
|
|
2034
|
+
await I.switchToWindow( windows[0] );
|
|
2035
|
+
|
|
2036
|
+
const window = await I.grabCurrentWindowHandle();
|
|
2037
|
+
// ... do something
|
|
2038
|
+
await I.switchToWindow( window );
|
|
1114
2039
|
```
|
|
1115
2040
|
|
|
1116
2041
|
#### Parameters
|
|
1117
2042
|
|
|
1118
|
-
* `
|
|
1119
|
-
* `attr` **[string][5]** attribute name.
|
|
1120
|
-
|
|
1121
|
-
Returns **[Promise][6]<[string][5]>** attribute value
|
|
2043
|
+
* `window` **[string][5]** name of window handle.
|
|
1122
2044
|
|
|
1123
|
-
###
|
|
2045
|
+
### tap
|
|
1124
2046
|
|
|
1125
|
-
|
|
1126
|
-
Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
|
|
1127
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
2047
|
+
Taps on element.
|
|
1128
2048
|
|
|
1129
2049
|
```js
|
|
1130
|
-
|
|
2050
|
+
I.tap("~buttonStartWebviewCD");
|
|
1131
2051
|
```
|
|
1132
2052
|
|
|
2053
|
+
Shortcut for `makeTouchAction`
|
|
2054
|
+
|
|
1133
2055
|
#### Parameters
|
|
1134
2056
|
|
|
1135
|
-
* `locator` **
|
|
1136
|
-
* `attr` **[string][5]** attribute name.
|
|
2057
|
+
* `locator` **any** 
|
|
1137
2058
|
|
|
1138
|
-
Returns **[Promise][
|
|
2059
|
+
Returns **[Promise][9]<void>** 
|
|
1139
2060
|
|
|
1140
|
-
###
|
|
2061
|
+
### touchPerform
|
|
1141
2062
|
|
|
1142
|
-
|
|
1143
|
-
|
|
2063
|
+
Performs a specific touch action.
|
|
2064
|
+
The action object need to contain the action name, x/y coordinates
|
|
1144
2065
|
|
|
1145
2066
|
```js
|
|
1146
|
-
|
|
2067
|
+
I.touchPerform([{
|
|
2068
|
+
action: 'press',
|
|
2069
|
+
options: {
|
|
2070
|
+
x: 100,
|
|
2071
|
+
y: 200
|
|
2072
|
+
}
|
|
2073
|
+
}, {action: 'release'}])
|
|
2074
|
+
|
|
2075
|
+
I.touchPerform([{
|
|
2076
|
+
action: 'tap',
|
|
2077
|
+
options: {
|
|
2078
|
+
element: '1', // json web element was queried before
|
|
2079
|
+
x: 10, // x offset
|
|
2080
|
+
y: 20, // y offset
|
|
2081
|
+
count: 1 // number of touches
|
|
2082
|
+
}
|
|
2083
|
+
}]);
|
|
1147
2084
|
```
|
|
1148
2085
|
|
|
1149
|
-
|
|
2086
|
+
Appium: support Android and iOS
|
|
1150
2087
|
|
|
1151
|
-
|
|
2088
|
+
#### Parameters
|
|
1152
2089
|
|
|
1153
|
-
|
|
2090
|
+
* `actions` **[Array][15]** Array of touch actions
|
|
1154
2091
|
|
|
1155
|
-
###
|
|
2092
|
+
### type
|
|
1156
2093
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
2094
|
+
Types out the given text into an active field.
|
|
2095
|
+
To slow down typing use a second parameter, to set interval between key presses.
|
|
2096
|
+
*Note:* Should be used when [`fillField`][24] is not an option.
|
|
1160
2097
|
|
|
1161
2098
|
```js
|
|
1162
|
-
|
|
2099
|
+
// passing in a string
|
|
2100
|
+
I.type('Type this out.');
|
|
2101
|
+
|
|
2102
|
+
// typing values with a 100ms interval
|
|
2103
|
+
I.type('4141555311111111', 100);
|
|
2104
|
+
|
|
2105
|
+
// passing in an array
|
|
2106
|
+
I.type(['T', 'E', 'X', 'T']);
|
|
2107
|
+
|
|
2108
|
+
// passing a secret
|
|
2109
|
+
I.type(secret('123456'));
|
|
1163
2110
|
```
|
|
1164
2111
|
|
|
1165
2112
|
#### Parameters
|
|
1166
2113
|
|
|
1167
|
-
* `
|
|
2114
|
+
* `keys`  
|
|
2115
|
+
* `delay` **[number][12]?** (optional) delay in ms between key presses
|
|
2116
|
+
* `key` **([string][5] | [Array][15]<[string][5]>)** or array of keys to type.
|
|
2117
|
+
|
|
2118
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1168
2119
|
|
|
1169
|
-
|
|
2120
|
+
### uncheckOption
|
|
1170
2121
|
|
|
1171
|
-
|
|
2122
|
+
Appium: not tested
|
|
2123
|
+
Unselects a checkbox or radio button.
|
|
2124
|
+
Element is located by label or name or CSS or XPath.
|
|
1172
2125
|
|
|
1173
|
-
|
|
1174
|
-
Filename is relative to output folder.
|
|
2126
|
+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
|
|
1175
2127
|
|
|
1176
2128
|
```js
|
|
1177
|
-
I.
|
|
2129
|
+
I.uncheckOption('#agree');
|
|
2130
|
+
I.uncheckOption('I Agree to Terms and Conditions');
|
|
2131
|
+
I.uncheckOption('agree', '//form');
|
|
1178
2132
|
```
|
|
1179
2133
|
|
|
1180
2134
|
#### Parameters
|
|
1181
2135
|
|
|
1182
|
-
* `
|
|
2136
|
+
* `field` **([string][5] | [object][6])** checkbox located by label | name | CSS | XPath | strict locator.
|
|
2137
|
+
* `context` **([string][5]? | [object][6])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1183
2138
|
|
|
1184
|
-
Returns **
|
|
2139
|
+
Returns **void** automatically synchronized promise through #recorder
|
|
1185
2140
|
|
|
1186
|
-
###
|
|
2141
|
+
### useWebDriverTo
|
|
1187
2142
|
|
|
1188
|
-
|
|
2143
|
+
Use [webdriverio][25] API inside a test.
|
|
2144
|
+
|
|
2145
|
+
First argument is a description of an action.
|
|
2146
|
+
Second argument is async function that gets this helper as parameter.
|
|
2147
|
+
|
|
2148
|
+
{ [`browser`][25]) } object from WebDriver API is available.
|
|
1189
2149
|
|
|
1190
2150
|
```js
|
|
1191
|
-
I.
|
|
1192
|
-
|
|
1193
|
-
|
|
2151
|
+
I.useWebDriverTo('open multiple windows', async ({ browser }) {
|
|
2152
|
+
// create new window
|
|
2153
|
+
await browser.newWindow('https://webdriver.io');
|
|
2154
|
+
});
|
|
1194
2155
|
```
|
|
1195
2156
|
|
|
1196
2157
|
#### Parameters
|
|
1197
2158
|
|
|
1198
|
-
* `
|
|
1199
|
-
* `
|
|
1200
|
-
|
|
1201
|
-
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
|
|
2159
|
+
* `description` **[string][5]** used to show in logs.
|
|
2160
|
+
* `fn` **[function][26]** async functuion that executed with WebDriver helper as argument
|
|
1202
2161
|
|
|
1203
|
-
###
|
|
2162
|
+
### waitForElement
|
|
1204
2163
|
|
|
1205
|
-
|
|
2164
|
+
Waits for element to be present on page (by default waits for 1sec).
|
|
2165
|
+
Element can be located by CSS or XPath.
|
|
1206
2166
|
|
|
1207
2167
|
```js
|
|
1208
|
-
I.
|
|
1209
|
-
I.
|
|
1210
|
-
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
2168
|
+
I.waitForElement('.btn.continue');
|
|
2169
|
+
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1211
2170
|
```
|
|
1212
2171
|
|
|
1213
2172
|
#### Parameters
|
|
1214
2173
|
|
|
1215
|
-
* `
|
|
2174
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2175
|
+
* `sec` **[number][12]?** (optional, `1` by default) time in seconds to wait
|
|
1216
2176
|
|
|
1217
2177
|
Returns **void** automatically synchronized promise through #recorder
|
|
1218
2178
|
|
|
1219
|
-
###
|
|
1220
|
-
|
|
1221
|
-
Checks that a given Element is visible
|
|
1222
|
-
Element is located by CSS or XPath.
|
|
2179
|
+
### waitForInvisible
|
|
1223
2180
|
|
|
1224
|
-
|
|
2181
|
+
Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
2182
|
+
Element can be located by CSS or XPath.
|
|
1225
2183
|
|
|
1226
2184
|
```js
|
|
1227
|
-
I.
|
|
1228
|
-
I.seeElement('#modal', '#container');
|
|
1229
|
-
// using ARIA role locator
|
|
1230
|
-
I.seeElement({role: 'dialog'});
|
|
2185
|
+
I.waitForInvisible('#popup');
|
|
1231
2186
|
```
|
|
1232
2187
|
|
|
1233
|
-
> ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][17].
|
|
1234
|
-
|
|
1235
2188
|
#### Parameters
|
|
1236
2189
|
|
|
1237
|
-
* `locator` **([string][5] | [object][
|
|
1238
|
-
* `
|
|
2190
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2191
|
+
* `sec` **[number][12]** (optional, `1` by default) time in seconds to wait
|
|
1239
2192
|
|
|
1240
2193
|
Returns **void** automatically synchronized promise through #recorder
|
|
1241
2194
|
|
|
1242
|
-
###
|
|
1243
|
-
|
|
1244
|
-
Checks that the given input field or textarea equals to given value.
|
|
1245
|
-
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
2195
|
+
### waitForText
|
|
1246
2196
|
|
|
1247
|
-
|
|
2197
|
+
Waits for a text to appear (by default waits for 1sec).
|
|
2198
|
+
Element can be located by CSS or XPath.
|
|
2199
|
+
Narrow down search results by providing context.
|
|
1248
2200
|
|
|
1249
2201
|
```js
|
|
1250
|
-
I.
|
|
1251
|
-
I.
|
|
1252
|
-
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1253
|
-
I.seeInField('#searchform input','Search');
|
|
1254
|
-
// within a context
|
|
1255
|
-
I.seeInField('Name', 'John', '.form-container');
|
|
2202
|
+
I.waitForText('Thank you, form has been submitted');
|
|
2203
|
+
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
1256
2204
|
```
|
|
1257
2205
|
|
|
1258
2206
|
#### Parameters
|
|
1259
2207
|
|
|
1260
|
-
* `
|
|
1261
|
-
* `
|
|
1262
|
-
* `context` **([string][5]
|
|
2208
|
+
* `text` **[string][5]** to wait for.
|
|
2209
|
+
* `sec` **[number][12]** (optional, `1` by default) time in seconds to wait
|
|
2210
|
+
* `context` **([string][5] | [object][6])?** (optional) element located by CSS|XPath|strict locator.
|
|
1263
2211
|
|
|
1264
2212
|
Returns **void** automatically synchronized promise through #recorder
|
|
1265
2213
|
|
|
1266
|
-
###
|
|
2214
|
+
### waitForVisible
|
|
1267
2215
|
|
|
1268
|
-
|
|
1269
|
-
|
|
2216
|
+
Waits for an element to become visible on a page (by default waits for 1sec).
|
|
2217
|
+
Element can be located by CSS or XPath.
|
|
1270
2218
|
|
|
1271
2219
|
```js
|
|
1272
|
-
I.
|
|
1273
|
-
I.see('Welcome', '.content'); // text inside .content div
|
|
1274
|
-
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
2220
|
+
I.waitForVisible('#popup');
|
|
1275
2221
|
```
|
|
1276
2222
|
|
|
1277
2223
|
#### Parameters
|
|
1278
2224
|
|
|
1279
|
-
* `
|
|
1280
|
-
* `
|
|
2225
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2226
|
+
* `sec` **[number][12]** (optional, `1` by default) time in seconds to wait
|
|
1281
2227
|
|
|
1282
2228
|
Returns **void** automatically synchronized promise through #recorder
|
|
1283
2229
|
|
|
1284
|
-
###
|
|
2230
|
+
### _isShadowLocator
|
|
1285
2231
|
|
|
1286
|
-
|
|
1287
|
-
Field is searched by label | name | CSS | XPath.
|
|
1288
|
-
Option is selected by visible text or by value.
|
|
2232
|
+
Check if locator is type of "Shadow"
|
|
1289
2233
|
|
|
1290
|
-
|
|
2234
|
+
#### Parameters
|
|
1291
2235
|
|
|
1292
|
-
|
|
1293
|
-
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
1294
|
-
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
1295
|
-
I.selectOption('subscription', '0'); // or by value
|
|
1296
|
-
I.selectOption('//form/select[@name=account]','Premium');
|
|
1297
|
-
I.selectOption('form select[name=account]', 'Premium');
|
|
1298
|
-
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
1299
|
-
// within a context
|
|
1300
|
-
I.selectOption('age', '21-60', '#section2');
|
|
1301
|
-
```
|
|
2236
|
+
* `locator` **[object][6]** 
|
|
1302
2237
|
|
|
1303
|
-
|
|
2238
|
+
### _locate
|
|
2239
|
+
|
|
2240
|
+
Get elements by different locator types, including strict locator.
|
|
2241
|
+
Should be used in custom helpers:
|
|
1304
2242
|
|
|
1305
2243
|
```js
|
|
1306
|
-
|
|
2244
|
+
this.helpers['WebDriver']._locate({name: 'password'}).then //...
|
|
1307
2245
|
```
|
|
1308
2246
|
|
|
1309
2247
|
#### Parameters
|
|
1310
2248
|
|
|
1311
|
-
* `
|
|
1312
|
-
* `
|
|
1313
|
-
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
|
|
2249
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2250
|
+
* `smartWait`
|
|
1314
2251
|
|
|
1315
|
-
|
|
2252
|
+
### _locateByRole
|
|
1316
2253
|
|
|
1317
|
-
|
|
2254
|
+
Locate elements by ARIA role using WebdriverIO accessibility selectors
|
|
1318
2255
|
|
|
1319
|
-
|
|
1320
|
-
|
|
2256
|
+
#### Parameters
|
|
2257
|
+
|
|
2258
|
+
* `locator` **[object][6]** role locator object { role: string, text?: string, exact?: boolean }
|
|
2259
|
+
|
|
2260
|
+
### _locateCheckable
|
|
2261
|
+
|
|
2262
|
+
Find a checkbox by providing human-readable text:
|
|
1321
2263
|
|
|
1322
2264
|
```js
|
|
1323
|
-
|
|
1324
|
-
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2265
|
+
this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').then // ...
|
|
1325
2266
|
```
|
|
1326
2267
|
|
|
1327
2268
|
#### Parameters
|
|
1328
2269
|
|
|
1329
|
-
* `locator` **([string][5] | [object][
|
|
1330
|
-
* `sec` **[number][10]?** (optional, `1` by default) time in seconds to wait (optional, default `null`)
|
|
1331
|
-
|
|
1332
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2270
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1333
2271
|
|
|
1334
|
-
###
|
|
2272
|
+
### _locateClickable
|
|
1335
2273
|
|
|
1336
|
-
|
|
1337
|
-
Element can be located by CSS or XPath.
|
|
2274
|
+
Find a clickable element by providing human-readable text:
|
|
1338
2275
|
|
|
1339
2276
|
```js
|
|
1340
|
-
|
|
2277
|
+
const els = await this.helpers.WebDriver._locateClickable('Next page');
|
|
2278
|
+
const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
|
|
1341
2279
|
```
|
|
1342
2280
|
|
|
1343
2281
|
#### Parameters
|
|
1344
2282
|
|
|
1345
|
-
* `locator` **([string][5] | [object][
|
|
1346
|
-
* `
|
|
1347
|
-
|
|
1348
|
-
Returns **void** automatically synchronized promise through #recorder
|
|
2283
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
2284
|
+
* `context`  
|
|
1349
2285
|
|
|
1350
|
-
###
|
|
2286
|
+
### _locateFields
|
|
1351
2287
|
|
|
1352
|
-
|
|
1353
|
-
Element can be located by CSS or XPath.
|
|
2288
|
+
Find field elements by providing human-readable text:
|
|
1354
2289
|
|
|
1355
2290
|
```js
|
|
1356
|
-
|
|
2291
|
+
this.helpers['WebDriver']._locateFields('Your email').then // ...
|
|
1357
2292
|
```
|
|
1358
2293
|
|
|
1359
2294
|
#### Parameters
|
|
1360
2295
|
|
|
1361
|
-
* `locator` **([string][5] | [object][
|
|
1362
|
-
* `sec` **[number][10]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
2296
|
+
* `locator` **([string][5] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1363
2297
|
|
|
1364
|
-
|
|
2298
|
+
### _locateShadow
|
|
1365
2299
|
|
|
1366
|
-
|
|
2300
|
+
Locate Element within the Shadow Dom
|
|
1367
2301
|
|
|
1368
|
-
|
|
1369
|
-
Element can be located by CSS or XPath.
|
|
1370
|
-
Narrow down search results by providing context.
|
|
2302
|
+
#### Parameters
|
|
1371
2303
|
|
|
1372
|
-
|
|
1373
|
-
I.waitForText('Thank you, form has been submitted');
|
|
1374
|
-
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
1375
|
-
```
|
|
2304
|
+
* `locator` **[object][6]** 
|
|
1376
2305
|
|
|
1377
|
-
|
|
2306
|
+
### _smartWait
|
|
1378
2307
|
|
|
1379
|
-
|
|
1380
|
-
* `sec` **[number][10]** (optional, `1` by default) time in seconds to wait (optional, default `1`)
|
|
1381
|
-
* `context` **([string][5] | [object][11])?** (optional) element located by CSS|XPath|strict locator. (optional, default `null`)
|
|
2308
|
+
Smart Wait to locate an element
|
|
1382
2309
|
|
|
1383
|
-
|
|
2310
|
+
#### Parameters
|
|
2311
|
+
|
|
2312
|
+
* `locator` **[object][6]** 
|
|
1384
2313
|
|
|
1385
2314
|
[1]: http://codecept.io/helpers/WebDriver/
|
|
1386
2315
|
|
|
@@ -1392,28 +2321,44 @@ Returns **void** automatically synchronized promise through #recorder
|
|
|
1392
2321
|
|
|
1393
2322
|
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1394
2323
|
|
|
1395
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
2324
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
2325
|
+
|
|
2326
|
+
[7]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
|
|
2327
|
+
|
|
2328
|
+
[8]: https://playwright.dev/docs/api/class-locator#locator-blur
|
|
2329
|
+
|
|
2330
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
2331
|
+
|
|
2332
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
2333
|
+
|
|
2334
|
+
[11]: /locators#aria-locators
|
|
2335
|
+
|
|
2336
|
+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
2337
|
+
|
|
2338
|
+
[13]: https://webdriver.io/docs/timeouts.html
|
|
2339
|
+
|
|
2340
|
+
[14]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
1396
2341
|
|
|
1397
|
-
[
|
|
2342
|
+
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1398
2343
|
|
|
1399
|
-
[
|
|
2344
|
+
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
|
|
1400
2345
|
|
|
1401
|
-
[
|
|
2346
|
+
[17]: http://webdriver.io/api/mobile/touchAction.html
|
|
1402
2347
|
|
|
1403
|
-
[
|
|
2348
|
+
[18]: http://webdriver.io/api/mobile/rotate.html
|
|
1404
2349
|
|
|
1405
|
-
[
|
|
2350
|
+
[19]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
1406
2351
|
|
|
1407
|
-
[
|
|
2352
|
+
[20]: https://developer.android.com/reference/android/view/KeyEvent.html
|
|
1408
2353
|
|
|
1409
|
-
[
|
|
2354
|
+
[21]: http://webdriver.io/api/mobile/setImmediateValue.html
|
|
1410
2355
|
|
|
1411
|
-
[
|
|
2356
|
+
[22]: https://webdriver.io/docs/api/chromium/#setnetworkconnection
|
|
1412
2357
|
|
|
1413
|
-
[
|
|
2358
|
+
[23]: http://webdriver.io/api/mobile/swipe.html
|
|
1414
2359
|
|
|
1415
|
-
[
|
|
2360
|
+
[24]: #fillfield
|
|
1416
2361
|
|
|
1417
|
-
[
|
|
2362
|
+
[25]: https://webdriver.io/docs/api.html
|
|
1418
2363
|
|
|
1419
|
-
[
|
|
2364
|
+
[26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|