codeceptjs 2.1.3 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +125 -37
  2. package/README.md +15 -22
  3. package/bin/codecept.js +4 -1
  4. package/docs/acceptance.md +44 -1
  5. package/docs/advanced.md +1 -1
  6. package/docs/angular.md +6 -9
  7. package/docs/basics.md +388 -75
  8. package/docs/bdd.md +4 -3
  9. package/docs/best.md +1 -1
  10. package/docs/books.md +31 -0
  11. package/docs/build/Appium.js +215 -176
  12. package/docs/build/Nightmare.js +618 -489
  13. package/docs/build/Polly.js +189 -0
  14. package/docs/build/Protractor.js +747 -608
  15. package/docs/build/Puppeteer.js +914 -633
  16. package/docs/build/REST.js +1 -1
  17. package/docs/build/TestCafe.js +1835 -0
  18. package/docs/build/WebDriver.js +861 -805
  19. package/docs/build/WebDriverIO.js +616 -617
  20. package/docs/changelog.md +410 -316
  21. package/docs/commands.md +6 -6
  22. package/docs/community-helpers.md +2 -0
  23. package/docs/detox.md +235 -0
  24. package/docs/examples.md +23 -0
  25. package/docs/helpers/ApiDataFactory.md +11 -10
  26. package/docs/helpers/Appium.md +130 -61
  27. package/docs/helpers/Detox.md +579 -0
  28. package/docs/helpers/FileSystem.md +2 -1
  29. package/docs/helpers/Mochawesome.md +1 -0
  30. package/docs/helpers/Nightmare.md +348 -128
  31. package/docs/helpers/Polly.md +85 -0
  32. package/docs/helpers/Protractor.md +451 -184
  33. package/docs/helpers/Puppeteer-firefox.md +55 -0
  34. package/docs/helpers/Puppeteer.md +619 -183
  35. package/docs/helpers/REST.md +17 -16
  36. package/docs/helpers/SeleniumWebdriver.md +9 -8
  37. package/docs/helpers/TestCafe.md +1168 -0
  38. package/docs/helpers/WebDriver.md +600 -291
  39. package/docs/helpers/WebDriverIO.md +393 -278
  40. package/docs/helpers.md +37 -18
  41. package/docs/locators.md +2 -0
  42. package/docs/mobile-react-native-locators.md +64 -0
  43. package/docs/mobile.md +5 -0
  44. package/docs/plugins.md +54 -13
  45. package/docs/puppeteer.md +74 -26
  46. package/docs/quickstart.md +47 -12
  47. package/docs/react.md +67 -0
  48. package/docs/reports.md +1 -1
  49. package/docs/{webapi/_keys.mustache → shared/keys.mustache} +0 -0
  50. package/docs/shared/react.mustache +1 -0
  51. package/docs/testcafe.md +157 -0
  52. package/docs/videos.md +19 -0
  53. package/docs/webapi/amOnPage.mustache +1 -1
  54. package/docs/webapi/appendField.mustache +2 -2
  55. package/docs/webapi/attachFile.mustache +2 -2
  56. package/docs/webapi/checkOption.mustache +2 -2
  57. package/docs/webapi/clearCookie.mustache +1 -1
  58. package/docs/webapi/clearField.mustache +1 -1
  59. package/docs/webapi/click.mustache +2 -2
  60. package/docs/webapi/clickLink.mustache +3 -3
  61. package/docs/webapi/dontSee.mustache +6 -3
  62. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +7 -1
  63. package/docs/webapi/dontSeeCookie.mustache +5 -1
  64. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +6 -1
  65. package/docs/webapi/dontSeeElement.mustache +5 -1
  66. package/docs/webapi/dontSeeElementInDOM.mustache +5 -1
  67. package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
  68. package/docs/webapi/dontSeeInField.mustache +7 -2
  69. package/docs/webapi/dontSeeInSource.mustache +5 -1
  70. package/docs/webapi/dontSeeInTitle.mustache +5 -1
  71. package/docs/webapi/doubleClick.mustache +2 -2
  72. package/docs/webapi/downloadFile.mustache +2 -2
  73. package/docs/webapi/dragAndDrop.mustache +2 -2
  74. package/docs/webapi/dragSlider.mustache +2 -2
  75. package/docs/webapi/executeAsyncScript.mustache +1 -1
  76. package/docs/webapi/executeScript.mustache +1 -1
  77. package/docs/webapi/fillField.mustache +2 -2
  78. package/docs/webapi/grabAttributeFrom.mustache +3 -2
  79. package/docs/webapi/grabBrowserLogs.mustache +3 -1
  80. package/docs/webapi/grabCookie.mustache +2 -1
  81. package/docs/webapi/grabCssPropertyFrom.mustache +3 -2
  82. package/docs/webapi/grabCurrentUrl.mustache +3 -1
  83. package/docs/webapi/grabDataFromPerformanceTiming.mustache +19 -0
  84. package/docs/webapi/grabHTMLFrom.mustache +2 -1
  85. package/docs/webapi/grabNumberOfOpenTabs.mustache +4 -2
  86. package/docs/webapi/grabNumberOfVisibleElements.mustache +3 -2
  87. package/docs/webapi/grabPageScrollPosition.mustache +3 -1
  88. package/docs/webapi/grabSource.mustache +3 -1
  89. package/docs/webapi/grabTextFrom.mustache +2 -1
  90. package/docs/webapi/grabTitle.mustache +3 -1
  91. package/docs/webapi/grabValueFrom.mustache +2 -1
  92. package/docs/webapi/moveCursorTo.mustache +3 -3
  93. package/docs/webapi/pressKey.mustache +1 -1
  94. package/docs/webapi/resizeWindow.mustache +2 -2
  95. package/docs/webapi/rightClick.mustache +2 -2
  96. package/docs/webapi/saveScreenshot.mustache +3 -3
  97. package/docs/webapi/say.mustache +2 -2
  98. package/docs/webapi/scrollPageToBottom.mustache +1 -1
  99. package/docs/webapi/scrollPageToTop.mustache +1 -1
  100. package/docs/webapi/scrollTo.mustache +3 -3
  101. package/docs/webapi/see.mustache +2 -2
  102. package/docs/webapi/seeAttributesOnElements.mustache +3 -3
  103. package/docs/webapi/seeCheckboxIsChecked.mustache +2 -1
  104. package/docs/webapi/seeCookie.mustache +1 -1
  105. package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -2
  106. package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
  107. package/docs/webapi/seeElement.mustache +1 -1
  108. package/docs/webapi/seeElementInDOM.mustache +1 -1
  109. package/docs/webapi/seeInCurrentUrl.mustache +1 -1
  110. package/docs/webapi/seeInField.mustache +2 -2
  111. package/docs/webapi/seeInSource.mustache +1 -1
  112. package/docs/webapi/seeInTitle.mustache +5 -1
  113. package/docs/webapi/seeNumberOfElements.mustache +10 -0
  114. package/docs/webapi/seeNumberOfVisibleElements.mustache +2 -2
  115. package/docs/webapi/selectOption.mustache +2 -2
  116. package/docs/webapi/setCookie.mustache +1 -1
  117. package/docs/webapi/switchTo.mustache +6 -1
  118. package/docs/webapi/uncheckOption.mustache +2 -2
  119. package/docs/webapi/wait.mustache +1 -2
  120. package/docs/webapi/waitForDetached.mustache +3 -3
  121. package/docs/webapi/waitForElement.mustache +2 -2
  122. package/docs/webapi/waitForEnabled.mustache +1 -1
  123. package/docs/webapi/waitForFunction.mustache +3 -3
  124. package/docs/webapi/waitForInvisible.mustache +3 -3
  125. package/docs/webapi/waitForText.mustache +3 -3
  126. package/docs/webapi/waitForValue.mustache +3 -3
  127. package/docs/webapi/waitForVisible.mustache +3 -3
  128. package/docs/webapi/waitInUrl.mustache +2 -2
  129. package/docs/webapi/waitNumberOfVisibleElements.mustache +3 -3
  130. package/docs/webapi/waitToHide.mustache +3 -3
  131. package/docs/webapi/waitUntil.mustache +3 -3
  132. package/docs/webapi/waitUrlEquals.mustache +2 -2
  133. package/docs/webdriver.md +453 -0
  134. package/lib/codecept.js +11 -9
  135. package/lib/command/definitions.js +183 -30
  136. package/lib/command/gherkin/snippets.js +29 -9
  137. package/lib/command/init.js +31 -9
  138. package/lib/command/run-multiple.js +46 -59
  139. package/lib/command/utils.js +1 -1
  140. package/lib/container.js +30 -4
  141. package/lib/data/dataScenarioConfig.js +18 -0
  142. package/lib/helper/Appium.js +24 -24
  143. package/lib/helper/Nightmare.js +81 -84
  144. package/lib/helper/Polly.js +189 -0
  145. package/lib/helper/Protractor.js +96 -86
  146. package/lib/helper/Puppeteer.js +238 -113
  147. package/lib/helper/REST.js +1 -1
  148. package/lib/helper/TestCafe.js +1257 -0
  149. package/lib/helper/WebDriver.js +217 -277
  150. package/lib/helper/WebDriverIO.js +75 -75
  151. package/lib/helper/clientscripts/nightmare.js +8 -0
  152. package/lib/helper/extras/React.js +55 -0
  153. package/lib/helper/testcafe/testControllerHolder.js +42 -0
  154. package/lib/helper/testcafe/testcafe-utils.js +63 -0
  155. package/lib/history.js +39 -0
  156. package/lib/hooks.js +25 -1
  157. package/lib/interfaces/gherkin.js +17 -1
  158. package/lib/interfaces/scenarioConfig.js +2 -2
  159. package/lib/listener/config.js +3 -3
  160. package/lib/locator.js +6 -0
  161. package/lib/pause.js +22 -1
  162. package/lib/plugin/allure.js +63 -0
  163. package/lib/plugin/autoLogin.js +65 -16
  164. package/lib/plugin/puppeteerCoverage.js +6 -1
  165. package/lib/plugin/stepByStepReport.js +4 -3
  166. package/lib/scenario.js +23 -17
  167. package/lib/step.js +5 -2
  168. package/lib/ui.js +1 -1
  169. package/lib/utils.js +70 -20
  170. package/package.json +20 -19
  171. package/translations/de-DE.js +69 -0
  172. package/translations/index.js +1 -0
  173. package/docs/video.md +0 -26
@@ -15,7 +15,6 @@ const {
15
15
  chunkArray,
16
16
  convertCssPropertiesToCamelCase,
17
17
  screenshotOutputFolder,
18
- fileToBase64Zip,
19
18
  } = require('../utils');
