codeceptjs 3.5.6 → 3.5.7-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 (140) hide show
  1. package/CHANGELOG.md +2950 -0
  2. package/docs/bdd.md +11 -7
  3. package/docs/build/ApiDataFactory.js +2 -1
  4. package/docs/build/Appium.js +25 -23
  5. package/docs/build/Expect.js +422 -0
  6. package/docs/build/Nightmare.js +53 -56
  7. package/docs/build/Playwright.js +166 -103
  8. package/docs/build/Protractor.js +66 -69
  9. package/docs/build/Puppeteer.js +79 -79
  10. package/docs/build/TestCafe.js +56 -55
  11. package/docs/build/WebDriver.js +81 -82
  12. package/docs/changelog.md +388 -1
  13. package/docs/commands.md +12 -0
  14. package/docs/community-helpers.md +8 -4
  15. package/docs/examples.md +8 -2
  16. package/docs/helpers/Appium.md +50 -32
  17. package/docs/helpers/Expect.md +275 -0
  18. package/docs/helpers/Nightmare.md +141 -94
  19. package/docs/helpers/Playwright.md +280 -211
  20. package/docs/helpers/Protractor.md +229 -169
  21. package/docs/helpers/Puppeteer.md +256 -185
  22. package/docs/helpers/TestCafe.md +201 -149
  23. package/docs/helpers/WebDriver.md +252 -178
  24. package/docs/mobile.md +17 -21
  25. package/docs/plugins.md +35 -1
  26. package/docs/webapi/amOnPage.mustache +1 -1
  27. package/docs/webapi/appendField.mustache +1 -1
  28. package/docs/webapi/attachFile.mustache +1 -1
  29. package/docs/webapi/blur.mustache +1 -0
  30. package/docs/webapi/checkOption.mustache +1 -1
  31. package/docs/webapi/clearCookie.mustache +1 -1
  32. package/docs/webapi/clearField.mustache +1 -1
  33. package/docs/webapi/click.mustache +1 -1
  34. package/docs/webapi/clickLink.mustache +1 -1
  35. package/docs/webapi/closeCurrentTab.mustache +1 -1
  36. package/docs/webapi/closeOtherTabs.mustache +1 -1
  37. package/docs/webapi/dontSee.mustache +1 -1
  38. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -1
  39. package/docs/webapi/dontSeeCookie.mustache +1 -1
  40. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +1 -1
  41. package/docs/webapi/dontSeeElement.mustache +1 -1
  42. package/docs/webapi/dontSeeElementInDOM.mustache +1 -1
  43. package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
  44. package/docs/webapi/dontSeeInField.mustache +1 -1
  45. package/docs/webapi/dontSeeInSource.mustache +1 -1
  46. package/docs/webapi/dontSeeInTitle.mustache +1 -1
  47. package/docs/webapi/doubleClick.mustache +1 -1
  48. package/docs/webapi/downloadFile.mustache +1 -1
  49. package/docs/webapi/dragAndDrop.mustache +1 -1
  50. package/docs/webapi/dragSlider.mustache +1 -1
  51. package/docs/webapi/executeAsyncScript.mustache +0 -2
  52. package/docs/webapi/executeScript.mustache +0 -2
  53. package/docs/webapi/fillField.mustache +1 -1
  54. package/docs/webapi/focus.mustache +1 -0
  55. package/docs/webapi/forceClick.mustache +1 -1
  56. package/docs/webapi/forceRightClick.mustache +1 -1
  57. package/docs/webapi/grabCookie.mustache +1 -1
  58. package/docs/webapi/grabDataFromPerformanceTiming.mustache +1 -1
  59. package/docs/webapi/moveCursorTo.mustache +1 -1
  60. package/docs/webapi/openNewTab.mustache +1 -1
  61. package/docs/webapi/pressKey.mustache +1 -1
  62. package/docs/webapi/pressKeyDown.mustache +1 -1
  63. package/docs/webapi/pressKeyUp.mustache +1 -1
  64. package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -1
  65. package/docs/webapi/refreshPage.mustache +1 -1
  66. package/docs/webapi/resizeWindow.mustache +1 -1
  67. package/docs/webapi/rightClick.mustache +1 -1
  68. package/docs/webapi/saveElementScreenshot.mustache +1 -1
  69. package/docs/webapi/saveScreenshot.mustache +1 -1
  70. package/docs/webapi/say.mustache +1 -1
  71. package/docs/webapi/scrollIntoView.mustache +1 -1
  72. package/docs/webapi/scrollPageToBottom.mustache +1 -1
  73. package/docs/webapi/scrollPageToTop.mustache +1 -1
  74. package/docs/webapi/scrollTo.mustache +1 -1
  75. package/docs/webapi/see.mustache +1 -1
  76. package/docs/webapi/seeAttributesOnElements.mustache +1 -1
  77. package/docs/webapi/seeCheckboxIsChecked.mustache +1 -1
  78. package/docs/webapi/seeCookie.mustache +1 -1
  79. package/docs/webapi/seeCssPropertiesOnElements.mustache +1 -1
  80. package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
  81. package/docs/webapi/seeElement.mustache +1 -1
  82. package/docs/webapi/seeElementInDOM.mustache +1 -1
  83. package/docs/webapi/seeInCurrentUrl.mustache +1 -1
  84. package/docs/webapi/seeInField.mustache +1 -1
  85. package/docs/webapi/seeInPopup.mustache +1 -1
  86. package/docs/webapi/seeInSource.mustache +1 -1
  87. package/docs/webapi/seeInTitle.mustache +1 -1
  88. package/docs/webapi/seeNumberOfElements.mustache +1 -1
  89. package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -1
  90. package/docs/webapi/seeTextEquals.mustache +1 -1
  91. package/docs/webapi/seeTitleEquals.mustache +1 -1
  92. package/docs/webapi/selectOption.mustache +1 -1
  93. package/docs/webapi/setCookie.mustache +1 -1
  94. package/docs/webapi/setGeoLocation.mustache +1 -1
  95. package/docs/webapi/switchTo.mustache +1 -1
  96. package/docs/webapi/switchToNextTab.mustache +1 -1
  97. package/docs/webapi/switchToPreviousTab.mustache +1 -1
  98. package/docs/webapi/type.mustache +1 -1
  99. package/docs/webapi/uncheckOption.mustache +1 -1
  100. package/docs/webapi/wait.mustache +1 -1
  101. package/docs/webapi/waitForClickable.mustache +1 -1
  102. package/docs/webapi/waitForDetached.mustache +1 -1
  103. package/docs/webapi/waitForElement.mustache +1 -1
  104. package/docs/webapi/waitForEnabled.mustache +1 -1
  105. package/docs/webapi/waitForFunction.mustache +1 -1
  106. package/docs/webapi/waitForInvisible.mustache +1 -1
  107. package/docs/webapi/waitForText.mustache +1 -1
  108. package/docs/webapi/waitForValue.mustache +1 -1
  109. package/docs/webapi/waitForVisible.mustache +1 -1
  110. package/docs/webapi/waitInUrl.mustache +1 -1
  111. package/docs/webapi/waitNumberOfVisibleElements.mustache +1 -1
  112. package/docs/webapi/waitToHide.mustache +1 -1
  113. package/docs/webapi/waitUrlEquals.mustache +1 -1
  114. package/lib/ai.js +12 -3
  115. package/lib/cli.js +3 -1
  116. package/lib/command/dryRun.js +2 -1
  117. package/lib/helper/ApiDataFactory.js +2 -1
  118. package/lib/helper/Appium.js +7 -5
  119. package/lib/helper/Expect.js +422 -0
  120. package/lib/helper/Playwright.js +91 -32
  121. package/lib/helper/Puppeteer.js +2 -2
  122. package/lib/html.js +3 -3
  123. package/lib/interfaces/gherkin.js +21 -2
  124. package/lib/output.js +1 -1
  125. package/lib/pause.js +6 -3
  126. package/lib/plugin/autoLogin.js +35 -3
  127. package/lib/plugin/heal.js +40 -7
  128. package/lib/recorder.js +12 -5
  129. package/package.json +15 -8
  130. package/translations/de-DE.js +5 -0
  131. package/translations/fr-FR.js +1 -0
  132. package/translations/it-IT.js +1 -0
  133. package/translations/ja-JP.js +5 -0
  134. package/translations/pl-PL.js +5 -0
  135. package/translations/pt-BR.js +1 -0
  136. package/translations/ru-RU.js +1 -0
  137. package/translations/zh-CN.js +5 -0
  138. package/translations/zh-TW.js +5 -0
  139. package/typings/promiseBasedTypes.d.ts +904 -862
  140. package/typings/types.d.ts +904 -845
