codeceptjs 3.3.2 → 3.3.5-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.
Files changed (77) hide show
  1. package/CHANGELOG.md +44 -2
  2. package/docs/api.md +4 -0
  3. package/docs/basics.md +2 -0
  4. package/docs/bdd.md +12 -0
  5. package/docs/build/JSONResponse.js +44 -3
  6. package/docs/build/Playwright.js +63 -40
  7. package/docs/build/Puppeteer.js +54 -43
  8. package/docs/build/REST.js +23 -9
  9. package/docs/build/WebDriver.js +39 -30
  10. package/docs/changelog.md +6 -2
  11. package/docs/community-helpers.md +1 -0
  12. package/docs/configuration.md +21 -18
  13. package/docs/helpers/Appium.md +0 -723
  14. package/docs/helpers/JSONResponse.md +24 -0
  15. package/docs/helpers/Playwright.md +276 -264
  16. package/docs/helpers/Puppeteer.md +230 -222
  17. package/docs/helpers/REST.md +21 -6
  18. package/docs/helpers/WebDriver.md +265 -259
  19. package/docs/plugins.md +41 -1
  20. package/docs/reports.md +11 -0
  21. package/docs/secrets.md +30 -0
  22. package/docs/wiki/.git/FETCH_HEAD +1 -0
  23. package/docs/wiki/.git/HEAD +1 -0
  24. package/docs/wiki/.git/ORIG_HEAD +1 -0
  25. package/docs/wiki/.git/config +11 -0
  26. package/docs/wiki/.git/description +1 -0
  27. package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
  28. package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
  29. package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +173 -0
  30. package/docs/wiki/.git/hooks/post-update.sample +8 -0
  31. package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
  32. package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
  33. package/docs/wiki/.git/hooks/pre-merge-commit.sample +13 -0
  34. package/docs/wiki/.git/hooks/pre-push.sample +53 -0
  35. package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
  36. package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
  37. package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
  38. package/docs/wiki/.git/hooks/push-to-checkout.sample +78 -0
  39. package/docs/wiki/.git/hooks/update.sample +128 -0
  40. package/docs/wiki/.git/index +0 -0
  41. package/docs/wiki/.git/info/exclude +6 -0
  42. package/docs/wiki/.git/logs/HEAD +1 -0
  43. package/docs/wiki/.git/logs/refs/heads/master +1 -0
  44. package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
  45. package/docs/wiki/.git/objects/pack/pack-5938044f9d30daf1c195fda4dec1d54850933935.idx +0 -0
  46. package/docs/wiki/.git/objects/pack/pack-5938044f9d30daf1c195fda4dec1d54850933935.pack +0 -0
  47. package/docs/wiki/.git/packed-refs +2 -0
  48. package/docs/wiki/.git/refs/heads/master +1 -0
  49. package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
  50. package/docs/wiki/Community-Helpers-&-Plugins.md +7 -3
  51. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +29 -0
  52. package/docs/wiki/Examples.md +39 -48
  53. package/docs/wiki/Release-Process.md +8 -8
  54. package/docs/wiki/Tests.md +62 -60
  55. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +2 -2
  56. package/lib/cli.js +1 -1
  57. package/lib/command/generate.js +3 -0
  58. package/lib/command/init.js +83 -24
  59. package/lib/command/interactive.js +1 -1
  60. package/lib/command/run-workers.js +1 -1
  61. package/lib/command/workers/runTests.js +15 -0
  62. package/lib/helper/JSONResponse.js +44 -3
  63. package/lib/helper/Playwright.js +63 -40
  64. package/lib/helper/Puppeteer.js +54 -43
  65. package/lib/helper/REST.js +23 -9
  66. package/lib/helper/WebDriver.js +39 -30
  67. package/lib/interfaces/gherkin.js +1 -1
  68. package/lib/output.js +4 -0
  69. package/lib/plugin/customLocator.js +50 -3
  70. package/lib/plugin/retryFailedStep.js +1 -1
  71. package/lib/plugin/retryTo.js +1 -8
  72. package/lib/secret.js +31 -1
  73. package/lib/step.js +22 -10
  74. package/lib/utils.js +1 -6
  75. package/package.json +4 -4
  76. package/typings/index.d.ts +158 -0
  77. package/typings/types.d.ts +367 -96