20
19
  const {
21
20
  isColorProperty,
@@ -61,15 +60,15 @@ const webRoot = 'body';
61
60
  *
62
61
  * Example:
63
62
  *
64
- * ```json
63
+ * ```js
65
64
  * {
66
- * "helpers": {
67
- * "WebDriver" : {
68
- * "smartWait": 5000,
69
- * "browser": "chrome",
70
- * "restart": false,
71
- * "windowSize": "maximize",
72
- * "timeouts": {
65
+ * helpers: {
66
+ * WebDriver : {
67
+ * smartWait: 5000,
68
+ * browser: "chrome",
69
+ * restart: false,
70
+ * windowSize: "maximize",
71
+ * timeouts: {
73
72
  * "script": 60000,
74
73
  * "page load": 10000
75
74
  * }
@@ -83,15 +82,15 @@ const webRoot = 'body';
83
82
  *
84
83
  * ### Headless Chrome
85
84
  *
86
- * ```json
85
+ * ```js
87
86
  * {
88
- * "helpers": {
89
- * "WebDriver" : {
90
- * "url": "http://localhost",
91
- * "browser": "chrome",
92
- * "desiredCapabilities": {
93
- * "chromeOptions": {
94
- * "args": [ "--headless", "--disable-gpu", "--window-size=800,600" ]
87
+ * helpers: {
88
+ * WebDriver : {
89
+ * url: "http://localhost",
90
+ * browser: "chrome",
91
+ * desiredCapabilities: {
92
+ * chromeOptions: {
93
+ * args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
95
94
  * }
96
95
  * }
97
96
  * }
@@ -103,14 +102,14 @@ const webRoot = 'body';
103
102
  *
104
103
  * Additional configuration params can be used from [IE options](https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/IE/Options.html)
105
104
  *
106
- * ```json
105
+ * ```js
107
106
  * {
108
- * "helpers": {
109
- * "WebDriver" : {
110
- * "url": "http://localhost",
111
- * "browser": "internet explorer",
112
- * "desiredCapabilities": {
113
- * "ieOptions": {
107
+ * helpers: {
108
+ * WebDriver : {
109
+ * url: "http://localhost",
110
+ * browser: "internet explorer",
111
+ * desiredCapabilities: {
112
+ * ieOptions: {
114
113
  * "ie.browserCommandLineSwitches": "-private",
115
114
  * "ie.usePerProcessProxy": true,
116
115
  * "ie.ensureCleanSession": true,
@@ -123,15 +122,18 @@ const webRoot = 'body';
123
122
  *
124
123
  * ### Selenoid Options
125
124
  *
126
- * ```json
125
+ * [Selenoid](https://aerokube.com/selenoid/latest/) is a modern way to run Selenium inside Docker containers.
126
+ * Selenoid is easy to set up and provides more features than original Selenium Server. Use `selenoidOptions` to set Selenoid capabilities
127
+ *
128
+ * ```js
127
129
  * {
128
- * "helpers": {
129
- * "WebDriver" : {
130
- * "url": "http://localhost",
131
- * "browser": "chrome",
132
- * "desiredCapabilities": {
133
- * "selenoidOptions": {
134
- * "enableVNC": true,
130
+ * helpers: {
131
+ * WebDriver : {
132
+ * url: "http://localhost",
133
+ * browser: "chrome",
134
+ * desiredCapabilities: {
135
+ * selenoidOptions: {
136
+ * enableVNC: true,
135
137
  * }
136
138
  * }
137
139
  * }
@@ -139,17 +141,17 @@ const webRoot = 'body';
139
141
  * }
140
142
  * ```
141
143
  *
142
- * ### Connect through proxy
144
+ * ### Connect Through proxy
143
145
  *
144
146
  * CodeceptJS also provides flexible options when you want to execute tests to Selenium servers through proxy. You will
145
147
  * need to update the `helpers.WebDriver.capabilities.proxy` key.
146
148
  *
147
149
  * ```js
148
150
  * {
149
- * "helpers": {
150
- * "WebDriver": {
151
- * "capabilities": {
152
- * "proxy": {
151
+ * helpers: {
152
+ * WebDriver: {
153
+ * capabilities: {
154
+ * proxy: {
153
155
  * "proxyType": "manual|pac",
154
156
  * "proxyAutoconfigUrl": "URL TO PAC FILE",
155
157
  * "httpProxy": "PROXY SERVER",
@@ -169,10 +171,10 @@ const webRoot = 'body';
169
171
  *
170
172
  * ```js
171
173
  * {
172
- * "helpers": {
173
- * "WebDriver": {
174
- * "capabilities": {
175
- * "proxy": {
174
+ * helpers: {
175
+ * WebDriver: {
176
+ * capabilities: {
177
+ * proxy: {
176
178
  * "proxyType": "manual",
177
179
  * "httpProxy": "http://corporate.proxy:8080",
178
180
  * "socksUsername": "codeceptjs",
@@ -199,12 +201,12 @@ const webRoot = 'body';
199
201
  *
200
202
  * ```js
201
203
  * {
202
- * "helpers":{
203
- * "WebDriver": {
204
- * "url": "YOUR_DESIRED_HOST",
205
- * "user": "YOUR_BROWSERSTACK_USER",
206
- * "key": "YOUR_BROWSERSTACK_KEY",
207
- * "capabilities": {
204
+ * helpers:{
205
+ * WebDriver: {
206
+ * url: "YOUR_DESIRED_HOST",
207
+ * user: "YOUR_BROWSERSTACK_USER",
208
+ * key: "YOUR_BROWSERSTACK_KEY",
209
+ * capabilities: {
208
210
  * "browserName": "chrome",
209
211
  *
210
212
  * // only set this if you're using BrowserStackLocal to test a local domain
@@ -318,8 +320,8 @@ const webRoot = 'body';
318
320
  *
319
321
  * ```js
320
322
  * {
321
- * "helpers": {
322
- * "WebDriver": {
323
+ * helpers: {
324
+ * WebDriver: {
323
325
  * "multiremote": {
324
326
  * "MyChrome": {
325
327
  * "desiredCapabilities": {
@@ -490,12 +492,8 @@ class WebDriver extends Helper {
490
492
  await this.defineTimeout(this.options.timeouts);
491
493
  }
492
494
 
493
- if (this.isWeb && this.options.windowSize === 'maximize') {
494
- await this.resizeWindow('maximize');
495
- } else if (this.isWeb && this.options.windowSize && this.options.windowSize.indexOf('x') > 0) {
496
- const dimensions = this.options.windowSize.split('x');
497
- await this.resizeWindow(dimensions[0], dimensions[1]);
498
- }
495
+ await this._resizeWindowIfNeeded(this.browser, this.options.windowSize);
496
+
499
497
  this.$$ = this.browser.$$.bind(this.browser);
500
498
  return this.browser;
501
499
  }
@@ -547,7 +545,15 @@ class WebDriver extends Helper {
547
545
  // opts.disableScreenshots = true; // screenshots cant be saved as session will be already closed
548
546
  opts = this._validateConfig(Object.assign(this.options, opts));
549
547
  this.debugSection('New Browser', JSON.stringify(opts));
550
- return webdriverio.remote(opts);
548
+ const browser = await webdriverio.remote(opts);
549
+
550
+ if (opts.timeouts && this.isWeb) {
551
+ await this._defineBrowserTimeout(browser, opts.timeouts);
552
+ }
553
+
554
+ await this._resizeWindowIfNeeded(browser, opts.windowSize);
555
+
556
+ return browser;
551
557
  },
552
558
  stop: async (browser) => {
553
559
  return browser.deleteSession();
@@ -673,8 +679,6 @@ class WebDriver extends Helper {
673
679
  /**
674
680
  * Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
675
681
  *
676
- *
677
- * * *Appium*: supported only for web testing.
678
682
  * Timeouts are expected to be passed as object:
679
683
  *
680
684
  * ```js
@@ -685,23 +689,26 @@ class WebDriver extends Helper {
685
689
  * @param timeouts WebDriver timeouts object.
686
690
  */
687
691
  defineTimeout(timeouts) {
688
- return this.browser.setTimeout(timeouts);
692
+ return this._defineBrowserTimeout(this.browser, timeouts);
693
+ }
694
+
695
+ _defineBrowserTimeout(browser, timeouts) {
696
+ return browser.setTimeout(timeouts);
689
697
  }
690
698
 
691
699
  /**
692
700
  * Opens a web page in a browser. Requires relative or absolute url.
693
- If url starts with `/`, opens a web page of a site defined in `url` config parameter.
694
-
695
- ```js
696
- I.amOnPage('/'); // opens main page of website
697
- I.amOnPage('https://github.com'); // opens github
698
- I.amOnPage('/login'); // opens a login page
699
- ```
700
-
701
- @param url url path or global url.
702
- *
701
+ * If url starts with `/`, opens a web page of a site defined in `url` config parameter.
702
+ *
703
+ * ```js
704
+ * I.amOnPage('/'); // opens main page of website
705
+ * I.amOnPage('https://github.com'); // opens github
706
+ * I.amOnPage('/login'); // opens a login page
707
+ * ```
708
+ *
709
+ * @param {string} url url path or global url.
710
+ * {--end--}
703
711
  *
704
- * * *Appium*: supported only for web testing
705
712
  */
706
713
  amOnPage(url) {
707
714
  return this.browser.url(url);
@@ -709,32 +716,32 @@ I.amOnPage('/login'); // opens a login page
709
716
 
710
717
  /**
711
718
  * Perform a click on a link or a button, given by a locator.
712
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
713
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
714
- For images, the "alt" attribute and inner text of any parent links are searched.
715
-
716
- The second parameter is a context (CSS or XPath locator) to narrow the search.
717
-
718
- ```js
719
- // simple link
720
- I.click('Logout');
721
- // button of form
722
- I.click('Submit');
723
- // CSS button
724
- I.click('#form input[type=submit]');
725
- // XPath
726
- I.click('//form/*[@type=submit]');
727
- // link in context
728
- I.click('Logout', '#nav');
729
- // using strict locator
730
- I.click({css: 'nav a.login'});
731
- ```
732
-
733
- @param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
734
- @param context (optional) element to search in CSS|XPath|Strict locator.
735
- *
719
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
720
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
721
+ * For images, the "alt" attribute and inner text of any parent links are searched.
722
+ *
723
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
724
+ *
725
+ * ```js
726
+ * // simple link
727
+ * I.click('Logout');
728
+ * // button of form
729
+ * I.click('Submit');
730
+ * // CSS button
731
+ * I.click('#form input[type=submit]');
732
+ * // XPath
733
+ * I.click('//form/*[@type=submit]');
734
+ * // link in context
735
+ * I.click('Logout', '#nav');
736
+ * // using strict locator
737
+ * I.click({css: 'nav a.login'});
738
+ * ```
739
+ *
740
+ * @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
741
+ * @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
742
+ * {--end--}
736
743
  *
737
- * * *Appium*: supported
744
+ * {{ react }}
738
745
  */
739
746
  async click(locator, context = null) {
740
747
  const clickMethod = this.browser.isMobile ? 'touchClick' : 'elementClick';
@@ -752,20 +759,20 @@ I.click({css: 'nav a.login'});
752
759
 
753
760
  /**
754
761
  * Performs a double-click on an element matched by link|button|label|CSS or XPath.
755
- Context can be specified as second parameter to narrow search.
756
-
757
- ```js
758
- I.doubleClick('Edit');
759
- I.doubleClick('Edit', '.actions');
760
- I.doubleClick({css: 'button.accept'});
761
- I.doubleClick('.btn.edit');
762
- ```
763
-
764
- @param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
765
- @param context (optional) element to search in CSS|XPath|Strict locator.
766
- *
762
+ * Context can be specified as second parameter to narrow search.
763
+ *
764
+ * ```js
765
+ * I.doubleClick('Edit');
766
+ * I.doubleClick('Edit', '.actions');
767
+ * I.doubleClick({css: 'button.accept'});
768
+ * I.doubleClick('.btn.edit');
769
+ * ```
770
+ *
771
+ * @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
772
+ * @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
773
+ * {--end--}
767
774
  *
768
- * * *Appium*: supported only for web testing
775
+ * {{ react }}
769
776
  */
770
777
  async doubleClick(locator, context = null) {
771
778
  const locateFn = prepareLocateFn.call(this, context);
@@ -783,22 +790,21 @@ I.doubleClick('.btn.edit');
783
790
 
784
791
  /**
785
792
  * Performs right click on a clickable element matched by semantic locator, CSS or XPath.
786
-
787
- ```js
788
- // right click element with id el
789
- I.rightClick('#el');
790
- // right click link or button with text "Click me"
791
- I.rightClick('Click me');
792
- // right click button with text "Click me" inside .context
793
- I.rightClick('Click me', '.context');
794
- ```
795
-
796
- @param locator clickable element located by CSS|XPath|strict locator.
797
- @param context (optional) element located by CSS|XPath|strict locator.
798
-
799
- *
793
+ *
794
+ * ```js
795
+ * // right click element with id el
796
+ * I.rightClick('#el');
797
+ * // right click link or button with text "Click me"
798
+ * I.rightClick('Click me');
799
+ * // right click button with text "Click me" inside .context
800
+ * I.rightClick('Click me', '.context');
801
+ * ```
802
+ *
803
+ * @param {string|object} locator clickable element located by CSS|XPath|strict locator.
804
+ * @param {string|object} context (optional, `null` by default) element located by CSS|XPath|strict locator.
805
+ * {--end--}
800
806
  *
801
- * * *Appium*: supported, but in apps works as usual click
807
+ * {{ react }}
802
808
  */
803
809
  async rightClick(locator, context) {
804
810
  const locateFn = prepareLocateFn.call(this, context);
@@ -826,24 +832,23 @@ I.rightClick('Click me', '.context');
826
832
 
827
833
  /**
828
834
  * Fills a text field or textarea, after clearing its value, with the given string.
829
- Field is located by name, label, CSS, or XPath.
830
-
831
- ```js
832
- // by label
833
- I.fillField('Email', 'hello@world.com');
834
- // by name
835
- I.fillField('password', secret('123456'));
836
- // by CSS
837
- I.fillField('form#login input[name=username]', 'John');
838
- // or by strict locator
839
- I.fillField({css: 'form#login input[name=username]'}, 'John');
840
- ```
841
- @param field located by label|name|CSS|XPath|strict locator.
842
- @param value text value to fill.
843
-
844
- *
835
+ * Field is located by name, label, CSS, or XPath.
836
+ *
837
+ * ```js
838
+ * // by label
839
+ * I.fillField('Email', 'hello@world.com');
840
+ * // by name
841
+ * I.fillField('password', secret('123456'));
842
+ * // by CSS
843
+ * I.fillField('form#login input[name=username]', 'John');
844
+ * // or by strict locator
845
+ * I.fillField({css: 'form#login input[name=username]'}, 'John');
846
+ * ```
847
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
848
+ * @param {string} value text value to fill.
849
+ * {--end--}
850
+ * {{ react }}
845
851
  *
846
- * * *Appium*: supported
847
852
  */
848
853
  async fillField(field, value) {
849
854
  const res = await findFields.call(this, field);
@@ -854,16 +859,15 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
854
859
 
855
860
  /**
856
861
  * Appends text to a input field or textarea.
857
- Field is located by name, label, CSS or XPath
858
-
859
- ```js
860
- I.appendField('#myTextField', 'appended');
861
- ```
862
- @param field located by label|name|CSS|XPath|strict locator
863
- @param value text value to append.
864
- *
865
- *
866
- * * *Appium*: supported, but it's clear a field before insert in apps
862
+ * Field is located by name, label, CSS or XPath
863
+ *
864
+ * ```js
865
+ * I.appendField('#myTextField', 'appended');
866
+ * ```
867
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator
868
+ * @param {string} value text value to append.
869
+ * {--end--}
870
+ * {{ react }}
867
871
  */
868
872
  async appendField(field, value) {
869
873
  const res = await findFields.call(this, field);
@@ -875,16 +879,15 @@ I.appendField('#myTextField', 'appended');
875
879
 
876
880
  /**
877
881
  * Clears a `<textarea>` or text `<input>` element's value.
878
-
879
- ```js
880
- I.clearField('Email');
881
- I.clearField('user[email]');
882
- I.clearField('#email');
883
- ```
884
- @param field located by label|name|CSS|XPath|strict locator.
885
- *
882
+ *
883
+ * ```js
884
+ * I.clearField('Email');
885
+ * I.clearField('user[email]');
886
+ * I.clearField('#email');
887
+ * ```
888
+ * @param {string|object} editable field located by label|name|CSS|XPath|strict locator.
889
+ * {--end--}
886
890
  *
887
- * * *Appium*: supported
888
891
  */
889
892
  async clearField(field) {
890
893
  const res = await findFields.call(this, field);
@@ -896,25 +899,26 @@ I.clearField('#email');
896
899
 
897
900
  /**
898
901
  * Selects an option in a drop-down select.
899
- Field is searched by label | name | CSS | XPath.
900
- Option is selected by visible text or by value.
901
-
902
- ```js
903
- I.selectOption('Choose Plan', 'Monthly'); // select by label
904
- I.selectOption('subscription', 'Monthly'); // match option by text
905
- I.selectOption('subscription', '0'); // or by value
906
- I.selectOption('//form/select[@name=account]','Premium');
907
- I.selectOption('form select[name=account]', 'Premium');
908
- I.selectOption({css: 'form select[name=account]'}, 'Premium');
909
- ```
910
-
911
- Provide an array for the second argument to select multiple options.
912
-
913
- ```js
914
- I.selectOption('Which OS do you use?', ['Android', 'iOS']);
915
- ```
916
- @param select field located by label|name|CSS|XPath|strict locator.
917
- @param option visible text or value of option.
902
+ * Field is searched by label | name | CSS | XPath.
903
+ * Option is selected by visible text or by value.
904
+ *
905
+ * ```js
906
+ * I.selectOption('Choose Plan', 'Monthly'); // select by label
907
+ * I.selectOption('subscription', 'Monthly'); // match option by text
908
+ * I.selectOption('subscription', '0'); // or by value
909
+ * I.selectOption('//form/select[@name=account]','Premium');
910
+ * I.selectOption('form select[name=account]', 'Premium');
911
+ * I.selectOption({css: 'form select[name=account]'}, 'Premium');
912
+ * ```
913
+ *
914
+ * Provide an array for the second argument to select multiple options.
915
+ *
916
+ * ```js
917
+ * I.selectOption('Which OS do you use?', ['Android', 'iOS']);
918
+ * ```
919
+ * @param {string|object} select field located by label|name|CSS|XPath|strict locator.
920
+ * @param {string|array} option visible text or value of option.
921
+ * {--end--}
918
922
  */
919
923
  async selectOption(select, option) {
920
924
  const res = await findFields.call(this, select);
@@ -947,16 +951,17 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
947
951
 
948
952
  /**
949
953
  * Attaches a file to element located by label, name, CSS or XPath
950
- Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
951
- File will be uploaded to remote system (if tests are running remotely).
952
-
953
- ```js
954
- I.attachFile('Avatar', 'data/avatar.jpg');
955
- I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
956
- ```
957
-
958
- @param locator field located by label|name|CSS|XPath|strict locator.
959
- @param pathToFile local file path relative to codecept.json config file.
954
+ * Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
955
+ * File will be uploaded to remote system (if tests are running remotely).
956
+ *
957
+ * ```js
958
+ * I.attachFile('Avatar', 'data/avatar.jpg');
959
+ * I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
960
+ * ```
961
+ *
962
+ * @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
963
+ * @param {string} pathToFile local file path relative to codecept.json config file.
964
+ * {--end--}
960
965
  * Appium: not tested
961
966
  */
962
967
  async attachFile(locator, pathToFile) {
@@ -970,12 +975,11 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
970
975
  assertElementExists(res, locator, 'File field');
971
976
  const el = usingFirstElement(res);
972
977
 
973
- // Remote Uplaod (when running Selenium Server)
978
+ // Remote Upload (when running Selenium Server)
974
979
  if (this.options.remoteFileUpload) {
975
- const fileCompressed = await fileToBase64Zip(file);
976
980
  try {
977
981
  this.debugSection('File', 'Uploading file to remote server');
978
- file = await this.browser.uploadFile(fileCompressed);
982
+ file = await this.browser.uploadFile(file);
979
983
  } catch (err) {
980
984
  throw new Error(`File can't be transferred to remote server. Set \`remoteFileUpload: false\` in config to upload file locally.\n${err.message}`);
981
985
  }
@@ -986,17 +990,18 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
986
990
 
987
991
  /**
988
992
  * Selects a checkbox or radio button.
989
- Element is located by label or name or CSS or XPath.
990
-
991
- The second parameter is a context (CSS or XPath locator) to narrow the search.
992
-
993
- ```js
994
- I.checkOption('#agree');
995
- I.checkOption('I Agree to Terms and Conditions');
996
- I.checkOption('agree', '//form');
997
- ```
998
- @param field checkbox located by label | name | CSS | XPath | strict locator.
999
- @param context (optional) element located by CSS | XPath | strict locator.
993
+ * Element is located by label or name or CSS or XPath.
994
+ *
995
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
996
+ *
997
+ * ```js
998
+ * I.checkOption('#agree');
999
+ * I.checkOption('I Agree to Terms and Conditions');
1000
+ * I.checkOption('agree', '//form');
1001
+ * ```
1002
+ * @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
1003
+ * @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
1004
+ * {--end--}
1000
1005
  * Appium: not tested
1001
1006
  */
1002
1007
  async checkOption(field, context = null) {
@@ -1010,23 +1015,24 @@ I.checkOption('agree', '//form');
1010
1015
  const elementId = getElementId(elem);
1011
1016
 
1012
1017
  const isSelected = await this.browser.isElementSelected(elementId);
1013
- if (isSelected.value) return Promise.resolve(true);
1018
+ if (isSelected) return Promise.resolve(true);
1014
1019
  return this.browser[clickMethod](elementId);
1015
1020
  }
1016
1021
 
1017
1022
  /**
1018
1023
  * Unselects a checkbox or radio button.
1019
- Element is located by label or name or CSS or XPath.
1020
-
1021
- The second parameter is a context (CSS or XPath locator) to narrow the search.
1022
-
1023
- ```js
1024
- I.uncheckOption('#agree');
1025
- I.uncheckOption('I Agree to Terms and Conditions');
1026
- I.uncheckOption('agree', '//form');
1027
- ```
1028
- @param field checkbox located by label | name | CSS | XPath | strict locator.
1029
- @param context (optional) element located by CSS | XPath | strict locator.
1024
+ * Element is located by label or name or CSS or XPath.
1025
+ *
1026
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
1027
+ *
1028
+ * ```js
1029
+ * I.uncheckOption('#agree');
1030
+ * I.uncheckOption('I Agree to Terms and Conditions');
1031
+ * I.uncheckOption('agree', '//form');
1032
+ * ```
1033
+ * @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
1034
+ * @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
1035
+ * {--end--}
1030
1036
  * Appium: not tested
1031
1037
  */
1032
1038
  async uncheckOption(field, context = null) {
@@ -1040,23 +1046,23 @@ I.uncheckOption('agree', '//form');
1040
1046
  const elementId = getElementId(elem);
1041
1047
 
1042
1048
  const isSelected = await this.browser.isElementSelected(elementId);
1043
- if (!isSelected.value) return Promise.resolve(true);
1049
+ if (!isSelected) return Promise.resolve(true);
1044
1050
  return this.browser[clickMethod](elementId);
1045
1051
  }
1046
1052
 
1047
1053
  /**
1048
1054
  * Retrieves a text from an element located by CSS or XPath and returns it to test.
1049
- Resumes test execution, so **should be used inside async with `await`** operator.
1050
-
1051
- ```js
1052
- let pin = await I.grabTextFrom('#pin');
1053
- ```
1054
- If multiple elements found returns an array of texts.
1055
-
1056
- @param locator element located by CSS|XPath|strict locator.
1057
- *
1055
+ * Resumes test execution, so **should be used inside async with `await`** operator.
1056
+ *
1057
+ * ```js
1058
+ * let pin = await I.grabTextFrom('#pin');
1059
+ * ```
1060
+ * If multiple elements found returns an array of texts.
1061
+ *
1062
+ * @param locator element located by CSS|XPath|strict locator.
1063
+ * @returns {Promise<string>} attribute value
1064
+ * {--end--}
1058
1065
  *
1059
- * * *Appium*: supported
1060
1066
  */
1061
1067
  async grabTextFrom(locator) {
1062
1068
  const res = await this._locate(locator, true);
@@ -1073,17 +1079,17 @@ If multiple elements found returns an array of texts.
1073
1079
 
1074
1080
  /**
1075
1081
  * Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
1076
- Resumes test execution, so **should be used inside async function with `await`** operator.
1077
- If more than one element is found - an array of HTMLs returned.
1078
-
1079
- ```js
1080
- let postHTML = await I.grabHTMLFrom('#post');
1081
- ```
1082
-
1083
- @param locator element located by CSS|XPath|strict locator.
1084
- *
1082
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
1083
+ * If more than one element is found - an array of HTMLs returned.
1084
+ *
1085
+ * ```js
1086
+ * let postHTML = await I.grabHTMLFrom('#post');
1087
+ * ```
1088
+ *
1089
+ * @param locator element located by CSS|XPath|strict locator.
1090
+ * @returns {Promise<string>} HTML code for an element
1091
+ * {--end--}
1085
1092
  *
1086
- * * *Appium*: supported only for web testing
1087
1093
  */
1088
1094
  async grabHTMLFrom(locator) {
1089
1095
  const elems = await this._locate(locator, true);
@@ -1098,15 +1104,15 @@ let postHTML = await I.grabHTMLFrom('#post');
1098
1104
 
1099
1105
  /**
1100
1106
  * Retrieves a value from a form element located by CSS or XPath and returns it to test.
1101
- Resumes test execution, so **should be used inside async function with `await`** operator.
1102
-
1103
- ```js
1104
- let email = await I.grabValueFrom('input[name=email]');
1105
- ```
1106
- @param locator field located by label|name|CSS|XPath|strict locator.
1107
- *
1107
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
1108
+ *
1109
+ * ```js
1110
+ * let email = await I.grabValueFrom('input[name=email]');
1111
+ * ```
1112
+ * @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
1113
+ * @returns {Promise<string>} attribute value
1114
+ * {--end--}
1108
1115
  *
1109
- * * *Appium*: supported only for web testing
1110
1116
  */
1111
1117
  async grabValueFrom(locator) {
1112
1118
  const res = await this._locate(locator, true);
@@ -1117,14 +1123,16 @@ let email = await I.grabValueFrom('input[name=email]');
1117
1123
 
1118
1124
  /**
1119
1125
  * Grab CSS property for given locator
1120
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1121
-
1122
- ```js
1123
- const value = await I.grabCssPropertyFrom('h3', 'font-weight');
1124
- ```
1125
-
1126
- @param locator element located by CSS|XPath|strict locator.
1127
- @param cssProperty CSS property name.
1126
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
1127
+ *
1128
+ * ```js
1129
+ * const value = await I.grabCssPropertyFrom('h3', 'font-weight');
1130
+ * ```
1131
+ *
1132
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1133
+ * @param {string} cssProperty CSS property name.
1134
+ * @returns {Promise<string>} CSS value
1135
+ * {--end--}
1128
1136
  */
1129
1137
  async grabCssPropertyFrom(locator, cssProperty) {
1130
1138
  const res = await this._locate(locator, true);
@@ -1134,14 +1142,16 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
1134
1142
 
1135
1143
  /**
1136
1144
  * Retrieves an attribute from an element located by CSS or XPath and returns it to test.
1137
- An array as a result will be returned if there are more than one matched element.
1138
- Resumes test execution, so **should be used inside async with `await`** operator.
1139
-
1140
- ```js
1141
- let hint = await I.grabAttributeFrom('#tooltip', 'title');
1142
- ```
1143
- @param locator element located by CSS|XPath|strict locator.
1144
- @param attr attribute name.
1145
+ * An array as a result will be returned if there are more than one matched element.
1146
+ * Resumes test execution, so **should be used inside async with `await`** operator.
1147
+ *
1148
+ * ```js
1149
+ * let hint = await I.grabAttributeFrom('#tooltip', 'title');
1150
+ * ```
1151
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1152
+ * @param {string} attr attribute name.
1153
+ * @returns {Promise<string>} attribute value
1154
+ * {--end--}
1145
1155
  * Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
1146
1156
  */
1147
1157
  async grabAttributeFrom(locator, attr) {
@@ -1152,11 +1162,14 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1152
1162
 
1153
1163
  /**
1154
1164
  * Checks that title contains text.
1155
-
1156
- @param text text value to check.
1157
- *
1165
+ *
1166
+ * ```js
1167
+ * I.seeInTitle('Home Page');
1168
+ * ```
1169
+ *
1170
+ * @param {string} text text value to check.
1171
+ * {--end--}
1158
1172
  *
1159
- * * *Appium*: supported only for web testing
1160
1173
  */
1161
1174
  async seeInTitle(text) {
1162
1175
  const title = await this.browser.getTitle();
@@ -1179,11 +1192,14 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1179
1192
 
1180
1193
  /**
1181
1194
  * Checks that title does not contain text.
1182
-
1183
- @param text text value to check.
1184
- *
1195
+ *
1196
+ * ```js
1197
+ * I.dontSeeInTitle('Error');
1198
+ * ```
1199
+ *
1200
+ * @param {string} text value to check.
1201
+ * {--end--}
1185
1202
  *
1186
- * * *Appium*: supported only for web testing
1187
1203
  */
1188
1204
  async dontSeeInTitle(text) {
1189
1205
  const title = await this.browser.getTitle();
@@ -1192,14 +1208,15 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1192
1208
 
1193
1209
  /**
1194
1210
  * Retrieves a page title and returns it to test.
1195
- Resumes test execution, so **should be used inside async with `await`** operator.
1196
-
1197
- ```js
1198
- let title = await I.grabTitle();
1199
- ```
1200
- *
1211
+ * Resumes test execution, so **should be used inside async with `await`** operator.
1212
+ *
1213
+ * ```js
1214
+ * let title = await I.grabTitle();
1215
+ * ```
1216
+ *
1217
+ * @returns {Promise<string>} title
1218
+ * {--end--}
1201
1219
  *
1202
- * * *Appium*: supported only for web testing
1203
1220
  */
1204
1221
  async grabTitle() {
1205
1222
  const title = await this.browser.getTitle();
@@ -1209,18 +1226,18 @@ let title = await I.grabTitle();
1209
1226
 
1210
1227
  /**
1211
1228
  * Checks that a page contains a visible text.
1212
- Use context parameter to narrow down the search.
1213
-
1214
- ```js
1215
- I.see('Welcome'); // text welcome on a page
1216
- I.see('Welcome', '.content'); // text inside .content div
1217
- I.see('Register', {css: 'form.register'}); // use strict locator
1218
- ```
1219
- @param text expected on page.
1220
- @param context (optional) element located by CSS|Xpath|strict locator in which to search for text.
1221
- *
1229
+ * Use context parameter to narrow down the search.
1230
+ *
1231
+ * ```js
1232
+ * I.see('Welcome'); // text welcome on a page
1233
+ * I.see('Welcome', '.content'); // text inside .content div
1234
+ * I.see('Register', {css: 'form.register'}); // use strict locator
1235
+ * ```
1236
+ * @param {string} text expected on page.
1237
+ * @param {string|object} context (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
1238
+ * {--end--}
1222
1239
  *
1223
- * * *Appium*: supported with context in apps
1240
+ * {{ react }}
1224
1241
  */
1225
1242
  async see(text, context = null) {
1226
1243
  return proceedSee.call(this, 'assert', text, context);
@@ -1242,16 +1259,19 @@ I.see('Register', {css: 'form.register'}); // use strict locator
1242
1259
 
1243
1260
  /**
1244
1261
  * Opposite to `see`. Checks that a text is not present on a page.
1245
- Use context parameter to narrow down the search.
1246
-
1247
- ```js
1248
- I.dontSee('Login'); // assume we are already logged in
1249
- ```
1250
- @param text is not present.
1251
- @param context (optional) element located by CSS|XPath|strict locator in which to perfrom search.
1262
+ * Use context parameter to narrow down the search.
1263
+ *
1264
+ * ```js
1265
+ * I.dontSee('Login'); // assume we are already logged in.
1266
+ * I.dontSee('Login', '.nav'); // no login inside .nav element
1267
+ * ```
1268
+ *
1269
+ * @param {string} text which is not present.
1270
+ * @param {string|object} context (optional) element located by CSS|XPath|strict locator in which to perfrom search.
1252
1271
  *
1272
+ * {--end--}
1253
1273
  *
1254
- * * *Appium*: supported with context in apps
1274
+ * {{ react }}
1255
1275
  */
1256
1276
  async dontSee(text, context = null) {
1257
1277
  return proceedSee.call(this, 'negate', text, context);
@@ -1259,19 +1279,18 @@ I.dontSee('Login'); // assume we are already logged in
1259
1279
 
1260
1280
  /**
1261
1281
  * Checks that the given input field or textarea equals to given value.
1262
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1263
-
1264
- ```js
1265
- I.seeInField('Username', 'davert');
1266
- I.seeInField({css: 'form textarea'},'Type your comment here');
1267
- I.seeInField('form input[type=hidden]','hidden_value');
1268
- I.seeInField('#searchform input','Search');
1269
- ```
1270
- @param field located by label|name|CSS|XPath|strict locator.
1271
- @param value value to check.
1272
- *
1282
+ * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1283
+ *
1284
+ * ```js
1285
+ * I.seeInField('Username', 'davert');
1286
+ * I.seeInField({css: 'form textarea'},'Type your comment here');
1287
+ * I.seeInField('form input[type=hidden]','hidden_value');
1288
+ * I.seeInField('#searchform input','Search');
1289
+ * ```
1290
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
1291
+ * @param {string} value value to check.
1292
+ * {--end--}
1273
1293
  *
1274
- * * *Appium*: supported only for web testing
1275
1294
  */
1276
1295
  async seeInField(field, value) {
1277
1296
  return proceedSeeField.call(this, 'assert', field, value);
@@ -1279,13 +1298,17 @@ I.seeInField('#searchform input','Search');
1279
1298
 
1280
1299
  /**
1281
1300
  * Checks that value of input field or textare doesn't equal to given value
1282
- Opposite to `seeInField`.
1283
-
1284
- @param field located by label|name|CSS|XPath|strict locator.
1285
- @param value value to check.
1286
- *
1301
+ * Opposite to `seeInField`.
1302
+ *
1303
+ * ```js
1304
+ * I.dontSeeInField('email', 'user@user.com'); // field by name
1305
+ * I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
1306
+ * ```
1307
+ *
1308
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
1309
+ * @param {string} value value to check.
1310
+ * {--end--}
1287
1311
  *
1288
- * * *Appium*: supported only for web testing
1289
1312
  */
1290
1313
  async dontSeeInField(field, value) {
1291
1314
  return proceedSeeField.call(this, 'negate', field, value);
@@ -1293,13 +1316,15 @@ Opposite to `seeInField`.
1293
1316
 
1294
1317
  /**
1295
1318
  * Verifies that the specified checkbox is checked.
1296
-
1297
- ```js
1298
- I.seeCheckboxIsChecked('Agree');
1299
- I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1300
- I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1301
- ```
1302
- @param field located by label|name|CSS|XPath|strict locator.
1319
+ *
1320
+ * ```js
1321
+ * I.seeCheckboxIsChecked('Agree');
1322
+ * I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1323
+ * I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1324
+ * ```
1325
+ *
1326
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
1327
+ * {--end--}
1303
1328
  * Appium: not tested
1304
1329
  */
1305
1330
  async seeCheckboxIsChecked(field) {
@@ -1308,8 +1333,15 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1308
1333
 
1309
1334
  /**
1310
1335
  * Verifies that the specified checkbox is not checked.
1311
-
1312
- @param field located by label|name|CSS|XPath|strict locator.
1336
+ *
1337
+ * ```js
1338
+ * I.dontSeeeCheckboxIsChedcked('#agree'); // located by ID
1339
+ * I.dontSeeeCheckboxIsChedcked('I agree to terms'); // located by label
1340
+ * I.dontSeeeCheckboxIsChedcked('agree'); // located by name
1341
+ * ```
1342
+ *
1343
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
1344
+ * {--end--}
1313
1345
  * Appium: not tested
1314
1346
  */
1315
1347
  async dontSeeCheckboxIsChecked(field) {
@@ -1318,15 +1350,15 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1318
1350
 
1319
1351
  /**
1320
1352
  * Checks that a given Element is visible
1321
- Element is located by CSS or XPath.
1322
-
1323
- ```js
1324
- I.seeElement('#modal');
1325
- ```
1326
- @param locator located by CSS|XPath|strict locator.
1327
- *
1353
+ * Element is located by CSS or XPath.
1354
+ *
1355
+ * ```js
1356
+ * I.seeElement('#modal');
1357
+ * ```
1358
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1359
+ * {--end--}
1360
+ * {{ react }}
1328
1361
  *
1329
- * * *Appium*: supported
1330
1362
  */
1331
1363
  async seeElement(locator) {
1332
1364
  const res = await this._locate(locator, true);
@@ -1337,11 +1369,14 @@ I.seeElement('#modal');
1337
1369
 
1338
1370
  /**
1339
1371
  * Opposite to `seeElement`. Checks that element is not visible (or in DOM)
1340
-
1341
- @param locator located by CSS|XPath|Strict locator.
1342
- *
1343
- *
1344
- * * *Appium*: supported
1372
+ *
1373
+ * ```js
1374
+ * I.dontSeeElement('.modal'); // modal is not shown
1375
+ * ```
1376
+ *
1377
+ * @param {string|object} locator located by CSS|XPath|Strict locator.
1378
+ * {--end--}
1379
+ * {{ react }}
1345
1380
  */
1346
1381
  async dontSeeElement(locator) {
1347
1382
  const res = await this._locate(locator, false);
@@ -1354,15 +1389,14 @@ I.seeElement('#modal');
1354
1389
 
1355
1390
  /**
1356
1391
  * Checks that a given Element is present in the DOM
1357
- Element is located by CSS or XPath.
1358
-
1359
- ```js
1360
- I.seeElementInDOM('#modal');
1361
- ```
1362
- @param locator located by CSS|XPath|strict locator.
1363
- *
1392
+ * Element is located by CSS or XPath.
1393
+ *
1394
+ * ```js
1395
+ * I.seeElementInDOM('#modal');
1396
+ * ```
1397
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1398
+ * {--end--}
1364
1399
  *
1365
- * * *Appium*: supported
1366
1400
  */
1367
1401
  async seeElementInDOM(locator) {
1368
1402
  const res = await this.$$(withStrictLocator(locator));
@@ -1371,11 +1405,14 @@ I.seeElementInDOM('#modal');
1371
1405
 
1372
1406
  /**
1373
1407
  * Opposite to `seeElementInDOM`. Checks that element is not on page.
1374
-
1375
- @param locator located by CSS|XPath|Strict locator.
1376
- *
1408
+ *
1409
+ * ```js
1410
+ * I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
1411
+ * ```
1412
+ *
1413
+ * @param {string|object} locator located by CSS|XPath|Strict locator.
1414
+ * {--end--}
1377
1415
  *
1378
- * * *Appium*: supported
1379
1416
  */
1380
1417
  async dontSeeElementInDOM(locator) {
1381
1418
  const res = await this.$$(withStrictLocator(locator));
@@ -1384,14 +1421,13 @@ I.seeElementInDOM('#modal');
1384
1421
 
1385
1422
  /**
1386
1423
  * Checks that the current page contains the given string in its raw source code.
1387
-
1388
- ```js
1389
- I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1390
- ```
1391
- @param text value to check.
1392
- *
1424
+ *
1425
+ * ```js
1426
+ * I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1427
+ * ```
1428
+ * @param {string} text value to check.
1429
+ * {--end--}
1393
1430
  *
1394
- * * *Appium*: supported
1395
1431
  */
1396
1432
  async seeInSource(text) {
1397
1433
  const source = await this.browser.getPageSource();
@@ -1400,14 +1436,15 @@ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1400
1436
 
1401
1437
  /**
1402
1438
  * Retrieves page source and returns it to test.
1403
- Resumes test execution, so should be used inside an async function.
1404
-
1405
- ```js
1406
- let pageSource = await I.grabSource();
1407
- ```
1408
- *
1439
+ * Resumes test execution, so should be used inside an async function.
1440
+ *
1441
+ * ```js
1442
+ * let pageSource = await I.grabSource();
1443
+ * ```
1444
+ *
1445
+ * @returns {Promise<string>} source code
1446
+ * {--end--}
1409
1447
  *
1410
- * * *Appium*: supported
1411
1448
  */
1412
1449
  async grabSource() {
1413
1450
  return this.browser.getPageSource();
@@ -1431,12 +1468,15 @@ let pageSource = await I.grabSource();
1431
1468
 
1432
1469
  /**
1433
1470
  * Get current URL from browser.
1434
- Resumes test execution, so should be used inside an async function.
1435
-
1436
- ```js
1437
- let url = await I.grabCurrentUrl();
1438
- console.log(`Current URL is [${url}]`);
1439
- ```
1471
+ * Resumes test execution, so should be used inside an async function.
1472
+ *
1473
+ * ```js
1474
+ * let url = await I.grabCurrentUrl();
1475
+ * console.log(`Current URL is [${url}]`);
1476
+ * ```
1477
+ *
1478
+ * @returns {Promise<string>} current URL
1479
+ * {--end--}
1440
1480
  */
1441
1481
  async grabCurrentUrl() {
1442
1482
  const res = await this.browser.getUrl();
@@ -1446,12 +1486,13 @@ console.log(`Current URL is [${url}]`);
1446
1486
 
1447
1487
  /**
1448
1488
  * Checks that the current page does not contains the given string in its raw source code.
1449
-
1450
- @param text value to check.
1451
-
1452
- *
1453
- *
1454
- * * *Appium*: supported
1489
+ *
1490
+ * ```js
1491
+ * I.dontSeeInSource('<!--'); // no comments in source
1492
+ * ```
1493
+ *
1494
+ * @param {string} value to check.
1495
+ * {--end--}
1455
1496
  */
1456
1497
  async dontSeeInSource(text) {
1457
1498
  const source = await this.browser.getPageSource();
@@ -1461,16 +1502,16 @@ console.log(`Current URL is [${url}]`);
1461
1502
  /**
1462
1503
  * Asserts that an element appears a given number of times in the DOM.
1463
1504
  * Element is located by label or name or CSS or XPath.
1464
- *
1465
- *
1466
- * * *Appium*: supported
1467
- *
1505
+ *
1506
+ *
1468
1507
  * ```js
1469
1508
  * I.seeNumberOfElements('#submitBtn', 1);
1470
1509
  * ```
1471
- *
1472
- * @param locator element located by CSS|XPath|strict locator.
1473
- * @param num number of elements.
1510
+ *
1511
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1512
+ * @param {number} num number of elements.
1513
+ * {--end--}
1514
+ * {{ react }}
1474
1515
  */
1475
1516
  async seeNumberOfElements(locator, num) {
1476
1517
  const res = await this._locate(locator);
@@ -1479,14 +1520,16 @@ console.log(`Current URL is [${url}]`);
1479
1520
 
1480
1521
  /**
1481
1522
  * Asserts that an element is visible a given number of times.
1482
- Element is located by CSS or XPath.
1483
-
1484
- ```js
1485
- I.seeNumberOfVisibleElements('.buttons', 3);
1486
- ```
1487
-
1488
- @param locator element located by CSS|XPath|strict locator.
1489
- @param num number of elements.
1523
+ * Element is located by CSS or XPath.
1524
+ *
1525
+ * ```js
1526
+ * I.seeNumberOfVisibleElements('.buttons', 3);
1527
+ * ```
1528
+ *
1529
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1530
+ * @param {number} num number of elements.
1531
+ * {--end--}
1532
+ * {{ react }}
1490
1533
  */
1491
1534
  async seeNumberOfVisibleElements(locator, num) {
1492
1535
  const res = await this.grabNumberOfVisibleElements(locator);
@@ -1495,13 +1538,14 @@ I.seeNumberOfVisibleElements('.buttons', 3);
1495
1538
 
1496
1539
  /**
1497
1540
  * Checks that all elements with given locator have given CSS properties.
1498
-
1499
- ```js
1500
- I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1501
- ```
1502
-
1503
- @param locator located by CSS|XPath|strict locator.
1504
- @param cssProperties object with CSS properties and their values to check.
1541
+ *
1542
+ * ```js
1543
+ * I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1544
+ * ```
1545
+ *
1546
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1547
+ * @param {object} cssProperties object with CSS properties and their values to check.
1548
+ * {--end--}
1505
1549
  */
1506
1550
  async seeCssPropertiesOnElements(locator, cssProperties) {
1507
1551
  const res = await this._locate(locator);
@@ -1537,13 +1581,14 @@ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1537
1581
 
1538
1582
  /**
1539
1583
  * Checks that all elements with given locator have given attributes.
1540
-
1541
- ```js
1542
- I.seeAttributesOnElements('//form', {'method': "post"});
1543
- ```
1544
-
1545
- @param locator located by CSS|XPath|strict locator.
1546
- @param attributes object with attributes and their values to check.
1584
+ *
1585
+ * ```js
1586
+ * I.seeAttributesOnElements('//form', { method: "post"});
1587
+ * ```
1588
+ *
1589
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1590
+ * @param {object} attributes attributes and their values to check.
1591
+ * {--end--}
1547
1592
  */
1548
1593
  async seeAttributesOnElements(locator, attributes) {
1549
1594
  const res = await this._locate(locator);
@@ -1571,12 +1616,14 @@ I.seeAttributesOnElements('//form', {'method': "post"});
1571
1616
 
1572
1617
  /**
1573
1618
  * Grab number of visible elements by locator.
1574
-
1575
- ```js
1576
- I.grabNumberOfVisibleElements('p');
1577
- ```
1578
-
1579
- @param locator located by CSS|XPath|strict locator.
1619
+ *
1620
+ * ```js
1621
+ * let numOfElements = await I.grabNumberOfVisibleElements('p');
1622
+ * ```
1623
+ *
1624
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1625
+ * @returns {Promise<number>} number of visible elements
1626
+ * {--end--}
1580
1627
  */
1581
1628
  async grabNumberOfVisibleElements(locator) {
1582
1629
  const res = await this._locate(locator);
@@ -1589,15 +1636,14 @@ I.grabNumberOfVisibleElements('p');
1589
1636
 
1590
1637
  /**
1591
1638
  * Checks that current url contains a provided fragment.
1592
-
1593
- ```js
1594
- I.seeInCurrentUrl('/register'); // we are on registration page
1595
- ```
1596
-
1597
- @param url value to check.
1598
- *
1639
+ *
1640
+ * ```js
1641
+ * I.seeInCurrentUrl('/register'); // we are on registration page
1642
+ * ```
1643
+ *
1644
+ * @param {string} url a fragment to check
1645
+ * {--end--}
1599
1646
  *
1600
- * * *Appium*: supported only for web testing
1601
1647
  */
1602
1648
  async seeInCurrentUrl(url) {
1603
1649
  const res = await this.browser.getUrl();
@@ -1606,11 +1652,10 @@ I.seeInCurrentUrl('/register'); // we are on registration page
1606
1652
 
1607
1653
  /**
1608
1654
  * Checks that current url does not contain a provided fragment.
1609
-
1610
- @param url value to check.
1655
+ *
1656
+ * @param {string} url value to check.
1657
+ * {--end--}
1611
1658
  *
1612
- *
1613
- * * *Appium*: supported only for web testing
1614
1659
  */
1615
1660
  async dontSeeInCurrentUrl(url) {
1616
1661
  const res = await this.browser.getUrl();
@@ -1619,18 +1664,17 @@ I.seeInCurrentUrl('/register'); // we are on registration page
1619
1664
 
1620
1665
  /**
1621
1666
  * Checks that current url is equal to provided one.
1622
- If a relative url provided, a configured url will be prepended to it.
1623
- So both examples will work:
1624
-
1625
- ```js
1626
- I.seeCurrentUrlEquals('/register');
1627
- I.seeCurrentUrlEquals('http://my.site.com/register');
1628
- ```
1629
-
1630
- @param url value to check.
1631
- *
1667
+ * If a relative url provided, a configured url will be prepended to it.
1668
+ * So both examples will work:
1669
+ *
1670
+ * ```js
1671
+ * I.seeCurrentUrlEquals('/register');
1672
+ * I.seeCurrentUrlEquals('http://my.site.com/register');
1673
+ * ```
1674
+ *
1675
+ * @param {string} url value to check.
1676
+ * {--end--}
1632
1677
  *
1633
- * * *Appium*: supported only for web testing
1634
1678
  */
1635
1679
  async seeCurrentUrlEquals(url) {
1636
1680
  const res = await this.browser.getUrl();
@@ -1639,12 +1683,16 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
1639
1683
 
1640
1684
  /**
1641
1685
  * Checks that current url is not equal to provided one.
1642
- If a relative url provided, a configured url will be prepended to it.
1643
-
1644
- @param url value to check.
1645
- *
1686
+ * If a relative url provided, a configured url will be prepended to it.
1687
+ *
1688
+ * ```js
1689
+ * I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
1690
+ * I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
1691
+ * ```
1692
+ *
1693
+ * @param {string} url value to check.
1694
+ * {--end--}
1646
1695
  *
1647
- * * *Appium*: supported only for web testing
1648
1696
  */
1649
1697
  async dontSeeCurrentUrlEquals(url) {
1650
1698
  const res = await this.browser.getUrl();
@@ -1653,33 +1701,32 @@ If a relative url provided, a configured url will be prepended to it.
1653
1701
 
1654
1702
  /**
1655
1703
  * Executes sync script on a page.
1656
- Pass arguments to function as additional parameters.
1657
- Will return execution result to a test.
1658
- In this case you should use async function and await to receive results.
1659
-
1660
- Example with jQuery DatePicker:
1661
-
1662
- ```js
1663
- // change date of jQuery DatePicker
1664
- I.executeScript(function() {
1665
- // now we are inside browser context
1666
- $('date').datetimepicker('setDate', new Date());
1667
- });
1668
- ```
1669
- Can return values. Don't forget to use `await` to get them.
1670
-
1671
- ```js
1672
- let date = await I.executeScript(function(el) {
1673
- // only basic types can be returned
1674
- return $(el).datetimepicker('getDate').toString();
1675
- }, '#date'); // passing jquery selector
1676
- ```
1677
-
1678
- @param fn function to be executed in browser context.
1679
- @param ...args args to be passed to function.
1680
- *
1704
+ * Pass arguments to function as additional parameters.
1705
+ * Will return execution result to a test.
1706
+ * In this case you should use async function and await to receive results.
1707
+ *
1708
+ * Example with jQuery DatePicker:
1709
+ *
1710
+ * ```js
1711
+ * // change date of jQuery DatePicker
1712
+ * I.executeScript(function() {
1713
+ * // now we are inside browser context
1714
+ * $('date').datetimepicker('setDate', new Date());
1715
+ * });
1716
+ * ```
1717
+ * Can return values. Don't forget to use `await` to get them.
1718
+ *
1719
+ * ```js
1720
+ * let date = await I.executeScript(function(el) {
1721
+ * // only basic types can be returned
1722
+ * return $(el).datetimepicker('getDate').toString();
1723
+ * }, '#date'); // passing jquery selector
1724
+ * ```
1725
+ *
1726
+ * @param {string|function} fn function to be executed in browser context.
1727
+ * @param ...args args to be passed to function.
1728
+ * {--end--}
1681
1729
  *
1682
- * * *Appium*: supported only for web testing
1683
1730
  *
1684
1731
  * Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
1685
1732
  */
@@ -1689,31 +1736,30 @@ let date = await I.executeScript(function(el) {
1689
1736
 
1690
1737
  /**
1691
1738
  * Executes async script on page.
1692
- Provided function should execute a passed callback (as first argument) to signal it is finished.
1693
-
1694
- Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
1695
-
1696
- ```js
1697
- I.executeAsyncScript(function(done) {
1698
- Vue.nextTick(done); // waiting for next tick
1699
- });
1700
- ```
1701
-
1702
- By passing value to `done()` function you can return values.
1703
- Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
1704
-
1705
- ```js
1706
- let val = await I.executeAsyncScript(function(url, done) {
1707
- // in browser context
1708
- $.ajax(url, { success: (data) => done(data); }
1709
- }, 'http://ajax.callback.url/');
1710
- ```
1711
-
1712
- @param fn function to be executed in browser context.
1713
- @param ...args args to be passed to function.
1714
- *
1739
+ * Provided function should execute a passed callback (as first argument) to signal it is finished.
1740
+ *
1741
+ * Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
1742
+ *
1743
+ * ```js
1744
+ * I.executeAsyncScript(function(done) {
1745
+ * Vue.nextTick(done); // waiting for next tick
1746
+ * });
1747
+ * ```
1748
+ *
1749
+ * By passing value to `done()` function you can return values.
1750
+ * Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
1751
+ *
1752
+ * ```js
1753
+ * let val = await I.executeAsyncScript(function(url, done) {
1754
+ * // in browser context
1755
+ * $.ajax(url, { success: (data) => done(data); }
1756
+ * }, 'http://ajax.callback.url/');
1757
+ * ```
1758
+ *
1759
+ * @param {string|function} fn function to be executed in browser context.
1760
+ * @param ...args args to be passed to function.
1761
+ * {--end--}
1715
1762
  *
1716
- * * *Appium*: supported only for web testing
1717
1763
  */
1718
1764
  executeAsyncScript(fn) {
1719
1765
  return this.browser.executeAsync.apply(this.browser, arguments);
@@ -1722,32 +1768,17 @@ let val = await I.executeAsyncScript(function(url, done) {
1722
1768
  /**
1723
1769
  * Scrolls to element matched by locator.
1724
1770
  * Extra shift can be set with offsetX and offsetY options.
1725
- *
1771
+ *
1726
1772
  * ```js
1727
1773
  * I.scrollTo('footer');
1728
1774
  * I.scrollTo('#submit', 5, 5);
1729
1775
  * ```
1776
+ *
1777
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1778
+ * @param {number} offsetX (optional, `0` by default) X-axis offset.
1779
+ * @param {number} offsetY (optional, `0` by default) Y-axis offset.
1780
+ * {--end--}
1730
1781
  *
1731
- * @param locator located by CSS|XPath|strict locator.
1732
- * @param offsetX (optional) X-axis offset.
1733
- * @param offsetY (optional) Y-axis offset.
1734
- */
1735
-
1736
- /**
1737
- * Scrolls to element matched by locator.
1738
- Extra shift can be set with offsetX and offsetY options.
1739
-
1740
- ```js
1741
- I.scrollTo('footer');
1742
- I.scrollTo('#submit', 5, 5);
1743
- ```
1744
-
1745
- @param locator located by CSS|XPath|strict locator.
1746
- @param offsetX (optional) X-axis offset.
1747
- @param offsetY (optional) Y-axis offset.
1748
- *
1749
- *
1750
- * * *Appium*: supported only for web testing
1751
1782
  */
1752
1783
  async scrollTo(locator, offsetX = 0, offsetY = 0) {
1753
1784
  if (typeof locator === 'number' && typeof offsetX === 'number') {
@@ -1778,19 +1809,18 @@ I.scrollTo('#submit', 5, 5);
1778
1809
 
1779
1810
  /**
1780
1811
  * Moves cursor to element matched by locator.
1781
- Extra shift can be set with offsetX and offsetY options.
1782
-
1783
- ```js
1784
- I.moveCursorTo('.tooltip');
1785
- I.moveCursorTo('#submit', 5,5);
1786
- ```
1787
-
1788
- @param locator located by CSS|XPath|strict locator.
1789
- @param offsetX (optional) X-axis offset.
1790
- @param offsetY (optional) Y-axis offset.
1791
- *
1812
+ * Extra shift can be set with offsetX and offsetY options.
1813
+ *
1814
+ * ```js
1815
+ * I.moveCursorTo('.tooltip');
1816
+ * I.moveCursorTo('#submit', 5,5);
1817
+ * ```
1818
+ *
1819
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1820
+ * @param {number} offsetX (optional, `0` by default) X-axis offset.
1821
+ * @param {number} offsetY (optional, `0` by default) Y-axis offset.
1822
+ * {--end--}
1792
1823
  *
1793
- * * *Appium*: supported only for web testing
1794
1824
  */
1795
1825
  async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
1796
1826
  const res = await this._locate(withStrictLocator(locator), true);
@@ -1801,19 +1831,18 @@ I.moveCursorTo('#submit', 5,5);
1801
1831
 
1802
1832
  /**
1803
1833
  * Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
1804
- Filename is relative to output folder.
1805
- Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
1806
-
1807
- ```js
1808
- I.saveScreenshot('debug.png');
1809
- I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1810
- ```
1811
-
1812
- @param fileName file name to save.
1813
- @param fullPage (optional) flag to enable fullscreen screenshot mode.
1814
- *
1834
+ * Filename is relative to output folder.
1835
+ * Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
1836
+ *
1837
+ * ```js
1838
+ * I.saveScreenshot('debug.png');
1839
+ * I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1840
+ * ```
1841
+ *
1842
+ * @param {string} fileName file name to save.
1843
+ * @param {boolean} fullPage (optional, `false` by default) flag to enable fullscreen screenshot mode.
1844
+ * {--end--}
1815
1845
  *
1816
- * * *Appium*: supported
1817
1846
  */
1818
1847
  async saveScreenshot(fileName, fullPage = false) {
1819
1848
  const outputFile = screenshotOutputFolder(fileName);
@@ -1846,15 +1875,14 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
1846
1875
 
1847
1876
  /**
1848
1877
  * Sets a cookie.
1849
-
1850
- ```js
1851
- I.setCookie({name: 'auth', value: true});
1852
- ```
1853
-
1854
- @param cookie cookie JSON object.
1855
- *
1878
+ *
1879
+ * ```js
1880
+ * I.setCookie({name: 'auth', value: true});
1881
+ * ```
1882
+ *
1883
+ * @param {object} cookie a cookie object.
1884
+ * {--end--}
1856
1885
  *
1857
- * * *Appium*: supported only for web testing
1858
1886
  *
1859
1887
  * Uses Selenium's JSON [cookie
1860
1888
  * format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
@@ -1865,17 +1893,16 @@ I.setCookie({name: 'auth', value: true});
1865
1893
 
1866
1894
  /**
1867
1895
  * Clears a cookie by name,
1868
- if none provided clears all cookies.
1869
-
1870
- ```js
1871
- I.clearCookie();
1872
- I.clearCookie('test');
1873
- ```
1874
-
1875
- @param cookie (optional) cookie name.
1876
- *
1896
+ * if none provided clears all cookies.
1897
+ *
1898
+ * ```js
1899
+ * I.clearCookie();
1900
+ * I.clearCookie('test');
1901
+ * ```
1902
+ *
1903
+ * @param {string} cookie (optional, `null` by default) cookie name
1904
+ * {--end--}
1877
1905
  *
1878
- * * *Appium*: supported only for web testing
1879
1906
  */
1880
1907
  async clearCookie(cookie) {
1881
1908
  return this.browser.deleteCookies(cookie);
@@ -1883,15 +1910,14 @@ I.clearCookie('test');
1883
1910
 
1884
1911
  /**
1885
1912
  * Checks that cookie with given name exists.
1886
-
1887
- ```js
1888
- I.seeCookie('Auth');
1889
- ```
1890
-
1891
- @param name cookie name.
1892
- *
1913
+ *
1914
+ * ```js
1915
+ * I.seeCookie('Auth');
1916
+ * ```
1917
+ *
1918
+ * @param {string} name cookie name.
1919
+ * {--end--}
1893
1920
  *
1894
- * * *Appium*: supported only for web testing
1895
1921
  */
1896
1922
  async seeCookie(name) {
1897
1923
  const cookie = await this.browser.getCookies([name]);
@@ -1900,11 +1926,14 @@ I.seeCookie('Auth');
1900
1926
 
1901
1927
  /**
1902
1928
  * Checks that cookie with given name does not exist.
1903
-
1904
- @param name cookie name.
1905
- *
1929
+ *
1930
+ * ```js
1931
+ * I.dontSeeCookie('auth'); // no auth cookie
1932
+ * ```
1933
+ *
1934
+ * @param {string} name cookie name.
1935
+ * {--end--}
1906
1936
  *
1907
- * * *Appium*: supported only for web testing
1908
1937
  */
1909
1938
  async dontSeeCookie(name) {
1910
1939
  const cookie = await this.browser.getCookies([name]);
@@ -1913,18 +1942,18 @@ I.seeCookie('Auth');
1913
1942
 
1914
1943
  /**
1915
1944
  * Gets a cookie object by name.
1916
- If none provided gets all cookies.
1917
- * Resumes test execution, so **should be used inside async with `await`** operator.
1918
-
1919
- ```js
1920
- let cookie = await I.grabCookie('auth');
1921
- assert(cookie.value, '123456');
1922
- ```
1923
-
1924
- @param name (optional) cookie name.
1925
- *
1945
+ * If none provided gets all cookies.
1946
+ * * Resumes test execution, so **should be used inside async with `await`** operator.
1947
+ *
1948
+ * ```js
1949
+ * let cookie = await I.grabCookie('auth');
1950
+ * assert(cookie.value, '123456');
1951
+ * ```
1952
+ *
1953
+ * @param [name=null] cookie name.
1954
+ * @returns {Promise<string>} attribute value
1955
+ * {--end--}
1926
1956
  *
1927
- * * *Appium*: supported only for web testing
1928
1957
  */
1929
1958
  async grabCookie(name) {
1930
1959
  if (!name) return this.browser.getCookies();
@@ -1937,8 +1966,6 @@ assert(cookie.value, '123456');
1937
1966
  * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
1938
1967
  * Don't confuse popups with modal windows, as created by [various
1939
1968
  * libraries](http://jster.net/category/windows-modals-popups).
1940
- *
1941
- * * *Appium*: supported only for web testing
1942
1969
  */
1943
1970
  async acceptPopup() {
1944
1971
  return this.browser.getAlertText().then((res) => {
@@ -1951,8 +1978,6 @@ assert(cookie.value, '123456');
1951
1978
  /**
1952
1979
  * Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
1953
1980
  *
1954
- *
1955
- * * *Appium*: supported only for web testing
1956
1981
  */
1957
1982
  async cancelPopup() {
1958
1983
  return this.browser.getAlertText().then((res) => {
@@ -1966,8 +1991,6 @@ assert(cookie.value, '123456');
1966
1991
  * Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
1967
1992
  * given string.
1968
1993
  *
1969
- * * *Appium*: supported only for web testing
1970
- *
1971
1994
  * @param text value to check.
1972
1995
  */
1973
1996
  async seeInPopup(text) {
@@ -1996,53 +2019,22 @@ assert(cookie.value, '123456');
1996
2019
 
1997
2020
  /**
1998
2021
  * Presses a key on a focused element.
1999
- Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
2000
- will be replaced with corresponding unicode.
2001
- If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
2002
-
2003
- ```js
2004
- I.pressKey('Enter');
2005
- I.pressKey(['Control','a']);
2006
- ```
2007
-
2008
- @param key key or array of keys to press.
2009
- * [Valid key names](https://w3c.github.io/webdriver/#keyboard-actions) are:
2010
-
2011
- - `'Add'`,
2012
- - `'Alt'`,
2013
- - `'ArrowDown'` or `'Down arrow'`,
2014
- - `'ArrowLeft'` or `'Left arrow'`,
2015
- - `'ArrowRight'` or `'Right arrow'`,
2016
- - `'ArrowUp'` or `'Up arrow'`,
2017
- - `'Backspace'`,
2018
- - `'Command'`,
2019
- - `'Control'`,
2020
- - `'Del'`,
2021
- - `'Divide'`,
2022
- - `'End'`,
2023
- - `'Enter'`,
2024
- - `'Equals'`,
2025
- - `'Escape'`,
2026
- - `'F1 to F12'`,
2027
- - `'Home'`,
2028
- - `'Insert'`,
2029
- - `'Meta'`,
2030
- - `'Multiply'`,
2031
- - `'Numpad 0'` to `'Numpad 9'`,
2032
- - `'Pagedown'` or `'PageDown'`,
2033
- - `'Pageup'` or `'PageUp'`,
2034
- - `'Pause'`,
2035
- - `'Semicolon'`,
2036
- - `'Shift'`,
2037
- - `'Space'`,
2038
- - `'Subtract'`,
2039
- - `'Tab'`.
2022
+ * Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
2023
+ * will be replaced with corresponding unicode.
2024
+ * If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
2025
+ *
2026
+ * ```js
2027
+ * I.pressKey('Enter');
2028
+ * I.pressKey(['Control','a']);
2029
+ * ```
2030
+ *
2031
+ * @param {string|array} key key or array of keys to press.
2032
+ * {--end--}
2033
+ * {{ keys }}
2040
2034
  *
2041
2035
  * To make combinations with modifier and mouse clicks (like Ctrl+Click) press a modifier, click, then release it.
2042
2036
  *
2043
2037
  *
2044
- * * *Appium*: supported, but clear field before pressing in apps:
2045
- *
2046
2038
  * ```js
2047
2039
  * I.pressKey('Control');
2048
2040
  * I.click('#someelement');
@@ -2062,33 +2054,48 @@ I.pressKey(['Control','a']);
2062
2054
 
2063
2055
  /**
2064
2056
  * Resize the current window to provided width and height.
2065
- First parameter can be set to `maximize`.
2066
-
2067
- @param width width in pixels or `maximize`.
2068
- @param height height in pixels.
2057
+ * First parameter can be set to `maximize`.
2058
+ *
2059
+ * @param {number} width width in pixels or `maximize`.
2060
+ * @param {number} height height in pixels.
2061
+ * {--end--}
2069
2062
  * Appium: not tested in web, in apps doesn't work
2070
2063
  */
2071
2064
  async resizeWindow(width, height) {
2065
+ return this._resizeBrowserWindow(this.browser, width, height);
2066
+ }
2067
+
2068
+ async _resizeBrowserWindow(browser, width, height) {
2072
2069
  if (width === 'maximize') {
2073
- const size = await this.browser.maximizeWindow();
2070
+ const size = await browser.maximizeWindow();
2074
2071
  this.debugSection('Window Size', size);
2075
2072
  return;
2076
2073
  }
2077
- if (this.browser.isW3C) {
2078
- return this.browser.setWindowRect(null, null, parseInt(width, 10), parseInt(height, 10));
2074
+ if (browser.isW3C) {
2075
+ return browser.setWindowRect(null, null, parseInt(width, 10), parseInt(height, 10));
2076
+ }
2077
+ return browser.setWindowSize(parseInt(width, 10), parseInt(height, 10));
2078
+ }
2079
+
2080
+ async _resizeWindowIfNeeded(browser, windowSize) {
2081
+ if (this.isWeb && windowSize === 'maximize') {
2082
+ await this._resizeBrowserWindow(browser, 'maximize');
2083
+ } else if (this.isWeb && windowSize && windowSize.indexOf('x') > 0) {
2084
+ const dimensions = windowSize.split('x');
2085
+ await this._resizeBrowserWindow(browser, dimensions[0], dimensions[1]);
2079
2086
  }
2080
- return this.browser.setWindowSize(parseInt(width, 10), parseInt(height, 10));
2081
2087
  }
2082
2088
 
2083
2089
  /**
2084
2090
  * Drag an item to a destination element.
2085
-
2086
- ```js
2087
- I.dragAndDrop('#dragHandle', '#container');
2088
- ```
2089
-
2090
- @param srcElement located by CSS|XPath|strict locator.
2091
- @param destElement located by CSS|XPath|strict locator.
2091
+ *
2092
+ * ```js
2093
+ * I.dragAndDrop('#dragHandle', '#container');
2094
+ * ```
2095
+ *
2096
+ * @param {string|object} srcElement located by CSS|XPath|strict locator.
2097
+ * @param {string|object} destElement located by CSS|XPath|strict locator.
2098
+ * {--end--}
2092
2099
  * Appium: not tested
2093
2100
  */
2094
2101
  async dragAndDrop(srcElement, destElement) {
@@ -2105,15 +2112,16 @@ I.dragAndDrop('#dragHandle', '#container');
2105
2112
 
2106
2113
  /**
2107
2114
  * Drag the scrubber of a slider to a given position
2108
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
2109
-
2110
- ```js
2111
- I.dragSlider('#slider', 30);
2112
- I.dragSlider('#slider', -70);
2113
- ```
2114
-
2115
- @param locator located by label|name|CSS|XPath|strict locator.
2116
- @param offsetX position to drag.
2115
+ * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
2116
+ *
2117
+ * ```js
2118
+ * I.dragSlider('#slider', 30);
2119
+ * I.dragSlider('#slider', -70);
2120
+ * ```
2121
+ *
2122
+ * @param {string|object} locator located by label|name|CSS|XPath|strict locator.
2123
+ * @param {number} offsetX position to drag.
2124
+ * {--end--}
2117
2125
  */
2118
2126
  async dragSlider(locator, offsetX = 0) {
2119
2127
  const browser = this.browser;
@@ -2135,12 +2143,51 @@ I.dragSlider('#slider', -70);
2135
2143
  await browser.buttonUp(0);
2136
2144
  }
2137
2145
 
2146
+ /**
2147
+ * Get all Window Handles.
2148
+ * Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
2149
+ *
2150
+ * ```js
2151
+ * const windows = await I.grabAllWindowHandles();
2152
+ * ```
2153
+ */
2154
+ async grabAllWindowHandles() {
2155
+ return this.browser.getWindowHandles();
2156
+ }
2138
2157
 
2139
2158
  /**
2140
- * Close all tabs except for the current one.
2159
+ * Get the current Window Handle.
2160
+ * Useful for referencing it when calling `I.switchToWindow(handle)`
2161
+ *
2162
+ * ```js
2163
+ * const window = await I.grabCurrentWindowHandle();
2164
+ * ```
2165
+ */
2166
+ async grabCurrentWindowHandle() {
2167
+ return this.browser.getWindowHandle();
2168
+ }
2169
+
2170
+ /**
2171
+ * Switch to the window with a specified handle.
2172
+ *
2173
+ * ```js
2174
+ * const windows = await I.grabAllWindowHandles();
2175
+ * // ... do something
2176
+ * await I.switchToWindow( windows[0] );
2141
2177
  *
2178
+ * const window = await.grabCurrentWindowHandle();
2179
+ * // ... do something
2180
+ * await I.switchToWindow( window );
2181
+ * ```
2182
+ */
2183
+ async switchToWindow(window) {
2184
+ await this.browser.switchToWindow(window);
2185
+ }
2186
+
2187
+
2188
+ /**
2189
+ * Close all tabs except for the current one.
2142
2190
  *
2143
- * * *Appium*: supported web test
2144
2191
  *
2145
2192
  * ```js
2146
2193
  * I.closeOtherTabs();
@@ -2160,16 +2207,14 @@ I.dragSlider('#slider', -70);
2160
2207
 
2161
2208
  /**
2162
2209
  * Pauses execution for a number of seconds.
2163
-
2164
- ```js
2165
- I.wait(2); // wait 2 secs
2166
- ```
2167
-
2168
- @param sec number of second to wait.
2169
- @param sec time in seconds to wait.
2170
- *
2210
+ *
2211
+ * ```js
2212
+ * I.wait(2); // wait 2 secs
2213
+ * ```
2214
+ *
2215
+ * @param {number} sec number of second to wait.
2216
+ * {--end--}
2171
2217
  *
2172
- * * *Appium*: supported
2173
2218
  */
2174
2219
  async wait(sec) {
2175
2220
  return new Promise(resolve => setTimeout(resolve, sec * 1000));
@@ -2177,13 +2222,12 @@ I.wait(2); // wait 2 secs
2177
2222
 
2178
2223
  /**
2179
2224
  * Waits for element to become enabled (by default waits for 1sec).
2180
- Element can be located by CSS or XPath.
2181
-
2182
- @param locator element located by CSS|XPath|strict locator.
2183
- @param sec (optional) time in seconds to wait, 1 by default.
2184
- *
2225
+ * Element can be located by CSS or XPath.
2226
+ *
2227
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2228
+ * @param sec (optional) time in seconds to wait, 1 by default.
2229
+ * {--end--}
2185
2230
  *
2186
- * * *Appium*: supported
2187
2231
  */
2188
2232
  async waitForEnabled(locator, sec = null) {
2189
2233
  const aSec = sec || this.options.waitForTimeout;
@@ -2202,15 +2246,16 @@ Element can be located by CSS or XPath.
2202
2246
 
2203
2247
  /**
2204
2248
  * Waits for element to be present on page (by default waits for 1sec).
2205
- Element can be located by CSS or XPath.
2206
-
2207
- ```js
2208
- I.waitForElement('.btn.continue');
2209
- I.waitForElement('.btn.continue', 5); // wait for 5 secs
2210
- ```
2211
-
2212
- @param locator element located by CSS|XPath|strict locator.
2213
- @param sec (optional) time in seconds to wait, 1 by default.
2249
+ * Element can be located by CSS or XPath.
2250
+ *
2251
+ * ```js
2252
+ * I.waitForElement('.btn.continue');
2253
+ * I.waitForElement('.btn.continue', 5); // wait for 5 secs
2254
+ * ```
2255
+ *
2256
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2257
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2258
+ * {--end--}
2214
2259
  */
2215
2260
  async waitForElement(locator, sec = null) {
2216
2261
  const aSec = sec || this.options.waitForTimeout;
@@ -2230,13 +2275,14 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
2230
2275
 
2231
2276
  /**
2232
2277
  * Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
2233
-
2234
- ```js
2235
- I.waitInUrl('/info', 2);
2236
- ```
2237
-
2238
- @param urlPart value to check.
2239
- @param sec (optional) time in seconds to wait.
2278
+ *
2279
+ * ```js
2280
+ * I.waitInUrl('/info', 2);
2281
+ * ```
2282
+ *
2283
+ * @param {string} urlPart value to check.
2284
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2285
+ * {--end--}
2240
2286
  */
2241
2287
  async waitInUrl(urlPart, sec = null) {
2242
2288
  const client = this.browser;
@@ -2258,14 +2304,15 @@ I.waitInUrl('/info', 2);
2258
2304
 
2259
2305
  /**
2260
2306
  * Waits for the entire URL to match the expected
2261
-
2262
- ```js
2263
- I.waitUrlEquals('/info', 2);
2264
- I.waitUrlEquals('http://127.0.0.1:8000/info');
2265
- ```
2266
-
2267
- @param urlPart value to check.
2268
- @param sec (optional) time in seconds to wait.
2307
+ *
2308
+ * ```js
2309
+ * I.waitUrlEquals('/info', 2);
2310
+ * I.waitUrlEquals('http://127.0.0.1:8000/info');
2311
+ * ```
2312
+ *
2313
+ * @param {string} urlPart value to check.
2314
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2315
+ * {--end--}
2269
2316
  */
2270
2317
  async waitUrlEquals(urlPart, sec = null) {
2271
2318
  const aSec = sec || this.options.waitForTimeout;
@@ -2289,17 +2336,18 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
2289
2336
 
2290
2337
  /**
2291
2338
  * Waits for a text to appear (by default waits for 1sec).
2292
- Element can be located by CSS or XPath.
2293
- Narrow down search results by providing context.
2294
-
2295
- ```js
2296
- I.waitForText('Thank you, form has been submitted');
2297
- I.waitForText('Thank you, form has been submitted', 5, '#modal');
2298
- ```
2299
-
2300
- @param text to wait for.
2301
- @param sec (optional) time in seconds to wait.
2302
- @param context (optional) element located by CSS|XPath|strict locator.
2339
+ * Element can be located by CSS or XPath.
2340
+ * Narrow down search results by providing context.
2341
+ *
2342
+ * ```js
2343
+ * I.waitForText('Thank you, form has been submitted');
2344
+ * I.waitForText('Thank you, form has been submitted', 5, '#modal');
2345
+ * ```
2346
+ *
2347
+ * @param {string }text to wait for.
2348
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2349
+ * @param {string|object} context (optional) element located by CSS|XPath|strict locator.
2350
+ * {--end--}
2303
2351
  *
2304
2352
  */
2305
2353
  async waitForText(text, sec = null, context = null) {
@@ -2321,14 +2369,15 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
2321
2369
 
2322
2370
  /**
2323
2371
  * Waits for the specified value to be in value attribute.
2324
-
2325
- ```js
2326
- I.waitForValue('//input', "GoodValue");
2327
- ```
2328
-
2329
- @param field input field.
2330
- @param value expected value.
2331
- @param sec (optional) time in seconds to wait, 1 sec by default.
2372
+ *
2373
+ * ```js
2374
+ * I.waitForValue('//input', "GoodValue");
2375
+ * ```
2376
+ *
2377
+ * @param {string|object} field input field.
2378
+ * @param {string }value expected value.
2379
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2380
+ * {--end--}
2332
2381
  */
2333
2382
  async waitForValue(field, value, sec = null) {
2334
2383
  const client = this.browser;
@@ -2349,17 +2398,16 @@ I.waitForValue('//input', "GoodValue");
2349
2398
 
2350
2399
  /**
2351
2400
  * Waits for an element to become visible on a page (by default waits for 1sec).
2352
- Element can be located by CSS or XPath.
2353
-
2354
- ```
2355
- I.waitForVisible('#popup');
2356
- ```
2357
-
2358
- @param locator element located by CSS|XPath|strict locator.
2359
- @param sec (optional) time in seconds to wait, 1 by default.
2360
- *
2401
+ * Element can be located by CSS or XPath.
2402
+ *
2403
+ * ```js
2404
+ * I.waitForVisible('#popup');
2405
+ * ```
2406
+ *
2407
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2408
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2409
+ * {--end--}
2361
2410
  *
2362
- * * *Appium*: supported
2363
2411
  */
2364
2412
  async waitForVisible(locator, sec = null) {
2365
2413
  const aSec = sec || this.options.waitForTimeout;
@@ -2376,14 +2424,15 @@ I.waitForVisible('#popup');
2376
2424
 
2377
2425
  /**
2378
2426
  * Waits for a specified number of elements on the page.
2379
-
2380
- ```js
2381
- I.waitNumberOfVisibleElements('a', 3);
2382
- ```
2383
-
2384
- @param locator element located by CSS|XPath|strict locator.
2385
- @param num number of elements.
2386
- @param sec (optional) time in seconds to wait.
2427
+ *
2428
+ * ```js
2429
+ * I.waitNumberOfVisibleElements('a', 3);
2430
+ * ```
2431
+ *
2432
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2433
+ * @param {number} num number of elements.
2434
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2435
+ * {--end--}
2387
2436
  */
2388
2437
  async waitNumberOfVisibleElements(locator, num, sec = null) {
2389
2438
  const aSec = sec || this.options.waitForTimeout;
@@ -2399,17 +2448,16 @@ I.waitNumberOfVisibleElements('a', 3);
2399
2448
 
2400
2449
  /**
2401
2450
  * Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
2402
- Element can be located by CSS or XPath.
2403
-
2404
- ```
2405
- I.waitForInvisible('#popup');
2406
- ```
2407
-
2408
- @param locator element located by CSS|XPath|strict locator.
2409
- @param sec (optional) time in seconds to wait, 1 by default.
2410
- *
2451
+ * Element can be located by CSS or XPath.
2452
+ *
2453
+ * ```js
2454
+ * I.waitForInvisible('#popup');
2455
+ * ```
2456
+ *
2457
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2458
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2459
+ * {--end--}
2411
2460
  *
2412
- * * *Appium*: supported
2413
2461
  */
2414
2462
  async waitForInvisible(locator, sec = null) {
2415
2463
  const aSec = sec || this.options.waitForTimeout;
@@ -2423,17 +2471,16 @@ I.waitForInvisible('#popup');
2423
2471
 
2424
2472
  /**
2425
2473
  * Waits for an element to hide (by default waits for 1sec).
2426
- Element can be located by CSS or XPath.
2427
-
2428
- ```
2429
- I.waitToHide('#popup');
2430
- ```
2431
-
2432
- @param locator element located by CSS|XPath|strict locator.
2433
- @param sec (optional) time in seconds to wait, 1 by default.
2434
- *
2474
+ * Element can be located by CSS or XPath.
2475
+ *
2476
+ * ```js
2477
+ * I.waitToHide('#popup');
2478
+ * ```
2479
+ *
2480
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2481
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2482
+ * {--end--}
2435
2483
  *
2436
- * * *Appium*: supported
2437
2484
  */
2438
2485
  async waitToHide(locator, sec = null) {
2439
2486
  return this.waitForInvisible(locator, sec);
@@ -2446,17 +2493,16 @@ I.waitToHide('#popup');
2446
2493
 
2447
2494
  /**
2448
2495
  * Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
2449
- Element can be located by CSS or XPath.
2450
-
2451
- ```
2452
- I.waitForDetached('#popup');
2453
- ```
2454
-
2455
- @param locator element located by CSS|XPath|strict locator.
2456
- @param sec (optional) time in seconds to wait, 1 by default.
2457
- *
2496
+ * Element can be located by CSS or XPath.
2497
+ *
2498
+ * ```js
2499
+ * I.waitForDetached('#popup');
2500
+ * ```
2501
+ *
2502
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
2503
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2504
+ * {--end--}
2458
2505
  *
2459
- * * *Appium*: supported
2460
2506
  */
2461
2507
  async waitForDetached(locator, sec = null) {
2462
2508
  const aSec = sec || this.options.waitForTimeout;
@@ -2471,24 +2517,23 @@ I.waitForDetached('#popup');
2471
2517
 
2472
2518
  /**
2473
2519
  * Waits for a function to return true (waits for 1 sec by default).
2474
- Running in browser context.
2475
-
2476
- ```js
2477
- I.waitForFunction(fn[, [args[, timeout]])
2478
- ```
2479
-
2480
- ```js
2481
- I.waitForFunction(() => window.requests == 0);
2482
- I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
2483
- I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
2484
- ```
2485
-
2486
- @param fn to be executed in browser context.
2487
- @param argsOrSec (optional) arguments for function or seconds.
2488
- @param sec (optional) time in seconds to wait, 1 by default.
2489
- *
2520
+ * Running in browser context.
2521
+ *
2522
+ * ```js
2523
+ * I.waitForFunction(fn[, [args[, timeout]])
2524
+ * ```
2525
+ *
2526
+ * ```js
2527
+ * I.waitForFunction(() => window.requests == 0);
2528
+ * I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
2529
+ * I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
2530
+ * ```
2531
+ *
2532
+ * @param {string|function} fn to be executed in browser context.
2533
+ * @param {array|number} argsOrSec (optional, `1` by default) arguments for function or seconds.
2534
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2535
+ * {--end--}
2490
2536
  *
2491
- * * *Appium*: supported
2492
2537
  */
2493
2538
  async waitForFunction(fn, argsOrSec = null, sec = null) {
2494
2539
  let args = [];
@@ -2506,18 +2551,17 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
2506
2551
 
2507
2552
  /**
2508
2553
  * Waits for a function to return true (waits for 1sec by default).
2509
-
2510
- ```js
2511
- I.waitUntil(() => window.requests == 0);
2512
- I.waitUntil(() => window.requests == 0, 5);
2513
- ```
2514
-
2515
- @param fn function which is executed in browser context.
2516
- @param sec (optional) time in seconds to wait, 1 by default.
2517
- @param timeoutMsg (optional) message to show in case of timeout fail.
2554
+ *
2555
+ * ```js
2556
+ * I.waitUntil(() => window.requests == 0);
2557
+ * I.waitUntil(() => window.requests == 0, 5);
2558
+ * ```
2559
+ *
2560
+ * @param {function|string} fn function which is executed in browser context.
2561
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2562
+ * @param {string} [timeoutMsg=''] message to show in case of timeout fail.
2563
+ * {--end--}
2518
2564
  *
2519
- * @param interval (optional) time in seconds between condition checks.
2520
- * * *Appium*: supported
2521
2565
  */
2522
2566
  async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) {
2523
2567
  const aSec = sec || this.options.waitForTimeout;
@@ -2527,11 +2571,15 @@ I.waitUntil(() => window.requests == 0, 5);
2527
2571
 
2528
2572
  /**
2529
2573
  * Switches frame or in case of null locator reverts to parent.
2530
-
2531
- @param locator element located by CSS|XPath|strict locator.
2532
- *
2574
+ *
2575
+ * ```js
2576
+ * I.switchTo('iframe'); // switch to first iframe
2577
+ * I.switchTo(); // switch back to main page
2578
+ * ```
2579
+ *
2580
+ * @param {string|object} locator (optional, `null` by default) element located by CSS|XPath|strict locator.
2581
+ * {--end--}
2533
2582
  *
2534
- * * *Appium*: supported only for web testing
2535
2583
  */
2536
2584
  async switchTo(locator) {
2537
2585
  this.browser.isInsideFrame = true;
@@ -2625,10 +2673,13 @@ I.waitUntil(() => window.requests == 0, 5);
2625
2673
 
2626
2674
  /**
2627
2675
  * Grab number of open tabs.
2628
-
2629
- ```js
2630
- I.grabNumberOfOpenTabs();
2631
- ```
2676
+ *
2677
+ * ```js
2678
+ * let tabs = await I.grabNumberOfOpenTabs();
2679
+ * ```
2680
+ *
2681
+ * @returns {Promise<number>} number of open tabs
2682
+ * {--end--}
2632
2683
  */
2633
2684
  async grabNumberOfOpenTabs() {
2634
2685
  const pages = await this.browser.getWindowHandles();
@@ -2638,11 +2689,11 @@ I.grabNumberOfOpenTabs();
2638
2689
 
2639
2690
  /**
2640
2691
  * Reload the current page.
2641
-
2642
- ```js
2643
- I.refreshPage();
2644
- ```
2645
-
2692
+ *
2693
+ * ```js
2694
+ * I.refreshPage();
2695
+ * ```
2696
+ * {--end--}
2646
2697
  */
2647
2698
  async refreshPage() {
2648
2699
  const client = this.browser;
@@ -2651,10 +2702,11 @@ I.refreshPage();
2651
2702
 
2652
2703
  /**
2653
2704
  * Scroll page to the top.
2654
-
2655
- ```js
2656
- I.scrollPageToTop();
2657
- ```
2705
+ *
2706
+ * ```js
2707
+ * I.scrollPageToTop();
2708
+ * ```
2709
+ * {--end--}
2658
2710
  */
2659
2711
  scrollPageToTop() {
2660
2712
  const client = this.browser;
@@ -2667,10 +2719,11 @@ I.scrollPageToTop();
2667
2719
 
2668
2720
  /**
2669
2721
  * Scroll page to the bottom.
2670
-
2671
- ```js
2672
- I.scrollPageToBottom();
2673
- ```
2722
+ *
2723
+ * ```js
2724
+ * I.scrollPageToBottom();
2725
+ * ```
2726
+ * {--end--}
2674
2727
  */
2675
2728
  scrollPageToBottom() {
2676
2729
  const client = this.browser;
@@ -2688,11 +2741,14 @@ I.scrollPageToBottom();
2688
2741
 
2689
2742
  /**
2690
2743
  * Retrieves a page scroll position and returns it to test.
2691
- Resumes test execution, so **should be used inside an async function with `await`** operator.
2692
-
2693
- ```js
2694
- let { x, y } = await I.grabPageScrollPosition();
2695
- ```
2744
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2745
+ *
2746
+ * ```js
2747
+ * let { x, y } = await I.grabPageScrollPosition();
2748
+ * ```
2749
+ *
2750
+ * @returns {Promise<object>} scroll position
2751
+ * {--end--}
2696
2752
  */
2697
2753
  async grabPageScrollPosition() {
2698
2754
  /* eslint-disable comma-dangle */