@@ -694,7 +694,7 @@ class Playwright extends Helper {
694
694
  * I.seeInPopup('Popup text');
695
695
  * ```
696
696
  * @param {string} text value to check.
697
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
697
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
698
698
  *
699
699
  */
700
700
  async seeInPopup(text) {
@@ -900,7 +900,8 @@ class Playwright extends Helper {
900
900
  * ```
901
901
  *
902
902
  * @param {string} url url path or global url.
903
- * @return {void} automatically synchronized promise with recorder #!
903
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
904
+ *
904
905
  */
905
906
  async amOnPage(url) {
906
907
  if (this.isElectron) {
@@ -938,7 +939,7 @@ class Playwright extends Helper {
938
939
  *
939
940
  * @param {number} width width in pixels or `maximize`.
940
941
  * @param {number} height height in pixels.
941
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
942
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
942
943
  *
943
944
  *
944
945
  * Unlike other drivers Playwright changes the size of a viewport, not the window!
@@ -966,14 +967,14 @@ class Playwright extends Helper {
966
967
  * Set headers for all next requests
967
968
  *
968
969
  * ```js
969
- * I.haveRequestHeaders({
970
+ * I.setPlaywrightRequestHeaders({
970
971
  * 'X-Sent-By': 'CodeceptJS',
971
972
  * });
972
973
  * ```
973
974
  *
974
975
  * @param {object} customHeaders headers to set
975
976
  */
976
- async haveRequestHeaders(customHeaders) {
977
+ async setPlaywrightRequestHeaders(customHeaders) {
977
978
  if (!customHeaders) {
978
979
  throw new Error('Cannot send empty headers.');
979
980
  }
@@ -992,7 +993,7 @@ class Playwright extends Helper {
992
993
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
993
994
  * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
994
995
  * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
995
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
996
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
996
997
  *
997
998
  *
998
999
  */
@@ -1019,6 +1020,7 @@ class Playwright extends Helper {
1019
1020
  *
1020
1021
  * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
1021
1022
  * @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
1023
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1022
1024
  *
1023
1025
  *
1024
1026
  */
@@ -1048,6 +1050,7 @@ class Playwright extends Helper {
1048
1050
  *
1049
1051
  * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
1050
1052
  * @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
1053
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1051
1054
  *
1052
1055
  *
1053
1056
  */
@@ -1068,7 +1071,7 @@ class Playwright extends Helper {
1068
1071
  *
1069
1072
  * @param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
1070
1073
  * @param {LocatorOrString} destElement located by CSS|XPath|strict locator.
1071
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1074
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1072
1075
  *
1073
1076
  * @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
1074
1077
  *
@@ -1126,7 +1129,7 @@ class Playwright extends Helper {
1126
1129
  * ```js
1127
1130
  * I.refreshPage();
1128
1131
  * ```
1129
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1132
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1130
1133
  *
1131
1134
  */
1132
1135
  async refreshPage() {
@@ -1139,7 +1142,7 @@ class Playwright extends Helper {
1139
1142
  * ```js
1140
1143
  * I.scrollPageToTop();
1141
1144
  * ```
1142
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1145
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1143
1146
  *
1144
1147
  */
1145
1148
  scrollPageToTop() {
@@ -1154,7 +1157,7 @@ class Playwright extends Helper {
1154
1157
  * ```js
1155
1158
  * I.scrollPageToBottom();
1156
1159
  * ```
1157
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1160
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1158
1161
  *
1159
1162
  */
1160
1163
  async scrollPageToBottom() {
@@ -1183,7 +1186,7 @@ class Playwright extends Helper {
1183
1186
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
1184
1187
  * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
1185
1188
  * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
1186
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1189
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1187
1190
  *
1188
1191
  */
1189
1192
  async scrollTo(locator, offsetX = 0, offsetY = 0) {
@@ -1213,7 +1216,7 @@ class Playwright extends Helper {
1213
1216
  * ```
1214
1217
  *
1215
1218
  * @param {string} text text value to check.
1216
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1219
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1217
1220
  *
1218
1221
  */
1219
1222
  async seeInTitle(text) {
@@ -1252,7 +1255,7 @@ class Playwright extends Helper {
1252
1255
  * ```
1253
1256
  *
1254
1257
  * @param {string} text value to check.
1255
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1258
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1256
1259
  *
1257
1260
  */
1258
1261
  async seeTitleEquals(text) {
@@ -1268,7 +1271,7 @@ class Playwright extends Helper {
1268
1271
  * ```
1269
1272
  *
1270
1273
  * @param {string} text value to check.
1271
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1274
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1272
1275
  *
1273
1276
  */
1274
1277
  async dontSeeInTitle(text) {
@@ -1493,7 +1496,7 @@ class Playwright extends Helper {
1493
1496
  * I.seeElement('#modal');
1494
1497
  * ```
1495
1498
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
1496
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1499
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1497
1500
  *
1498
1501
  *
1499
1502
  */
@@ -1511,7 +1514,7 @@ class Playwright extends Helper {
1511
1514
  * ```
1512
1515
  *
1513
1516
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
1514
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1517
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1515
1518
  *
1516
1519
  *
1517
1520
  */
@@ -1529,7 +1532,7 @@ class Playwright extends Helper {
1529
1532
  * I.seeElementInDOM('#modal');
1530
1533
  * ```
1531
1534
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1532
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1535
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1533
1536
  *
1534
1537
  */
1535
1538
  async seeElementInDOM(locator) {
@@ -1545,7 +1548,7 @@ class Playwright extends Helper {
1545
1548
  * ```
1546
1549
  *
1547
1550
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
1548
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1551
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1549
1552
  *
1550
1553
  */
1551
1554
  async dontSeeElementInDOM(locator) {
@@ -1611,7 +1614,7 @@ class Playwright extends Helper {
1611
1614
  *
1612
1615
  * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1613
1616
  * @param {?CodeceptJS.LocatorOrString | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1614
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1617
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1615
1618
  *
1616
1619
  *
1617
1620
  * @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
@@ -1668,7 +1671,7 @@ class Playwright extends Helper {
1668
1671
  *
1669
1672
  * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1670
1673
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1671
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1674
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1672
1675
  *
1673
1676
  */
1674
1677
  async forceClick(locator, context = null) {
@@ -1688,7 +1691,7 @@ class Playwright extends Helper {
1688
1691
  *
1689
1692
  * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1690
1693
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1691
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1694
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1692
1695
  *
1693
1696
  *
1694
1697
  *
@@ -1711,7 +1714,7 @@ class Playwright extends Helper {
1711
1714
  *
1712
1715
  * @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
1713
1716
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
1714
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1717
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1715
1718
  *
1716
1719
  *
1717
1720
  *
@@ -1733,7 +1736,7 @@ class Playwright extends Helper {
1733
1736
  * ```
1734
1737
  * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
1735
1738
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1736
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1739
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1737
1740
  *
1738
1741
  *
1739
1742
  * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
@@ -1765,7 +1768,7 @@ class Playwright extends Helper {
1765
1768
  * ```
1766
1769
  * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
1767
1770
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1768
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1771
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1769
1772
  *
1770
1773
  *
1771
1774
  * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck) for uncheck available as 3rd argument.
@@ -1794,7 +1797,7 @@ class Playwright extends Helper {
1794
1797
  * ```
1795
1798
  *
1796
1799
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1797
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1800
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1798
1801
  *
1799
1802
  */
1800
1803
  async seeCheckboxIsChecked(field) {
@@ -1811,7 +1814,7 @@ class Playwright extends Helper {
1811
1814
  * ```
1812
1815
  *
1813
1816
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1814
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1817
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1815
1818
  *
1816
1819
  */
1817
1820
  async dontSeeCheckboxIsChecked(field) {
@@ -1830,7 +1833,7 @@ class Playwright extends Helper {
1830
1833
  * ```
1831
1834
  *
1832
1835
  * @param {string} key name of key to press down.
1833
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1836
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1834
1837
  *
1835
1838
  */
1836
1839
  async pressKeyDown(key) {
@@ -1851,7 +1854,7 @@ class Playwright extends Helper {
1851
1854
  * ```
1852
1855
  *
1853
1856
  * @param {string} key name of key to release.
1854
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1857
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1855
1858
  *
1856
1859
  */
1857
1860
  async pressKeyUp(key) {
@@ -1920,7 +1923,7 @@ class Playwright extends Helper {
1920
1923
  * - `'Tab'`
1921
1924
  *
1922
1925
  * @param {string|string[]} key key or array of keys to press.
1923
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1926
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1924
1927
  *
1925
1928
  *
1926
1929
  * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
@@ -1971,7 +1974,7 @@ class Playwright extends Helper {
1971
1974
  *
1972
1975
  * @param {string|string[]} key or array of keys to type.
1973
1976
  * @param {?number} [delay=null] (optional) delay in ms between key presses
1974
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
1977
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
1975
1978
  *
1976
1979
  */
1977
1980
  async type(keys, delay = null) {
@@ -2002,7 +2005,7 @@ class Playwright extends Helper {
2002
2005
  * ```
2003
2006
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2004
2007
  * @param {CodeceptJS.StringOrSecret} value text value to fill.
2005
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2008
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2006
2009
  *
2007
2010
  *
2008
2011
  */
@@ -2061,7 +2064,7 @@ class Playwright extends Helper {
2061
2064
  * ```
2062
2065
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
2063
2066
  * @param {string} value text value to append.
2064
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2067
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2065
2068
  *
2066
2069
  *
2067
2070
  *
@@ -2087,7 +2090,7 @@ class Playwright extends Helper {
2087
2090
  * ```
2088
2091
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2089
2092
  * @param {CodeceptJS.StringOrSecret} value value to check.
2090
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2093
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2091
2094
  *
2092
2095
  */
2093
2096
  async seeInField(field, value) {
@@ -2106,7 +2109,7 @@ class Playwright extends Helper {
2106
2109
  *
2107
2110
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2108
2111
  * @param {CodeceptJS.StringOrSecret} value value to check.
2109
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2112
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2110
2113
  *
2111
2114
  */
2112
2115
  async dontSeeInField(field, value) {
@@ -2126,7 +2129,7 @@ class Playwright extends Helper {
2126
2129
  *
2127
2130
  * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2128
2131
  * @param {string} pathToFile local file path relative to codecept.conf.ts or codecept.conf.js config file.
2129
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2132
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2130
2133
  *
2131
2134
  *
2132
2135
  */
@@ -2163,7 +2166,7 @@ class Playwright extends Helper {
2163
2166
  * ```
2164
2167
  * @param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
2165
2168
  * @param {string|Array<*>} option visible text or value of option.
2166
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2169
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2167
2170
  *
2168
2171
  */
2169
2172
  async selectOption(select, option) {
@@ -2205,7 +2208,7 @@ class Playwright extends Helper {
2205
2208
  * ```
2206
2209
  *
2207
2210
  * @param {string} url a fragment to check
2208
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2211
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2209
2212
  *
2210
2213
  */
2211
2214
  async seeInCurrentUrl(url) {
@@ -2216,7 +2219,7 @@ class Playwright extends Helper {
2216
2219
  * Checks that current url does not contain a provided fragment.
2217
2220
  *
2218
2221
  * @param {string} url value to check.
2219
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2222
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2220
2223
  *
2221
2224
  */
2222
2225
  async dontSeeInCurrentUrl(url) {
@@ -2234,7 +2237,7 @@ class Playwright extends Helper {
2234
2237
  * ```
2235
2238
  *
2236
2239
  * @param {string} url value to check.
2237
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2240
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2238
2241
  *
2239
2242
  */
2240
2243
  async seeCurrentUrlEquals(url) {
@@ -2251,7 +2254,7 @@ class Playwright extends Helper {
2251
2254
  * ```
2252
2255
  *
2253
2256
  * @param {string} url value to check.
2254
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2257
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2255
2258
  *
2256
2259
  */
2257
2260
  async dontSeeCurrentUrlEquals(url) {
@@ -2269,7 +2272,7 @@ class Playwright extends Helper {
2269
2272
  * ```
2270
2273
  * @param {string} text expected on page.
2271
2274
  * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
2272
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2275
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2273
2276
  *
2274
2277
  *
2275
2278
  *
@@ -2287,7 +2290,7 @@ class Playwright extends Helper {
2287
2290
  *
2288
2291
  * @param {string} text element value to check.
2289
2292
  * @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
2290
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2293
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2291
2294
  *
2292
2295
  */
2293
2296
  async seeTextEquals(text, context = null) {
@@ -2305,7 +2308,7 @@ class Playwright extends Helper {
2305
2308
  *
2306
2309
  * @param {string} text which is not present.
2307
2310
  * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
2308
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2311
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2309
2312
  *
2310
2313
  *
2311
2314
  *
@@ -2367,7 +2370,7 @@ class Playwright extends Helper {
2367
2370
  * I.seeInSource('<h1>Green eggs &amp; ham</h1>');
2368
2371
  * ```
2369
2372
  * @param {string} text value to check.
2370
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2373
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2371
2374
  *
2372
2375
  */
2373
2376
  async seeInSource(text) {
@@ -2383,7 +2386,7 @@ class Playwright extends Helper {
2383
2386
  * ```
2384
2387
  *
2385
2388
  * @param {string} value to check.
2386
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2389
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2387
2390
  *
2388
2391
  */
2389
2392
  async dontSeeInSource(text) {
@@ -2402,7 +2405,7 @@ class Playwright extends Helper {
2402
2405
  *
2403
2406
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2404
2407
  * @param {number} num number of elements.
2405
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2408
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2406
2409
  *
2407
2410
  *
2408
2411
  *
@@ -2422,7 +2425,7 @@ class Playwright extends Helper {
2422
2425
  *
2423
2426
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2424
2427
  * @param {number} num number of elements.
2425
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2428
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2426
2429
  *
2427
2430
  *
2428
2431
  *
@@ -2448,7 +2451,7 @@ class Playwright extends Helper {
2448
2451
  * ```
2449
2452
  *
2450
2453
  * @param {Cookie|Array<Cookie>} cookie a cookie object or array of cookie objects.
2451
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2454
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2452
2455
  *
2453
2456
  */
2454
2457
  async setCookie(cookie) {
@@ -2466,7 +2469,7 @@ class Playwright extends Helper {
2466
2469
  * ```
2467
2470
  *
2468
2471
  * @param {string} name cookie name.
2469
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2472
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2470
2473
  *
2471
2474
  *
2472
2475
  */
@@ -2483,7 +2486,7 @@ class Playwright extends Helper {
2483
2486
  * ```
2484
2487
  *
2485
2488
  * @param {string} name cookie name.
2486
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2489
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2487
2490
  *
2488
2491
  */
2489
2492
  async dontSeeCookie(name) {
@@ -2502,7 +2505,7 @@ class Playwright extends Helper {
2502
2505
  * ```
2503
2506
  *
2504
2507
  * @param {?string} [name=null] cookie name.
2505
- * @returns {Promise<string>|Promise<string[]>} attribute value
2508
+ * @returns {any} attribute value
2506
2509
  *
2507
2510
  *
2508
2511
  * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
@@ -2524,7 +2527,7 @@ class Playwright extends Helper {
2524
2527
  * ```
2525
2528
  *
2526
2529
  * @param {?string} [cookie=null] (optional, `null` by default) cookie name
2527
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2530
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2528
2531
  *
2529
2532
  */
2530
2533
  async clearCookie() {
@@ -2754,7 +2757,7 @@ class Playwright extends Helper {
2754
2757
  *
2755
2758
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2756
2759
  * @param {object} cssProperties object with CSS properties and their values to check.
2757
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2760
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2758
2761
  *
2759
2762
  *
2760
2763
  */
@@ -2800,7 +2803,7 @@ class Playwright extends Helper {
2800
2803
  *
2801
2804
  * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2802
2805
  * @param {object} attributes attributes and their values to check.
2803
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2806
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2804
2807
  *
2805
2808
  *
2806
2809
  */
@@ -2840,7 +2843,7 @@ class Playwright extends Helper {
2840
2843
  *
2841
2844
  * @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
2842
2845
  * @param {number} offsetX position to drag.
2843
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2846
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2844
2847
  *
2845
2848
  *
2846
2849
  */
@@ -2918,7 +2921,7 @@ class Playwright extends Helper {
2918
2921
  *
2919
2922
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2920
2923
  * @param {string} fileName file name to save.
2921
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2924
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2922
2925
  *
2923
2926
  *
2924
2927
  */
@@ -2944,7 +2947,7 @@ class Playwright extends Helper {
2944
2947
  *
2945
2948
  * @param {string} fileName file name to save.
2946
2949
  * @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
2947
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
2950
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
2948
2951
  *
2949
2952
  */
2950
2953
  async saveScreenshot(fileName, fullPage) {
@@ -3082,7 +3085,7 @@ class Playwright extends Helper {
3082
3085
  * ```
3083
3086
  *
3084
3087
  * @param {number} sec number of second to wait.
3085
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3088
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3086
3089
  *
3087
3090
  */
3088
3091
  async wait(sec) {
@@ -3097,7 +3100,7 @@ class Playwright extends Helper {
3097
3100
  *
3098
3101
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3099
3102
  * @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
3100
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3103
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3101
3104
  *
3102
3105
  */
3103
3106
  async waitForEnabled(locator, sec) {
@@ -3133,7 +3136,7 @@ class Playwright extends Helper {
3133
3136
  * @param {LocatorOrString} field input field.
3134
3137
  * @param {string }value expected value.
3135
3138
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3136
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3139
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3137
3140
  *
3138
3141
  */
3139
3142
  async waitForValue(field, value, sec) {
@@ -3170,7 +3173,7 @@ class Playwright extends Helper {
3170
3173
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3171
3174
  * @param {number} num number of elements.
3172
3175
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3173
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3176
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3174
3177
  *
3175
3178
  *
3176
3179
  */
@@ -3212,7 +3215,7 @@ class Playwright extends Helper {
3212
3215
  *
3213
3216
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3214
3217
  * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3215
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3218
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3216
3219
  *
3217
3220
  */
3218
3221
  async waitForClickable(locator, waitTimeout) {
@@ -3231,7 +3234,7 @@ class Playwright extends Helper {
3231
3234
  *
3232
3235
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3233
3236
  * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3234
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3237
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3235
3238
  *
3236
3239
  *
3237
3240
  */
@@ -3240,10 +3243,11 @@ class Playwright extends Helper {
3240
3243
  locator = new Locator(locator, 'css');
3241
3244
 
3242
3245
  const context = await this._getContext();
3243
- const waiter = context.waitForSelector(buildLocatorString(locator), { timeout: waitTimeout, state: 'attached' });
3244
- return waiter.catch((err) => {
3245
- throw new Error(`element (${locator.toString()}) still not present on page after ${waitTimeout / 1000} sec\n${err.message}`);
3246
- });
3246
+ try {
3247
+ await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'attached' });
3248
+ } catch (e) {
3249
+ throw new Error(`element (${locator.toString()}) still not present on page after ${waitTimeout / 1000} sec\n${e.message}`);
3250
+ }
3247
3251
  }
3248
3252
 
3249
3253
  /**
@@ -3256,7 +3260,7 @@ class Playwright extends Helper {
3256
3260
  *
3257
3261
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3258
3262
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3259
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3263
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3260
3264
  *
3261
3265
  *
3262
3266
  * This method accepts [React selectors](https://codecept.io/react).
@@ -3265,10 +3269,26 @@ class Playwright extends Helper {
3265
3269
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
3266
3270
  locator = new Locator(locator, 'css');
3267
3271
  const context = await this._getContext();
3268
- const waiter = context.waitForSelector(buildLocatorString(locator), { timeout: waitTimeout, state: 'visible' });
3269
- return waiter.catch((err) => {
3270
- throw new Error(`element (${locator.toString()}) still not visible after ${waitTimeout / 1000} sec\n${err.message}`);
3271
- });
3272
+ let count = 0;
3273
+
3274
+ // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
3275
+ let waiter;
3276
+ if (this.frame) {
3277
+ do {
3278
+ waiter = await this.frame.locator(buildLocatorString(locator)).first().isVisible();
3279
+ await this.wait(1);
3280
+ count += 1000;
3281
+ if (waiter) break;
3282
+ } while (count <= waitTimeout);
3283
+
3284
+ if (!waiter) throw new Error(`element (${locator.toString()}) still not visible after ${waitTimeout / 1000} sec.`);
3285
+ }
3286
+
3287
+ try {
3288
+ await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'visible' });
3289
+ } catch (e) {
3290
+ throw new Error(`element (${locator.toString()}) still not visible after ${waitTimeout / 1000} sec\n${e.message}`);
3291
+ }
3272
3292
  }
3273
3293
 
3274
3294
  /**
@@ -3281,17 +3301,34 @@ class Playwright extends Helper {
3281
3301
  *
3282
3302
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3283
3303
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3284
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3304
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3285
3305
  *
3286
3306
  */
3287
3307
  async waitForInvisible(locator, sec) {
3288
3308
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
3289
3309
  locator = new Locator(locator, 'css');
3290
3310
  const context = await this._getContext();
3291
- const waiter = context.waitForSelector(buildLocatorString(locator), { timeout: waitTimeout, state: 'hidden' });
3292
- return waiter.catch((err) => {
3293
- throw new Error(`element (${locator.toString()}) still visible after ${waitTimeout / 1000} sec\n${err.message}`);
3294
- });
3311
+ let waiter;
3312
+ let count = 0;
3313
+
3314
+ // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
3315
+ if (this.frame) {
3316
+ do {
3317
+ waiter = await this.frame.locator(buildLocatorString(locator)).first().isHidden();
3318
+ await this.wait(1);
3319
+ count += 1000;
3320
+ if (waiter) break;
3321
+ } while (count <= waitTimeout);
3322
+
3323
+ if (!waiter) throw new Error(`element (${locator.toString()}) still visible after ${waitTimeout / 1000} sec.`);
3324
+ return;
3325
+ }
3326
+
3327
+ try {
3328
+ await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'hidden' });
3329
+ } catch (e) {
3330
+ throw new Error(`element (${locator.toString()}) still visible after ${waitTimeout / 1000} sec\n${e.message}`);
3331
+ }
3295
3332
  }
3296
3333
 
3297
3334
  /**
@@ -3304,14 +3341,30 @@ class Playwright extends Helper {
3304
3341
  *
3305
3342
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3306
3343
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3307
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3344
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3308
3345
  *
3309
3346
  */
3310
3347
  async waitToHide(locator, sec) {
3311
3348
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
3312
3349
  locator = new Locator(locator, 'css');
3313
3350
  const context = await this._getContext();
3314
- return context.waitForSelector(buildLocatorString(locator), { timeout: waitTimeout, state: 'hidden' }).catch((err) => {
3351
+ let waiter;
3352
+ let count = 0;
3353
+
3354
+ // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
3355
+ if (this.frame) {
3356
+ do {
3357
+ waiter = await this.frame.locator(buildLocatorString(locator)).first().isHidden();
3358
+ await this.wait(1);
3359
+ count += 1000;
3360
+ if (waiter) break;
3361
+ } while (count <= waitTimeout);
3362
+
3363
+ if (!waiter) throw new Error(`element (${locator.toString()}) still not hidden after ${waitTimeout / 1000} sec.`);
3364
+ return;
3365
+ }
3366
+
3367
+ return context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'hidden' }).catch((err) => {
3315
3368
  throw new Error(`element (${locator.toString()}) still not hidden after ${waitTimeout / 1000} sec\n${err.message}`);
3316
3369
  });
3317
3370
  }
@@ -3332,7 +3385,7 @@ class Playwright extends Helper {
3332
3385
  *
3333
3386
  * @param {string} urlPart value to check.
3334
3387
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3335
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3388
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3336
3389
  *
3337
3390
  */
3338
3391
  async waitInUrl(urlPart, sec = null) {
@@ -3361,7 +3414,7 @@ class Playwright extends Helper {
3361
3414
  *
3362
3415
  * @param {string} urlPart value to check.
3363
3416
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3364
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3417
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3365
3418
  *
3366
3419
  */
3367
3420
  async waitUrlEquals(urlPart, sec = null) {
@@ -3398,7 +3451,7 @@ class Playwright extends Helper {
3398
3451
  * @param {string }text to wait for.
3399
3452
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3400
3453
  * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
3401
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3454
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3402
3455
  *
3403
3456
  */
3404
3457
  async waitForText(text, sec = null, context = null) {
@@ -3410,7 +3463,12 @@ class Playwright extends Helper {
3410
3463
  if (context) {
3411
3464
  const locator = new Locator(context, 'css');
3412
3465
  if (!locator.isXPath()) {
3413
- waiter = contextObject.waitForSelector(`${locator.isCustom() ? `${locator.type}=${locator.value}` : locator.simplify()} >> text=${text}`, { timeout: waitTimeout, state: 'visible' });
3466
+ try {
3467
+ await contextObject.locator(`${locator.isCustom() ? `${locator.type}=${locator.value}` : locator.simplify()} >> text=${text}`).first().waitFor({ timeout: waitTimeout, state: 'visible' });
3468
+ } catch (e) {
3469
+ console.log(e);
3470
+ throw new Error(`Text "${text}" was not found on page after ${waitTimeout / 1000} sec\n${e.message}`);
3471
+ }
3414
3472
  }
3415
3473
 
3416
3474
  if (locator.isXPath()) {
@@ -3423,18 +3481,17 @@ class Playwright extends Helper {
3423
3481
  }
3424
3482
  } else {
3425
3483
  // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
3426
- if (this.frame) {
3427
- const { setTimeout } = require('timers/promises');
3428
- await setTimeout(waitTimeout);
3429
- waiter = await this.frame.locator(`:has-text('${text}')`).first().isVisible();
3430
- if (!waiter) throw new Error(`Text "${text}" was not found on page after ${waitTimeout / 1000} sec`);
3431
- return;
3432
- }
3433
- waiter = contextObject.waitForFunction(text => document.body && document.body.innerText.indexOf(text) > -1, text, { timeout: waitTimeout });
3484
+ // eslint-disable-next-line no-lonely-if
3485
+ const _contextObject = this.frame ? this.frame : contextObject;
3486
+ let count = 0;
3487
+ do {
3488
+ waiter = await _contextObject.locator(`:has-text('${text}')`).first().isVisible();
3489
+ await this.wait(1);
3490
+ count += 1000;
3491
+ } while (count <= waitTimeout);
3492
+
3493
+ if (!waiter) throw new Error(`Text "${text}" was not found on page after ${waitTimeout / 1000} sec`);
3434
3494
  }
3435
- return waiter.catch((err) => {
3436
- throw new Error(`Text "${text}" was not found on page after ${waitTimeout / 1000} sec\n${err.message}`);
3437
- });
3438
3495
  }
3439
3496
 
3440
3497
  /**
@@ -3478,7 +3535,7 @@ class Playwright extends Helper {
3478
3535
  * ```
3479
3536
  *
3480
3537
  * @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
3481
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3538
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3482
3539
  *
3483
3540
  */
3484
3541
  async switchTo(locator) {
@@ -3550,7 +3607,7 @@ class Playwright extends Helper {
3550
3607
  * @param {string|function} fn to be executed in browser context.
3551
3608
  * @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
3552
3609
  * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3553
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3610
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3554
3611
  *
3555
3612
  */
3556
3613
  async waitForFunction(fn, argsOrSec = null, sec = null) {
@@ -3619,7 +3676,7 @@ class Playwright extends Helper {
3619
3676
  *
3620
3677
  * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3621
3678
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3622
- * ⚠️ returns a _promise_ which is synchronized internally by recorder
3679
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3623
3680
  *
3624
3681
  */
3625
3682
  async waitForDetached(locator, sec) {
@@ -3629,17 +3686,21 @@ class Playwright extends Helper {
3629
3686
  let waiter;
3630
3687
  const context = await this._getContext();
3631
3688
  if (!locator.isXPath()) {
3632
- waiter = context.waitForSelector(`${locator.isCustom() ? `${locator.type}=${locator.value}` : locator.simplify()}`, { timeout: waitTimeout, state: 'detached' });
3689
+ try {
3690
+ await context.locator(`${locator.isCustom() ? `${locator.type}=${locator.value}` : locator.simplify()}`).first().waitFor({ timeout: waitTimeout, state: 'detached' });
3691
+ } catch (e) {
3692
+ throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${e.message}`);
3693
+ }
3633
3694
  } else {
3634
3695
  const visibleFn = function ([locator, $XPath]) {
3635
3696
  eval($XPath); // eslint-disable-line no-eval
3636
3697
  return $XPath(null, locator).length === 0;
3637
3698
  };
3638
3699
  waiter = context.waitForFunction(visibleFn, [locator.value, $XPath.toString()], { timeout: waitTimeout });
3700
+ return waiter.catch((err) => {
3701
+ throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`);
3702
+ });
3639
3703
  }
3640
- return waiter.catch((err) => {
3641
- throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`);
3642
- });
3643
3704
  }
3644
3705
 
3645
3706
  async _waitForAction() {
@@ -3666,7 +3727,8 @@ class Playwright extends Helper {
3666
3727
  * loadEventEnd: 241
3667
3728
  * }
3668
3729
  * ```
3669
- * @return {Promise<any>} automatically synchronized promise through #recorder
3730
+ * @returns {Promise<void>} automatically synchronized promise through #recorder
3731
+ *
3670
3732
  */
3671
3733
  async grabDataFromPerformanceTiming() {
3672
3734
  return perfTiming;
@@ -4366,7 +4428,8 @@ async function proceedSee(assertType, text, context, strict = false) {
4366
4428
  if (!context) {
4367
4429
  const el = await this.context;
4368
4430
 
4369
- allText = [await el.locator('body').innerText()];
4431
+ allText = el.constructor.name ? [await el.locator('body').innerText()] : [await el.innerText()];
4432
+
4370
4433
  description = 'web application';
4371
4434
  } else {
4372
4435
  const locator = new Locator(context, 'css');