@@ -1255,719 +1255,6 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
1255
1255
  - `context` **([string][4] \| [object][8])?** (optional) element located by CSS|XPath|strict locator.
1256
1256
  [!] returns a _promise_ which is synchronized internally by recorder (optional, default `null`)
1257
1257
 
1258
- ### useWebDriverTo
1259
-
1260
- Use [webdriverio][16] API inside a test.
1261
-
1262
- First argument is a description of an action.
1263
- Second argument is async function that gets this helper as parameter.
1264
-
1265
- { [`browser`][16]) } object from WebDriver API is available.
1266
-
1267
- ```js
1268
- I.useWebDriverTo('open multiple windows', async ({ browser }) {
1269
- // create new window
1270
- await browser.newWindow('https://webdriver.io');
1271
- });
1272
- ```
1273
-
1274
- #### Parameters
1275
-
1276
- - `description` **[string][4]** used to show in logs.
1277
- - `fn` **[function][17]** async functuion that executed with WebDriver helper as argument
1278
-
1279
- ### \_isShadowLocator
1280
-
1281
- Check if locator is type of "Shadow"
1282
-
1283
- #### Parameters
1284
-
1285
- - `locator` **[object][8]**
1286
-
1287
- ### \_locateShadow
1288
-
1289
- Locate Element within the Shadow Dom
1290
-
1291
- #### Parameters
1292
-
1293
- - `locator` **[object][8]**
1294
-
1295
- ### \_smartWait
1296
-
1297
- Smart Wait to locate an element
1298
-
1299
- #### Parameters
1300
-
1301
- - `locator` **[object][8]**
1302
-
1303
- ### \_locate
1304
-
1305
- Get elements by different locator types, including strict locator.
1306
- Should be used in custom helpers:
1307
-
1308
- ```js
1309
- this.helpers['WebDriver']._locate({name: 'password'}).then //...
1310
- ```
1311
-
1312
- #### Parameters
1313
-
1314
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1315
- - `smartWait` (optional, default `false`)
1316
-
1317
- ### \_locateCheckable
1318
-
1319
- Find a checkbox by providing human readable text:
1320
-
1321
- ```js
1322
- this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').then // ...
1323
- ```
1324
-
1325
- #### Parameters
1326
-
1327
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1328
-
1329
- ### \_locateClickable
1330
-
1331
- Find a clickable element by providing human readable text:
1332
-
1333
- ```js
1334
- const els = await this.helpers.WebDriver._locateClickable('Next page');
1335
- const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
1336
- ```
1337
-
1338
- #### Parameters
1339
-
1340
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1341
- - `context`
1342
-
1343
- ### \_locateFields
1344
-
1345
- Find field elements by providing human readable text:
1346
-
1347
- ```js
1348
- this.helpers['WebDriver']._locateFields('Your email').then // ...
1349
- ```
1350
-
1351
- #### Parameters
1352
-
1353
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1354
-
1355
- ### defineTimeout
1356
-
1357
- Set [WebDriver timeouts][18] in realtime.
1358
-
1359
- Timeouts are expected to be passed as object:
1360
-
1361
- ```js
1362
- I.defineTimeout({ script: 5000 });
1363
- I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
1364
- ```
1365
-
1366
- #### Parameters
1367
-
1368
- - `timeouts` **any** WebDriver timeouts object.
1369
-
1370
- ### amOnPage
1371
-
1372
- Opens a web page in a browser. Requires relative or absolute url.
1373
- If url starts with `/`, opens a web page of a site defined in `url` config parameter.
1374
-
1375
- ```js
1376
- I.amOnPage('/'); // opens main page of website
1377
- I.amOnPage('https://github.com'); // opens github
1378
- I.amOnPage('/login'); // opens a login page
1379
- ```
1380
-
1381
- #### Parameters
1382
-
1383
- - `url` **[string][4]** url path or global url.
1384
-
1385
- Returns **void** automatically synchronized promise with recorder #!
1386
-
1387
- ### forceClick
1388
-
1389
- Perform an emulated click on a link or a button, given by a locator.
1390
- Unlike normal click instead of sending native event, emulates a click with JavaScript.
1391
- This works on hidden, animated or inactive elements as well.
1392
-
1393
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
1394
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1395
- For images, the "alt" attribute and inner text of any parent links are searched.
1396
-
1397
- The second parameter is a context (CSS or XPath locator) to narrow the search.
1398
-
1399
- ```js
1400
- // simple link
1401
- I.forceClick('Logout');
1402
- // button of form
1403
- I.forceClick('Submit');
1404
- // CSS button
1405
- I.forceClick('#form input[type=submit]');
1406
- // XPath
1407
- I.forceClick('//form/*[@type=submit]');
1408
- // link in context
1409
- I.forceClick('Logout', '#nav');
1410
- // using strict locator
1411
- I.forceClick({css: 'nav a.login'});
1412
- ```
1413
-
1414
- #### Parameters
1415
-
1416
- - `locator` **([string][4] \| [object][8])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1417
- - `context` **([string][4]? | [object][8])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1418
- [!] returns a _promise_ which is synchronized internally by recorder{{ react }} (optional, default `null`)
1419
-
1420
- ### doubleClick
1421
-
1422
- Performs a double-click on an element matched by link|button|label|CSS or XPath.
1423
- Context can be specified as second parameter to narrow search.
1424
-
1425
- ```js
1426
- I.doubleClick('Edit');
1427
- I.doubleClick('Edit', '.actions');
1428
- I.doubleClick({css: 'button.accept'});
1429
- I.doubleClick('.btn.edit');
1430
- ```
1431
-
1432
- #### Parameters
1433
-
1434
- - `locator` **([string][4] \| [object][8])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1435
- - `context` **([string][4]? | [object][8])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1436
- [!] returns a _promise_ which is synchronized internally by recorder{{ react }} (optional, default `null`)
1437
-
1438
- ### rightClick
1439
-
1440
- Performs right click on a clickable element matched by semantic locator, CSS or XPath.
1441
-
1442
- ```js
1443
- // right click element with id el
1444
- I.rightClick('#el');
1445
- // right click link or button with text "Click me"
1446
- I.rightClick('Click me');
1447
- // right click button with text "Click me" inside .context
1448
- I.rightClick('Click me', '.context');
1449
- ```
1450
-
1451
- #### Parameters
1452
-
1453
- - `locator` **([string][4] \| [object][8])** clickable element located by CSS|XPath|strict locator.
1454
- - `context` **([string][4]? | [object][8])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1455
- [!] returns a _promise_ which is synchronized internally by recorder{{ react }} (optional, default `null`)
1456
-
1457
- ### forceRightClick
1458
-
1459
- Emulates right click on an element.
1460
- Unlike normal click instead of sending native event, emulates a click with JavaScript.
1461
- This works on hidden, animated or inactive elements as well.
1462
-
1463
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
1464
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1465
- For images, the "alt" attribute and inner text of any parent links are searched.
1466
-
1467
- The second parameter is a context (CSS or XPath locator) to narrow the search.
1468
-
1469
- ```js
1470
- // simple link
1471
- I.forceRightClick('Menu');
1472
- ```
1473
-
1474
- #### Parameters
1475
-
1476
- - `locator` **([string][4] \| [object][8])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1477
- - `context` **([string][4]? | [object][8])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1478
- [!] returns a _promise_ which is synchronized internally by recorder{{ react }} (optional, default `null`)
1479
-
1480
- ### clearField
1481
-
1482
- Clears a `<textarea>` or text `<input>` element's value.
1483
-
1484
- ```js
1485
- I.clearField('Email');
1486
- I.clearField('user[email]');
1487
- I.clearField('#email');
1488
- ```
1489
-
1490
- #### Parameters
1491
-
1492
- - `field`
1493
- - `editable` **([string][4] \| [object][8])** field located by label|name|CSS|XPath|strict locator.
1494
- [!] returns a _promise_ which is synchronized internally by recorder
1495
-
1496
- ### attachFile
1497
-
1498
- Attaches a file to element located by label, name, CSS or XPath
1499
- Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
1500
- File will be uploaded to remote system (if tests are running remotely).
1501
-
1502
- ```js
1503
- I.attachFile('Avatar', 'data/avatar.jpg');
1504
- I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
1505
- ```
1506
-
1507
- #### Parameters
1508
-
1509
- - `locator` **([string][4] \| [object][8])** field located by label|name|CSS|XPath|strict locator.
1510
- - `pathToFile` **[string][4]** local file path relative to codecept.json config file.
1511
- [!] returns a _promise_ which is synchronized internally by recorder
1512
- Appium: not tested
1513
-
1514
- ### uncheckOption
1515
-
1516
- Unselects a checkbox or radio button.
1517
- Element is located by label or name or CSS or XPath.
1518
-
1519
- The second parameter is a context (CSS or XPath locator) to narrow the search.
1520
-
1521
- ```js
1522
- I.uncheckOption('#agree');
1523
- I.uncheckOption('I Agree to Terms and Conditions');
1524
- I.uncheckOption('agree', '//form');
1525
- ```
1526
-
1527
- #### Parameters
1528
-
1529
- - `field` **([string][4] \| [object][8])** checkbox located by label | name | CSS | XPath | strict locator.
1530
- - `context` **([string][4]? | [object][8])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1531
- [!] returns a _promise_ which is synchronized internally by recorder
1532
- Appium: not tested (optional, default `null`)
1533
-
1534
- ### grabHTMLFromAll
1535
-
1536
- Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
1537
- Resumes test execution, so **should be used inside async function with `await`** operator.
1538
-
1539
- ```js
1540
- let postHTMLs = await I.grabHTMLFromAll('.post');
1541
- ```
1542
-
1543
- #### Parameters
1544
-
1545
- - `locator`
1546
- - `element` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1547
-
1548
- Returns **[Promise][5]&lt;[Array][6]&lt;[string][4]>>** HTML code for an element
1549
-
1550
- ### grabHTMLFrom
1551
-
1552
- Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
1553
- Resumes test execution, so **should be used inside async function with `await`** operator.
1554
- If more than one element is found - HTML of first element is returned.
1555
-
1556
- ```js
1557
- let postHTML = await I.grabHTMLFrom('#post');
1558
- ```
1559
-
1560
- #### Parameters
1561
-
1562
- - `locator`
1563
- - `element` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1564
-
1565
- Returns **[Promise][5]&lt;[string][4]>** HTML code for an element
1566
-
1567
- ### seeTextEquals
1568
-
1569
- Checks that text is equal to provided one.
1570
-
1571
- ```js
1572
- I.seeTextEquals('text', 'h1');
1573
- ```
1574
-
1575
- #### Parameters
1576
-
1577
- - `text` **[string][4]** element value to check.
1578
- - `context` **([string][4] \| [object][8])?** element located by CSS|XPath|strict locator.
1579
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `null`)
1580
-
1581
- ### seeElementInDOM
1582
-
1583
- Checks that a given Element is present in the DOM
1584
- Element is located by CSS or XPath.
1585
-
1586
- ```js
1587
- I.seeElementInDOM('#modal');
1588
- ```
1589
-
1590
- #### Parameters
1591
-
1592
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1593
- [!] returns a _promise_ which is synchronized internally by recorder
1594
-
1595
- ### dontSeeElementInDOM
1596
-
1597
- Opposite to `seeElementInDOM`. Checks that element is not on page.
1598
-
1599
- ```js
1600
- I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
1601
- ```
1602
-
1603
- #### Parameters
1604
-
1605
- - `locator` **([string][4] \| [object][8])** located by CSS|XPath|Strict locator.
1606
- [!] returns a _promise_ which is synchronized internally by recorder
1607
-
1608
- ### seeInSource
1609
-
1610
- Checks that the current page contains the given string in its raw source code.
1611
-
1612
- ```js
1613
- I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1614
- ```
1615
-
1616
- #### Parameters
1617
-
1618
- - `text` **[string][4]** value to check.
1619
- [!] returns a _promise_ which is synchronized internally by recorder
1620
-
1621
- ### grabSource
1622
-
1623
- Retrieves page source and returns it to test.
1624
- Resumes test execution, so **should be used inside async function with `await`** operator.
1625
-
1626
- ```js
1627
- let pageSource = await I.grabSource();
1628
- ```
1629
-
1630
- Returns **[Promise][5]&lt;[string][4]>** source code
1631
-
1632
- ### grabBrowserLogs
1633
-
1634
- Get JS log from browser. Log buffer is reset after each request.
1635
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1636
-
1637
- ```js
1638
- let logs = await I.grabBrowserLogs();
1639
- console.log(JSON.stringify(logs))
1640
- ```
1641
-
1642
- Returns **([Promise][5]&lt;[Array][6]&lt;[object][8]>> | [undefined][19])** all browser logs
1643
-
1644
- ### dontSeeInSource
1645
-
1646
- Checks that the current page does not contains the given string in its raw source code.
1647
-
1648
- ```js
1649
- I.dontSeeInSource('<!--'); // no comments in source
1650
- ```
1651
-
1652
- #### Parameters
1653
-
1654
- - `text`
1655
- - `value` **[string][4]** to check.
1656
- [!] returns a _promise_ which is synchronized internally by recorder
1657
-
1658
- ### seeNumberOfElements
1659
-
1660
- Asserts that an element appears a given number of times in the DOM.
1661
- Element is located by label or name or CSS or XPath.
1662
-
1663
- ```js
1664
- I.seeNumberOfElements('#submitBtn', 1);
1665
- ```
1666
-
1667
- #### Parameters
1668
-
1669
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1670
- - `num` **[number][10]** number of elements.
1671
- [!] returns a _promise_ which is synchronized internally by recorder
1672
- {{ react }}
1673
-
1674
- ### seeNumberOfVisibleElements
1675
-
1676
- Asserts that an element is visible a given number of times.
1677
- Element is located by CSS or XPath.
1678
-
1679
- ```js
1680
- I.seeNumberOfVisibleElements('.buttons', 3);
1681
- ```
1682
-
1683
- #### Parameters
1684
-
1685
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1686
- - `num` **[number][10]** number of elements.
1687
- [!] returns a _promise_ which is synchronized internally by recorder
1688
- {{ react }}
1689
-
1690
- ### seeAttributesOnElements
1691
-
1692
- Checks that all elements with given locator have given attributes.
1693
-
1694
- ```js
1695
- I.seeAttributesOnElements('//form', { method: "post"});
1696
- ```
1697
-
1698
- #### Parameters
1699
-
1700
- - `locator` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1701
- - `attributes` **[object][8]** attributes and their values to check.
1702
- [!] returns a _promise_ which is synchronized internally by recorder
1703
-
1704
- ### scrollTo
1705
-
1706
- Scrolls to element matched by locator.
1707
- Extra shift can be set with offsetX and offsetY options.
1708
-
1709
- ```js
1710
- I.scrollTo('footer');
1711
- I.scrollTo('#submit', 5, 5);
1712
- ```
1713
-
1714
- #### Parameters
1715
-
1716
- - `locator` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1717
- - `offsetX` **[number][10]** (optional, `0` by default) X-axis offset. (optional, default `0`)
1718
- - `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
1719
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `0`)
1720
-
1721
- ### moveCursorTo
1722
-
1723
- Moves cursor to element matched by locator.
1724
- Extra shift can be set with offsetX and offsetY options.
1725
-
1726
- ```js
1727
- I.moveCursorTo('.tooltip');
1728
- I.moveCursorTo('#submit', 5,5);
1729
- ```
1730
-
1731
- #### Parameters
1732
-
1733
- - `locator` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1734
- - `xOffset`
1735
- - `yOffset`
1736
- - `offsetX` **[number][10]** (optional, `0` by default) X-axis offset. (optional, default `0`)
1737
- - `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
1738
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `0`)
1739
-
1740
- ### saveElementScreenshot
1741
-
1742
- Saves screenshot of the specified locator to ouput folder (set in codecept.json or codecept.conf.js).
1743
- Filename is relative to output folder.
1744
-
1745
- ```js
1746
- I.saveElementScreenshot(`#submit`,'debug.png');
1747
- ```
1748
-
1749
- #### Parameters
1750
-
1751
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1752
- - `fileName` **[string][4]** file name to save.
1753
- [!] returns a _promise_ which is synchronized internally by recorder
1754
-
1755
- ### type
1756
-
1757
- Types out the given text into an active field.
1758
- To slow down typing use a second parameter, to set interval between key presses.
1759
- _Note:_ Should be used when [`fillField`][20] is not an option.
1760
-
1761
- ```js
1762
- // passing in a string
1763
- I.type('Type this out.');
1764
-
1765
- // typing values with a 100ms interval
1766
- I.type('4141555311111111', 100);
1767
-
1768
- // passing in an array
1769
- I.type(['T', 'E', 'X', 'T']);
1770
- ```
1771
-
1772
- #### Parameters
1773
-
1774
- - `keys`
1775
- - `delay` **[number][10]?** (optional) delay in ms between key presses
1776
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `null`)
1777
- - `key` **([string][4] \| [Array][6]&lt;[string][4]>)** or array of keys to type.
1778
-
1779
- ### dragAndDrop
1780
-
1781
- Drag an item to a destination element.
1782
-
1783
- ```js
1784
- I.dragAndDrop('#dragHandle', '#container');
1785
- ```
1786
-
1787
- #### Parameters
1788
-
1789
- - `srcElement` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1790
- - `destElement` **([string][4] \| [object][8])** located by CSS|XPath|strict locator.
1791
- [!] returns a _promise_ which is synchronized internally by recorder
1792
- Appium: not tested
1793
-
1794
- ### dragSlider
1795
-
1796
- Drag the scrubber of a slider to a given position
1797
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1798
-
1799
- ```js
1800
- I.dragSlider('#slider', 30);
1801
- I.dragSlider('#slider', -70);
1802
- ```
1803
-
1804
- #### Parameters
1805
-
1806
- - `locator` **([string][4] \| [object][8])** located by label|name|CSS|XPath|strict locator.
1807
- - `offsetX` **[number][10]** position to drag.
1808
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `0`)
1809
-
1810
- ### grabAllWindowHandles
1811
-
1812
- Get all Window Handles.
1813
- Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
1814
-
1815
- ```js
1816
- const windows = await I.grabAllWindowHandles();
1817
- ```
1818
-
1819
- Returns **[Promise][5]&lt;[Array][6]&lt;[string][4]>>**
1820
-
1821
- ### grabCurrentWindowHandle
1822
-
1823
- Get the current Window Handle.
1824
- Useful for referencing it when calling `I.switchToWindow(handle)`
1825
-
1826
- ```js
1827
- const window = await I.grabCurrentWindowHandle();
1828
- ```
1829
-
1830
- Returns **[Promise][5]&lt;[string][4]>**
1831
-
1832
- ### switchToWindow
1833
-
1834
- Switch to the window with a specified handle.
1835
-
1836
- ```js
1837
- const windows = await I.grabAllWindowHandles();
1838
- // ... do something
1839
- await I.switchToWindow( windows[0] );
1840
-
1841
- const window = await I.grabCurrentWindowHandle();
1842
- // ... do something
1843
- await I.switchToWindow( window );
1844
- ```
1845
-
1846
- #### Parameters
1847
-
1848
- - `window` **[string][4]** name of window handle.
1849
-
1850
- ### closeOtherTabs
1851
-
1852
- Close all tabs except for the current one.
1853
-
1854
- ```js
1855
- I.closeOtherTabs();
1856
- ```
1857
-
1858
- [!] returns a _promise_ which is synchronized internally by recorder
1859
-
1860
- ### switchTo
1861
-
1862
- Switches frame or in case of null locator reverts to parent.
1863
-
1864
- ```js
1865
- I.switchTo('iframe'); // switch to first iframe
1866
- I.switchTo(); // switch back to main page
1867
- ```
1868
-
1869
- #### Parameters
1870
-
1871
- - `locator` **([string][4]? | [object][8])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1872
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `null`)
1873
-
1874
- ### grabNumberOfOpenTabs
1875
-
1876
- Grab number of open tabs.
1877
- Resumes test execution, so **should be used inside async function with `await`** operator.
1878
-
1879
- ```js
1880
- let tabs = await I.grabNumberOfOpenTabs();
1881
- ```
1882
-
1883
- Returns **[Promise][5]&lt;[number][10]>** number of open tabs
1884
-
1885
- ### scrollPageToTop
1886
-
1887
- Scroll page to the top.
1888
-
1889
- ```js
1890
- I.scrollPageToTop();
1891
- ```
1892
-
1893
- [!] returns a _promise_ which is synchronized internally by recorder
1894
-
1895
- ### scrollPageToBottom
1896
-
1897
- Scroll page to the bottom.
1898
-
1899
- ```js
1900
- I.scrollPageToBottom();
1901
- ```
1902
-
1903
- [!] returns a _promise_ which is synchronized internally by recorder
1904
-
1905
- ### grabPageScrollPosition
1906
-
1907
- Retrieves a page scroll position and returns it to test.
1908
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1909
-
1910
- ```js
1911
- let { x, y } = await I.grabPageScrollPosition();
1912
- ```
1913
-
1914
- Returns **[Promise][5]&lt;PageScrollPosition>** scroll position
1915
-
1916
- ### setGeoLocation
1917
-
1918
- Set the current geo location
1919
-
1920
- ```js
1921
- I.setGeoLocation(121.21, 11.56);
1922
- I.setGeoLocation(121.21, 11.56, 10);
1923
- ```
1924
-
1925
- #### Parameters
1926
-
1927
- - `latitude` **[number][10]** to set.
1928
- - `longitude` **[number][10]** to set
1929
- - `altitude` **[number][10]?** (optional, null by default) to set
1930
- [!] returns a _promise_ which is synchronized internally by recorder (optional, default `null`)
1931
-
1932
- ### grabGeoLocation
1933
-
1934
- Return the current geo location
1935
- Resumes test execution, so **should be used inside async function with `await`** operator.
1936
-
1937
- ```js
1938
- let geoLocation = await I.grabGeoLocation();
1939
- ```
1940
-
1941
- Returns **[Promise][5]&lt;{latitude: [number][10], longitude: [number][10], altitude: [number][10]}>**
1942
-
1943
- ### grabElementBoundingRect
1944
-
1945
- Grab the width, height, location of given locator.
1946
- Provide `width` or `height`as second param to get your desired prop.
1947
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1948
-
1949
- Returns an object with `x`, `y`, `width`, `height` keys.
1950
-
1951
- ```js
1952
- const value = await I.grabElementBoundingRect('h3');
1953
- // value is like { x: 226.5, y: 89, width: 527, height: 220 }
1954
- ```
1955
-
1956
- To get only one metric use second parameter:
1957
-
1958
- ```js
1959
- const width = await I.grabElementBoundingRect('h3', 'width');
1960
- // width == 527
1961
- ```
1962
-
1963
- #### Parameters
1964
-
1965
- - `locator` **([string][4] \| [object][8])** element located by CSS|XPath|strict locator.
1966
- - `prop`
1967
- - `elementSize` **[string][4]?** x, y, width or height of the given element.
1968
-
1969
- Returns **([Promise][5]&lt;DOMRect> | [Promise][5]&lt;[number][10]>)** Element bounding rectangle
1970
-
1971
1258
  [1]: http://codecept.io/helpers/WebDriver/
1972
1259
 
1973
1260
  [2]: http://appium.io/
@@ -1997,13 +1284,3 @@ Returns **([Promise][5]&lt;DOMRect> | [Promise][5]&lt;[number][10]>)** Element b
1997
1284
  [14]: http://webdriver.io/api/mobile/setImmediateValue.html
1998
1285
 
1999
1286
  [15]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
2000
-
2001
- [16]: https://webdriver.io/docs/api.html
2002
-
2003
- [17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
2004
-
2005
- [18]: https://webdriver.io/docs/timeouts.html
2006
-
2007
- [19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
2008
-
2009
- [20]: #fillfield