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
@@ -13,7 +13,6 @@ const truth = require('../assert/truth').truth;
13
13
  const {
14
14
  xpathLocator,
15
15
  fileExists,
16
- clearString,
17
16
  convertCssPropertiesToCamelCase,
18
17
  screenshotOutputFolder,
19
18
  } = require('../utils');
@@ -25,7 +24,6 @@ const ElementNotFound = require('./errors/ElementNotFound');
25
24
  const ConnectionRefused = require('./errors/ConnectionRefused');
26
25
  const Locator = require('../locator');
27
26
  const path = require('path');
28
- const recorder = require('../recorder');
29
27
 
30
28
  let withinStore = {};
31
29
  let Runner;
@@ -425,15 +423,16 @@ class Protractor extends Helper {
425
423
 
426
424
  /**
427
425
  * Opens a web page in a browser. Requires relative or absolute url.
428
- If url starts with `/`, opens a web page of a site defined in `url` config parameter.
429
-
430
- ```js
431
- I.amOnPage('/'); // opens main page of website
432
- I.amOnPage('https://github.com'); // opens github
433
- I.amOnPage('/login'); // opens a login page
434
- ```
435
-
436
- @param url url path or global url.
426
+ * If url starts with `/`, opens a web page of a site defined in `url` config parameter.
427
+ *
428
+ * ```js
429
+ * I.amOnPage('/'); // opens main page of website
430
+ * I.amOnPage('https://github.com'); // opens github
431
+ * I.amOnPage('/login'); // opens a login page
432
+ * ```
433
+ *
434
+ * @param {string} url url path or global url.
435
+ * {--end--}
437
436
  */
438
437
  async amOnPage(url) {
439
438
  if (!(/^\w+\:\/\//.test(url))) {
@@ -446,29 +445,30 @@ I.amOnPage('/login'); // opens a login page
446
445
 
447
446
  /**
448
447
  * Perform a click on a link or a button, given by a locator.
449
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
450
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
451
- For images, the "alt" attribute and inner text of any parent links are searched.
452
-
453
- The second parameter is a context (CSS or XPath locator) to narrow the search.
454
-
455
- ```js
456
- // simple link
457
- I.click('Logout');
458
- // button of form
459
- I.click('Submit');
460
- // CSS button
461
- I.click('#form input[type=submit]');
462
- // XPath
463
- I.click('//form/*[@type=submit]');
464
- // link in context
465
- I.click('Logout', '#nav');
466
- // using strict locator
467
- I.click({css: 'nav a.login'});
468
- ```
469
-
470
- @param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
471
- @param context (optional) element to search in CSS|XPath|Strict locator.
448
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
449
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
450
+ * For images, the "alt" attribute and inner text of any parent links are searched.
451
+ *
452
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
453
+ *
454
+ * ```js
455
+ * // simple link
456
+ * I.click('Logout');
457
+ * // button of form
458
+ * I.click('Submit');
459
+ * // CSS button
460
+ * I.click('#form input[type=submit]');
461
+ * // XPath
462
+ * I.click('//form/*[@type=submit]');
463
+ * // link in context
464
+ * I.click('Logout', '#nav');
465
+ * // using strict locator
466
+ * I.click({css: 'nav a.login'});
467
+ * ```
468
+ *
469
+ * @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
470
+ * @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
471
+ * {--end--}
472
472
  */
473
473
  async click(locator, context = null) {
474
474
  let matcher = this.browser;
@@ -483,17 +483,18 @@ I.click({css: 'nav a.login'});
483
483
 
484
484
  /**
485
485
  * Performs a double-click on an element matched by link|button|label|CSS or XPath.
486
- Context can be specified as second parameter to narrow search.
487
-
488
- ```js
489
- I.doubleClick('Edit');
490
- I.doubleClick('Edit', '.actions');
491
- I.doubleClick({css: 'button.accept'});
492
- I.doubleClick('.btn.edit');
493
- ```
494
-
495
- @param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
496
- @param context (optional) element to search in CSS|XPath|Strict locator.
486
+ * Context can be specified as second parameter to narrow search.
487
+ *
488
+ * ```js
489
+ * I.doubleClick('Edit');
490
+ * I.doubleClick('Edit', '.actions');
491
+ * I.doubleClick({css: 'button.accept'});
492
+ * I.doubleClick('.btn.edit');
493
+ * ```
494
+ *
495
+ * @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
496
+ * @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
497
+ * {--end--}
497
498
  */
498
499
  async doubleClick(locator, context = null) {
499
500
  let matcher = this.browser;
@@ -508,19 +509,19 @@ I.doubleClick('.btn.edit');
508
509
 
509
510
  /**
510
511
  * Performs right click on a clickable element matched by semantic locator, CSS or XPath.
511
-
512
- ```js
513
- // right click element with id el
514
- I.rightClick('#el');
515
- // right click link or button with text "Click me"
516
- I.rightClick('Click me');
517
- // right click button with text "Click me" inside .context
518
- I.rightClick('Click me', '.context');
519
- ```
520
-
521
- @param locator clickable element located by CSS|XPath|strict locator.
522
- @param context (optional) element located by CSS|XPath|strict locator.
523
-
512
+ *
513
+ * ```js
514
+ * // right click element with id el
515
+ * I.rightClick('#el');
516
+ * // right click link or button with text "Click me"
517
+ * I.rightClick('Click me');
518
+ * // right click button with text "Click me" inside .context
519
+ * I.rightClick('Click me', '.context');
520
+ * ```
521
+ *
522
+ * @param {string|object} locator clickable element located by CSS|XPath|strict locator.
523
+ * @param {string|object} context (optional, `null` by default) element located by CSS|XPath|strict locator.
524
+ * {--end--}
524
525
  */
525
526
  async rightClick(locator, context = null) {
526
527
  /**
@@ -543,16 +544,17 @@ I.rightClick('Click me', '.context');
543
544
 
544
545
  /**
545
546
  * Moves cursor to element matched by locator.
546
- Extra shift can be set with offsetX and offsetY options.
547
-
548
- ```js
549
- I.moveCursorTo('.tooltip');
550
- I.moveCursorTo('#submit', 5,5);
551
- ```
552
-
553
- @param locator located by CSS|XPath|strict locator.
554
- @param offsetX (optional) X-axis offset.
555
- @param offsetY (optional) Y-axis offset.
547
+ * Extra shift can be set with offsetX and offsetY options.
548
+ *
549
+ * ```js
550
+ * I.moveCursorTo('.tooltip');
551
+ * I.moveCursorTo('#submit', 5,5);
552
+ * ```
553
+ *
554
+ * @param {string|object} locator located by CSS|XPath|strict locator.
555
+ * @param {number} offsetX (optional, `0` by default) X-axis offset.
556
+ * @param {number} offsetY (optional, `0` by default) Y-axis offset.
557
+ * {--end--}
556
558
  */
557
559
  async moveCursorTo(locator, offsetX = null, offsetY = null) {
558
560
  let offset = null;
@@ -566,15 +568,16 @@ I.moveCursorTo('#submit', 5,5);
566
568
 
567
569
  /**
568
570
  * Checks that a page contains a visible text.
569
- Use context parameter to narrow down the search.
570
-
571
- ```js
572
- I.see('Welcome'); // text welcome on a page
573
- I.see('Welcome', '.content'); // text inside .content div
574
- I.see('Register', {css: 'form.register'}); // use strict locator
575
- ```
576
- @param text expected on page.
577
- @param context (optional) element located by CSS|Xpath|strict locator in which to search for text.
571
+ * Use context parameter to narrow down the search.
572
+ *
573
+ * ```js
574
+ * I.see('Welcome'); // text welcome on a page
575
+ * I.see('Welcome', '.content'); // text inside .content div
576
+ * I.see('Register', {css: 'form.register'}); // use strict locator
577
+ * ```
578
+ * @param {string} text expected on page.
579
+ * @param {string|object} context (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
580
+ * {--end--}
578
581
  */
579
582
  async see(text, context = null) {
580
583
  return proceedSee.call(this, 'assert', text, context);
@@ -593,13 +596,17 @@ I.see('Register', {css: 'form.register'}); // use strict locator
593
596
 
594
597
  /**
595
598
  * Opposite to `see`. Checks that a text is not present on a page.
596
- Use context parameter to narrow down the search.
597
-
598
- ```js
599
- I.dontSee('Login'); // assume we are already logged in
600
- ```
601
- @param text is not present.
602
- @param context (optional) element located by CSS|XPath|strict locator in which to perfrom search.
599
+ * Use context parameter to narrow down the search.
600
+ *
601
+ * ```js
602
+ * I.dontSee('Login'); // assume we are already logged in.
603
+ * I.dontSee('Login', '.nav'); // no login inside .nav element
604
+ * ```
605
+ *
606
+ * @param {string} text which is not present.
607
+ * @param {string|object} context (optional) element located by CSS|XPath|strict locator in which to perfrom search.
608
+ *
609
+ * {--end--}
603
610
  */
604
611
  dontSee(text, context = null) {
605
612
  return proceedSee.call(this, 'negate', text, context);
@@ -607,12 +614,15 @@ I.dontSee('Login'); // assume we are already logged in
607
614
 
608
615
  /**
609
616
  * Get JS log from browser. Log buffer is reset after each request.
610
- Resumes test execution, so **should be used inside an async function with `await`** operator.
611
-
612
- ```js
613
- let logs = await I.grabBrowserLogs();
614
- console.log(JSON.stringify(logs))
615
- ```
617
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
618
+ *
619
+ * ```js
620
+ * let logs = await I.grabBrowserLogs();
621
+ * console.log(JSON.stringify(logs))
622
+ * ```
623
+ *
624
+ * @returns {Promise<Array>} all browser logs
625
+ * {--end--}
616
626
  */
617
627
  async grabBrowserLogs() {
618
628
  return this.browser.manage().logs().get('browser');
@@ -620,12 +630,15 @@ console.log(JSON.stringify(logs))
620
630
 
621
631
  /**
622
632
  * Get current URL from browser.
623
- Resumes test execution, so should be used inside an async function.
624
-
625
- ```js
626
- let url = await I.grabCurrentUrl();
627
- console.log(`Current URL is [${url}]`);
628
- ```
633
+ * Resumes test execution, so should be used inside an async function.
634
+ *
635
+ * ```js
636
+ * let url = await I.grabCurrentUrl();
637
+ * console.log(`Current URL is [${url}]`);
638
+ * ```
639
+ *
640
+ * @returns {Promise<string>} current URL
641
+ * {--end--}
629
642
  */
630
643
  async grabCurrentUrl() {
631
644
  return this.browser.getCurrentUrl();
@@ -633,25 +646,26 @@ console.log(`Current URL is [${url}]`);
633
646
 
634
647
  /**
635
648
  * Selects an option in a drop-down select.
636
- Field is searched by label | name | CSS | XPath.
637
- Option is selected by visible text or by value.
638
-
639
- ```js
640
- I.selectOption('Choose Plan', 'Monthly'); // select by label
641
- I.selectOption('subscription', 'Monthly'); // match option by text
642
- I.selectOption('subscription', '0'); // or by value
643
- I.selectOption('//form/select[@name=account]','Premium');
644
- I.selectOption('form select[name=account]', 'Premium');
645
- I.selectOption({css: 'form select[name=account]'}, 'Premium');
646
- ```
647
-
648
- Provide an array for the second argument to select multiple options.
649
-
650
- ```js
651
- I.selectOption('Which OS do you use?', ['Android', 'iOS']);
652
- ```
653
- @param select field located by label|name|CSS|XPath|strict locator.
654
- @param option visible text or value of option.
649
+ * Field is searched by label | name | CSS | XPath.
650
+ * Option is selected by visible text or by value.
651
+ *
652
+ * ```js
653
+ * I.selectOption('Choose Plan', 'Monthly'); // select by label
654
+ * I.selectOption('subscription', 'Monthly'); // match option by text
655
+ * I.selectOption('subscription', '0'); // or by value
656
+ * I.selectOption('//form/select[@name=account]','Premium');
657
+ * I.selectOption('form select[name=account]', 'Premium');
658
+ * I.selectOption({css: 'form select[name=account]'}, 'Premium');
659
+ * ```
660
+ *
661
+ * Provide an array for the second argument to select multiple options.
662
+ *
663
+ * ```js
664
+ * I.selectOption('Which OS do you use?', ['Android', 'iOS']);
665
+ * ```
666
+ * @param {string|object} select field located by label|name|CSS|XPath|strict locator.
667
+ * @param {string|array} option visible text or value of option.
668
+ * {--end--}
655
669
  */
656
670
  async selectOption(select, option) {
657
671
  const fields = await findFields(this.browser, select);
@@ -675,21 +689,21 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
675
689
 
676
690
  /**
677
691
  * Fills a text field or textarea, after clearing its value, with the given string.
678
- Field is located by name, label, CSS, or XPath.
679
-
680
- ```js
681
- // by label
682
- I.fillField('Email', 'hello@world.com');
683
- // by name
684
- I.fillField('password', secret('123456'));
685
- // by CSS
686
- I.fillField('form#login input[name=username]', 'John');
687
- // or by strict locator
688
- I.fillField({css: 'form#login input[name=username]'}, 'John');
689
- ```
690
- @param field located by label|name|CSS|XPath|strict locator.
691
- @param value text value to fill.
692
-
692
+ * Field is located by name, label, CSS, or XPath.
693
+ *
694
+ * ```js
695
+ * // by label
696
+ * I.fillField('Email', 'hello@world.com');
697
+ * // by name
698
+ * I.fillField('password', secret('123456'));
699
+ * // by CSS
700
+ * I.fillField('form#login input[name=username]', 'John');
701
+ * // or by strict locator
702
+ * I.fillField({css: 'form#login input[name=username]'}, 'John');
703
+ * ```
704
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
705
+ * @param {string} value text value to fill.
706
+ * {--end--}
693
707
  */
694
708
  async fillField(field, value) {
695
709
  const els = await findFields(this.browser, field);
@@ -699,47 +713,18 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
699
713
 
700
714
  /**
701
715
  * Presses a key on a focused element.
702
- Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
703
- will be replaced with corresponding unicode.
704
- If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
705
-
706
- ```js
707
- I.pressKey('Enter');
708
- I.pressKey(['Control','a']);
709
- ```
710
-
711
- @param key key or array of keys to press.
712
- * [Valid key names](https://w3c.github.io/webdriver/#keyboard-actions) are:
713
-
714
- - `'Add'`,
715
- - `'Alt'`,
716
- - `'ArrowDown'` or `'Down arrow'`,
717
- - `'ArrowLeft'` or `'Left arrow'`,
718
- - `'ArrowRight'` or `'Right arrow'`,
719
- - `'ArrowUp'` or `'Up arrow'`,
720
- - `'Backspace'`,
721
- - `'Command'`,
722
- - `'Control'`,
723
- - `'Del'`,
724
- - `'Divide'`,
725
- - `'End'`,
726
- - `'Enter'`,
727
- - `'Equals'`,
728
- - `'Escape'`,
729
- - `'F1 to F12'`,
730
- - `'Home'`,
731
- - `'Insert'`,
732
- - `'Meta'`,
733
- - `'Multiply'`,
734
- - `'Numpad 0'` to `'Numpad 9'`,
735
- - `'Pagedown'` or `'PageDown'`,
736
- - `'Pageup'` or `'PageUp'`,
737
- - `'Pause'`,
738
- - `'Semicolon'`,
739
- - `'Shift'`,
740
- - `'Space'`,
741
- - `'Subtract'`,
742
- - `'Tab'`.
716
+ * Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
717
+ * will be replaced with corresponding unicode.
718
+ * If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
719
+ *
720
+ * ```js
721
+ * I.pressKey('Enter');
722
+ * I.pressKey(['Control','a']);
723
+ * ```
724
+ *
725
+ * @param {string|array} key key or array of keys to press.
726
+ * {--end--}
727
+ * {{ keys }}
743
728
  */
744
729
  async pressKey(key) {
745
730
  let modifier;
@@ -762,16 +747,17 @@ I.pressKey(['Control','a']);
762
747
 
763
748
  /**
764
749
  * Attaches a file to element located by label, name, CSS or XPath
765
- Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
766
- File will be uploaded to remote system (if tests are running remotely).
767
-
768
- ```js
769
- I.attachFile('Avatar', 'data/avatar.jpg');
770
- I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
771
- ```
772
-
773
- @param locator field located by label|name|CSS|XPath|strict locator.
774
- @param pathToFile local file path relative to codecept.json config file.
750
+ * Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
751
+ * File will be uploaded to remote system (if tests are running remotely).
752
+ *
753
+ * ```js
754
+ * I.attachFile('Avatar', 'data/avatar.jpg');
755
+ * I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
756
+ * ```
757
+ *
758
+ * @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
759
+ * @param {string} pathToFile local file path relative to codecept.json config file.
760
+ * {--end--}
775
761
  */
776
762
  async attachFile(locator, pathToFile) {
777
763
  const file = path.join(global.codecept_dir, pathToFile);
@@ -789,16 +775,17 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
789
775
 
790
776
  /**
791
777
  * Checks that the given input field or textarea equals to given value.
792
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
793
-
794
- ```js
795
- I.seeInField('Username', 'davert');
796
- I.seeInField({css: 'form textarea'},'Type your comment here');
797
- I.seeInField('form input[type=hidden]','hidden_value');
798
- I.seeInField('#searchform input','Search');
799
- ```
800
- @param field located by label|name|CSS|XPath|strict locator.
801
- @param value value to check.
778
+ * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
779
+ *
780
+ * ```js
781
+ * I.seeInField('Username', 'davert');
782
+ * I.seeInField({css: 'form textarea'},'Type your comment here');
783
+ * I.seeInField('form input[type=hidden]','hidden_value');
784
+ * I.seeInField('#searchform input','Search');
785
+ * ```
786
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
787
+ * @param {string} value value to check.
788
+ * {--end--}
802
789
  */
803
790
  async seeInField(field, value) {
804
791
  return proceedSeeInField.call(this, 'assert', field, value);
@@ -806,10 +793,16 @@ I.seeInField('#searchform input','Search');
806
793
 
807
794
  /**
808
795
  * Checks that value of input field or textare doesn't equal to given value
809
- Opposite to `seeInField`.
810
-
811
- @param field located by label|name|CSS|XPath|strict locator.
812
- @param value value to check.
796
+ * Opposite to `seeInField`.
797
+ *
798
+ * ```js
799
+ * I.dontSeeInField('email', 'user@user.com'); // field by name
800
+ * I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
801
+ * ```
802
+ *
803
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
804
+ * @param {string} value value to check.
805
+ * {--end--}
813
806
  */
814
807
  async dontSeeInField(field, value) {
815
808
  return proceedSeeInField.call(this, 'negate', field, value);
@@ -817,13 +810,14 @@ Opposite to `seeInField`.
817
810
 
818
811
  /**
819
812
  * Appends text to a input field or textarea.
820
- Field is located by name, label, CSS or XPath
821
-
822
- ```js
823
- I.appendField('#myTextField', 'appended');
824
- ```
825
- @param field located by label|name|CSS|XPath|strict locator
826
- @param value text value to append.
813
+ * Field is located by name, label, CSS or XPath
814
+ *
815
+ * ```js
816
+ * I.appendField('#myTextField', 'appended');
817
+ * ```
818
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator
819
+ * @param {string} value text value to append.
820
+ * {--end--}
827
821
  */
828
822
  async appendField(field, value) {
829
823
  const els = await findFields(this.browser, field);
@@ -833,13 +827,14 @@ I.appendField('#myTextField', 'appended');
833
827
 
834
828
  /**
835
829
  * Clears a `<textarea>` or text `<input>` element's value.
836
-
837
- ```js
838
- I.clearField('Email');
839
- I.clearField('user[email]');
840
- I.clearField('#email');
841
- ```
842
- @param field located by label|name|CSS|XPath|strict locator.
830
+ *
831
+ * ```js
832
+ * I.clearField('Email');
833
+ * I.clearField('user[email]');
834
+ * I.clearField('#email');
835
+ * ```
836
+ * @param {string|object} editable field located by label|name|CSS|XPath|strict locator.
837
+ * {--end--}
843
838
  */
844
839
  async clearField(field) {
845
840
  const els = await findFields(this.browser, field);
@@ -849,17 +844,18 @@ I.clearField('#email');
849
844
 
850
845
  /**
851
846
  * Selects a checkbox or radio button.
852
- Element is located by label or name or CSS or XPath.
853
-
854
- The second parameter is a context (CSS or XPath locator) to narrow the search.
855
-
856
- ```js
857
- I.checkOption('#agree');
858
- I.checkOption('I Agree to Terms and Conditions');
859
- I.checkOption('agree', '//form');
860
- ```
861
- @param field checkbox located by label | name | CSS | XPath | strict locator.
862
- @param context (optional) element located by CSS | XPath | strict locator.
847
+ * Element is located by label or name or CSS or XPath.
848
+ *
849
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
850
+ *
851
+ * ```js
852
+ * I.checkOption('#agree');
853
+ * I.checkOption('I Agree to Terms and Conditions');
854
+ * I.checkOption('agree', '//form');
855
+ * ```
856
+ * @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
857
+ * @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
858
+ * {--end--}
863
859
  */
864
860
  async checkOption(field, context = null) {
865
861
  let matcher = this.browser;
@@ -875,14 +871,44 @@ I.checkOption('agree', '//form');
875
871
  }
876
872
 
877
873
  /**
878
- * Verifies that the specified checkbox is checked.
874
+ * Unselects a checkbox or radio button.
875
+ * Element is located by label or name or CSS or XPath.
876
+ *
877
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
878
+ *
879
+ * ```js
880
+ * I.uncheckOption('#agree');
881
+ * I.uncheckOption('I Agree to Terms and Conditions');
882
+ * I.uncheckOption('agree', '//form');
883
+ * ```
884
+ * @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
885
+ * @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
886
+ * {--end--}
887
+ */
888
+ async uncheckOption(field, context = null) {
889
+ let matcher = this.browser;
890
+ if (context) {
891
+ const els = await this._locate(context, true);
892
+ assertElementExists(els, context);
893
+ matcher = els[0];
894
+ }
895
+ const els = await findCheckable(matcher, field);
896
+ assertElementExists(els, field, 'Checkbox or radio');
897
+ const isSelected = await els[0].isSelected();
898
+ if (isSelected) return els[0].click();
899
+ }
879
900
 
880
- ```js
881
- I.seeCheckboxIsChecked('Agree');
882
- I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
883
- I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
884
- ```
885
- @param field located by label|name|CSS|XPath|strict locator.
901
+ /**
902
+ * Verifies that the specified checkbox is checked.
903
+ *
904
+ * ```js
905
+ * I.seeCheckboxIsChecked('Agree');
906
+ * I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
907
+ * I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
908
+ * ```
909
+ *
910
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
911
+ * {--end--}
886
912
  */
887
913
  async seeCheckboxIsChecked(field) {
888
914
  return proceedIsChecked.call(this, 'assert', field);
@@ -890,8 +916,15 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
890
916
 
891
917
  /**
892
918
  * Verifies that the specified checkbox is not checked.
893
-
894
- @param field located by label|name|CSS|XPath|strict locator.
919
+ *
920
+ * ```js
921
+ * I.dontSeeeCheckboxIsChedcked('#agree'); // located by ID
922
+ * I.dontSeeeCheckboxIsChedcked('I agree to terms'); // located by label
923
+ * I.dontSeeeCheckboxIsChedcked('agree'); // located by name
924
+ * ```
925
+ *
926
+ * @param {string|object} field located by label|name|CSS|XPath|strict locator.
927
+ * {--end--}
895
928
  */
896
929
  async dontSeeCheckboxIsChecked(field) {
897
930
  return proceedIsChecked.call(this, 'negate', field);
@@ -899,14 +932,16 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
899
932
 
900
933
  /**
901
934
  * Retrieves a text from an element located by CSS or XPath and returns it to test.
902
- Resumes test execution, so **should be used inside async with `await`** operator.
903
-
904
- ```js
905
- let pin = await I.grabTextFrom('#pin');
906
- ```
907
- If multiple elements found returns an array of texts.
908
-
909
- @param locator element located by CSS|XPath|strict locator.
935
+ * Resumes test execution, so **should be used inside async with `await`** operator.
936
+ *
937
+ * ```js
938
+ * let pin = await I.grabTextFrom('#pin');
939
+ * ```
940
+ * If multiple elements found returns an array of texts.
941
+ *
942
+ * @param locator element located by CSS|XPath|strict locator.
943
+ * @returns {Promise<string>} attribute value
944
+ * {--end--}
910
945
  */
911
946
  async grabTextFrom(locator) {
912
947
  const els = await this._locate(locator);
@@ -921,14 +956,16 @@ If multiple elements found returns an array of texts.
921
956
 
922
957
  /**
923
958
  * Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
924
- Resumes test execution, so **should be used inside async function with `await`** operator.
925
- If more than one element is found - an array of HTMLs returned.
926
-
927
- ```js
928
- let postHTML = await I.grabHTMLFrom('#post');
929
- ```
930
-
931
- @param locator element located by CSS|XPath|strict locator.
959
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
960
+ * If more than one element is found - an array of HTMLs returned.
961
+ *
962
+ * ```js
963
+ * let postHTML = await I.grabHTMLFrom('#post');
964
+ * ```
965
+ *
966
+ * @param locator element located by CSS|XPath|strict locator.
967
+ * @returns {Promise<string>} HTML code for an element
968
+ * {--end--}
932
969
  */
933
970
  async grabHTMLFrom(locator) {
934
971
  const els = await this._locate(locator);
@@ -946,12 +983,14 @@ let postHTML = await I.grabHTMLFrom('#post');
946
983
 
947
984
  /**
948
985
  * Retrieves a value from a form element located by CSS or XPath and returns it to test.
949
- Resumes test execution, so **should be used inside async function with `await`** operator.
950
-
951
- ```js
952
- let email = await I.grabValueFrom('input[name=email]');
953
- ```
954
- @param locator field located by label|name|CSS|XPath|strict locator.
986
+ * Resumes test execution, so **should be used inside async function with `await`** operator.
987
+ *
988
+ * ```js
989
+ * let email = await I.grabValueFrom('input[name=email]');
990
+ * ```
991
+ * @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
992
+ * @returns {Promise<string>} attribute value
993
+ * {--end--}
955
994
  */
956
995
  async grabValueFrom(locator) {
957
996
  const els = await findFields(this.browser, locator);
@@ -961,14 +1000,16 @@ let email = await I.grabValueFrom('input[name=email]');
961
1000
 
962
1001
  /**
963
1002
  * Grab CSS property for given locator
964
- Resumes test execution, so **should be used inside an async function with `await`** operator.
965
-
966
- ```js
967
- const value = await I.grabCssPropertyFrom('h3', 'font-weight');
968
- ```
969
-
970
- @param locator element located by CSS|XPath|strict locator.
971
- @param cssProperty CSS property name.
1003
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
1004
+ *
1005
+ * ```js
1006
+ * const value = await I.grabCssPropertyFrom('h3', 'font-weight');
1007
+ * ```
1008
+ *
1009
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1010
+ * @param {string} cssProperty CSS property name.
1011
+ * @returns {Promise<string>} CSS value
1012
+ * {--end--}
972
1013
  */
973
1014
  async grabCssPropertyFrom(locator, cssProperty) {
974
1015
  const els = await this._locate(locator, true);
@@ -983,14 +1024,16 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
983
1024
 
984
1025
  /**
985
1026
  * Retrieves an attribute from an element located by CSS or XPath and returns it to test.
986
- An array as a result will be returned if there are more than one matched element.
987
- Resumes test execution, so **should be used inside async with `await`** operator.
988
-
989
- ```js
990
- let hint = await I.grabAttributeFrom('#tooltip', 'title');
991
- ```
992
- @param locator element located by CSS|XPath|strict locator.
993
- @param attr attribute name.
1027
+ * An array as a result will be returned if there are more than one matched element.
1028
+ * Resumes test execution, so **should be used inside async with `await`** operator.
1029
+ *
1030
+ * ```js
1031
+ * let hint = await I.grabAttributeFrom('#tooltip', 'title');
1032
+ * ```
1033
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1034
+ * @param {string} attr attribute name.
1035
+ * @returns {Promise<string>} attribute value
1036
+ * {--end--}
994
1037
  */
995
1038
  async grabAttributeFrom(locator, attr) {
996
1039
  const els = await this._locate(locator);
@@ -1005,8 +1048,13 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1005
1048
  }
1006
1049
  /**
1007
1050
  * Checks that title contains text.
1008
-
1009
- @param text text value to check.
1051
+ *
1052
+ * ```js
1053
+ * I.seeInTitle('Home Page');
1054
+ * ```
1055
+ *
1056
+ * @param {string} text text value to check.
1057
+ * {--end--}
1010
1058
  */
1011
1059
  async seeInTitle(text) {
1012
1060
  return this.browser.getTitle().then(title => stringIncludes('web page title').assert(text, title));
@@ -1026,8 +1074,13 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1026
1074
 
1027
1075
  /**
1028
1076
  * Checks that title does not contain text.
1029
-
1030
- @param text text value to check.
1077
+ *
1078
+ * ```js
1079
+ * I.dontSeeInTitle('Error');
1080
+ * ```
1081
+ *
1082
+ * @param {string} text value to check.
1083
+ * {--end--}
1031
1084
  */
1032
1085
  async dontSeeInTitle(text) {
1033
1086
  return this.browser.getTitle().then(title => stringIncludes('web page title').negate(text, title));
@@ -1035,11 +1088,14 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
1035
1088
 
1036
1089
  /**
1037
1090
  * Retrieves a page title and returns it to test.
1038
- Resumes test execution, so **should be used inside async with `await`** operator.
1039
-
1040
- ```js
1041
- let title = await I.grabTitle();
1042
- ```
1091
+ * Resumes test execution, so **should be used inside async with `await`** operator.
1092
+ *
1093
+ * ```js
1094
+ * let title = await I.grabTitle();
1095
+ * ```
1096
+ *
1097
+ * @returns {Promise<string>} title
1098
+ * {--end--}
1043
1099
  */
1044
1100
  async grabTitle() {
1045
1101
  return this.browser.getTitle().then((title) => {
@@ -1050,12 +1106,13 @@ let title = await I.grabTitle();
1050
1106
 
1051
1107
  /**
1052
1108
  * Checks that a given Element is visible
1053
- Element is located by CSS or XPath.
1054
-
1055
- ```js
1056
- I.seeElement('#modal');
1057
- ```
1058
- @param locator located by CSS|XPath|strict locator.
1109
+ * Element is located by CSS or XPath.
1110
+ *
1111
+ * ```js
1112
+ * I.seeElement('#modal');
1113
+ * ```
1114
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1115
+ * {--end--}
1059
1116
  */
1060
1117
  async seeElement(locator) {
1061
1118
  let els = await this._locate(locator, true);
@@ -1065,8 +1122,13 @@ I.seeElement('#modal');
1065
1122
 
1066
1123
  /**
1067
1124
  * Opposite to `seeElement`. Checks that element is not visible (or in DOM)
1068
-
1069
- @param locator located by CSS|XPath|Strict locator.
1125
+ *
1126
+ * ```js
1127
+ * I.dontSeeElement('.modal'); // modal is not shown
1128
+ * ```
1129
+ *
1130
+ * @param {string|object} locator located by CSS|XPath|Strict locator.
1131
+ * {--end--}
1070
1132
  */
1071
1133
  async dontSeeElement(locator) {
1072
1134
  let els = await this._locate(locator, false);
@@ -1076,12 +1138,13 @@ I.seeElement('#modal');
1076
1138
 
1077
1139
  /**
1078
1140
  * Checks that a given Element is present in the DOM
1079
- Element is located by CSS or XPath.
1080
-
1081
- ```js
1082
- I.seeElementInDOM('#modal');
1083
- ```
1084
- @param locator located by CSS|XPath|strict locator.
1141
+ * Element is located by CSS or XPath.
1142
+ *
1143
+ * ```js
1144
+ * I.seeElementInDOM('#modal');
1145
+ * ```
1146
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1147
+ * {--end--}
1085
1148
  */
1086
1149
  async seeElementInDOM(locator) {
1087
1150
  return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').negate(els.fill('ELEMENT')));
@@ -1089,8 +1152,13 @@ I.seeElementInDOM('#modal');
1089
1152
 
1090
1153
  /**
1091
1154
  * Opposite to `seeElementInDOM`. Checks that element is not on page.
1092
-
1093
- @param locator located by CSS|XPath|Strict locator.
1155
+ *
1156
+ * ```js
1157
+ * I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
1158
+ * ```
1159
+ *
1160
+ * @param {string|object} locator located by CSS|XPath|Strict locator.
1161
+ * {--end--}
1094
1162
  */
1095
1163
  async dontSeeElementInDOM(locator) {
1096
1164
  return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').assert(els.fill('ELEMENT')));
@@ -1098,11 +1166,12 @@ I.seeElementInDOM('#modal');
1098
1166
 
1099
1167
  /**
1100
1168
  * Checks that the current page contains the given string in its raw source code.
1101
-
1102
- ```js
1103
- I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1104
- ```
1105
- @param text value to check.
1169
+ *
1170
+ * ```js
1171
+ * I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1172
+ * ```
1173
+ * @param {string} text value to check.
1174
+ * {--end--}
1106
1175
  */
1107
1176
  async seeInSource(text) {
1108
1177
  return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').assert(text, source));
@@ -1110,11 +1179,14 @@ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1110
1179
 
1111
1180
  /**
1112
1181
  * Retrieves page source and returns it to test.
1113
- Resumes test execution, so should be used inside an async function.
1114
-
1115
- ```js
1116
- let pageSource = await I.grabSource();
1117
- ```
1182
+ * Resumes test execution, so should be used inside an async function.
1183
+ *
1184
+ * ```js
1185
+ * let pageSource = await I.grabSource();
1186
+ * ```
1187
+ *
1188
+ * @returns {Promise<string>} source code
1189
+ * {--end--}
1118
1190
  */
1119
1191
  async grabSource() {
1120
1192
  return this.browser.getPageSource();
@@ -1122,37 +1194,47 @@ let pageSource = await I.grabSource();
1122
1194
 
1123
1195
  /**
1124
1196
  * Checks that the current page does not contains the given string in its raw source code.
1125
-
1126
- @param text value to check.
1127
-
1197
+ *
1198
+ * ```js
1199
+ * I.dontSeeInSource('<!--'); // no comments in source
1200
+ * ```
1201
+ *
1202
+ * @param {string} value to check.
1203
+ * {--end--}
1128
1204
  */
1129
1205
  async dontSeeInSource(text) {
1130
1206
  return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').negate(text, source));
1131
1207
  }
1132
1208
 
1133
1209
  /**
1134
- * asserts that an element appears a given number of times in the DOM
1210
+ * Asserts that an element appears a given number of times in the DOM.
1135
1211
  * Element is located by label or name or CSS or XPath.
1136
- *
1212
+ *
1213
+ *
1137
1214
  * ```js
1138
1215
  * I.seeNumberOfElements('#submitBtn', 1);
1139
1216
  * ```
1217
+ *
1218
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1219
+ * @param {number} num number of elements.
1220
+ * {--end--}
1140
1221
  */
1141
- async seeNumberOfElements(selector, num) {
1142
- const elements = await this._locate(selector);
1143
- return equals(`expected number of elements (${selector}) is ${num}, but found ${elements.length}`).assert(elements.length, num);
1222
+ async seeNumberOfElements(locator, num) {
1223
+ const elements = await this._locate(locator);
1224
+ return equals(`expected number of elements (${locator}) is ${num}, but found ${elements.length}`).assert(elements.length, num);
1144
1225
  }
1145
1226
 
1146
1227
  /**
1147
1228
  * Asserts that an element is visible a given number of times.
1148
- Element is located by CSS or XPath.
1149
-
1150
- ```js
1151
- I.seeNumberOfVisibleElements('.buttons', 3);
1152
- ```
1153
-
1154
- @param locator element located by CSS|XPath|strict locator.
1155
- @param num number of elements.
1229
+ * Element is located by CSS or XPath.
1230
+ *
1231
+ * ```js
1232
+ * I.seeNumberOfVisibleElements('.buttons', 3);
1233
+ * ```
1234
+ *
1235
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1236
+ * @param {number} num number of elements.
1237
+ * {--end--}
1156
1238
  */
1157
1239
  async seeNumberOfVisibleElements(locator, num) {
1158
1240
  const res = await this.grabNumberOfVisibleElements(locator);
@@ -1161,12 +1243,14 @@ I.seeNumberOfVisibleElements('.buttons', 3);
1161
1243
 
1162
1244
  /**
1163
1245
  * Grab number of visible elements by locator.
1164
-
1165
- ```js
1166
- I.grabNumberOfVisibleElements('p');
1167
- ```
1168
-
1169
- @param locator located by CSS|XPath|strict locator.
1246
+ *
1247
+ * ```js
1248
+ * let numOfElements = await I.grabNumberOfVisibleElements('p');
1249
+ * ```
1250
+ *
1251
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1252
+ * @returns {Promise<number>} number of visible elements
1253
+ * {--end--}
1170
1254
  */
1171
1255
  async grabNumberOfVisibleElements(locator) {
1172
1256
  let els = await this._locate(locator);
@@ -1176,13 +1260,14 @@ I.grabNumberOfVisibleElements('p');
1176
1260
 
1177
1261
  /**
1178
1262
  * Checks that all elements with given locator have given CSS properties.
1179
-
1180
- ```js
1181
- I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1182
- ```
1183
-
1184
- @param locator located by CSS|XPath|strict locator.
1185
- @param cssProperties object with CSS properties and their values to check.
1263
+ *
1264
+ * ```js
1265
+ * I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1266
+ * ```
1267
+ *
1268
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1269
+ * @param {object} cssProperties object with CSS properties and their values to check.
1270
+ * {--end--}
1186
1271
  */
1187
1272
  async seeCssPropertiesOnElements(locator, cssProperties) {
1188
1273
  const els = await this._locate(locator);
@@ -1214,13 +1299,14 @@ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1214
1299
 
1215
1300
  /**
1216
1301
  * Checks that all elements with given locator have given attributes.
1217
-
1218
- ```js
1219
- I.seeAttributesOnElements('//form', {'method': "post"});
1220
- ```
1221
-
1222
- @param locator located by CSS|XPath|strict locator.
1223
- @param attributes object with attributes and their values to check.
1302
+ *
1303
+ * ```js
1304
+ * I.seeAttributesOnElements('//form', { method: "post"});
1305
+ * ```
1306
+ *
1307
+ * @param {string|object} locator located by CSS|XPath|strict locator.
1308
+ * @param {object} attributes attributes and their values to check.
1309
+ * {--end--}
1224
1310
  */
1225
1311
  async seeAttributesOnElements(locator, attributes) {
1226
1312
  const els = await this._locate(locator);
@@ -1248,30 +1334,31 @@ I.seeAttributesOnElements('//form', {'method': "post"});
1248
1334
 
1249
1335
  /**
1250
1336
  * Executes sync script on a page.
1251
- Pass arguments to function as additional parameters.
1252
- Will return execution result to a test.
1253
- In this case you should use async function and await to receive results.
1254
-
1255
- Example with jQuery DatePicker:
1256
-
1257
- ```js
1258
- // change date of jQuery DatePicker
1259
- I.executeScript(function() {
1260
- // now we are inside browser context
1261
- $('date').datetimepicker('setDate', new Date());
1262
- });
1263
- ```
1264
- Can return values. Don't forget to use `await` to get them.
1265
-
1266
- ```js
1267
- let date = await I.executeScript(function(el) {
1268
- // only basic types can be returned
1269
- return $(el).datetimepicker('getDate').toString();
1270
- }, '#date'); // passing jquery selector
1271
- ```
1272
-
1273
- @param fn function to be executed in browser context.
1274
- @param ...args args to be passed to function.
1337
+ * Pass arguments to function as additional parameters.
1338
+ * Will return execution result to a test.
1339
+ * In this case you should use async function and await to receive results.
1340
+ *
1341
+ * Example with jQuery DatePicker:
1342
+ *
1343
+ * ```js
1344
+ * // change date of jQuery DatePicker
1345
+ * I.executeScript(function() {
1346
+ * // now we are inside browser context
1347
+ * $('date').datetimepicker('setDate', new Date());
1348
+ * });
1349
+ * ```
1350
+ * Can return values. Don't forget to use `await` to get them.
1351
+ *
1352
+ * ```js
1353
+ * let date = await I.executeScript(function(el) {
1354
+ * // only basic types can be returned
1355
+ * return $(el).datetimepicker('getDate').toString();
1356
+ * }, '#date'); // passing jquery selector
1357
+ * ```
1358
+ *
1359
+ * @param {string|function} fn function to be executed in browser context.
1360
+ * @param ...args args to be passed to function.
1361
+ * {--end--}
1275
1362
  */
1276
1363
  async executeScript(fn) {
1277
1364
  return this.browser.executeScript.apply(this.browser, arguments);
@@ -1279,28 +1366,29 @@ let date = await I.executeScript(function(el) {
1279
1366
 
1280
1367
  /**
1281
1368
  * Executes async script on page.
1282
- Provided function should execute a passed callback (as first argument) to signal it is finished.
1283
-
1284
- Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
1285
-
1286
- ```js
1287
- I.executeAsyncScript(function(done) {
1288
- Vue.nextTick(done); // waiting for next tick
1289
- });
1290
- ```
1291
-
1292
- By passing value to `done()` function you can return values.
1293
- Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
1294
-
1295
- ```js
1296
- let val = await I.executeAsyncScript(function(url, done) {
1297
- // in browser context
1298
- $.ajax(url, { success: (data) => done(data); }
1299
- }, 'http://ajax.callback.url/');
1300
- ```
1301
-
1302
- @param fn function to be executed in browser context.
1303
- @param ...args args to be passed to function.
1369
+ * Provided function should execute a passed callback (as first argument) to signal it is finished.
1370
+ *
1371
+ * Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
1372
+ *
1373
+ * ```js
1374
+ * I.executeAsyncScript(function(done) {
1375
+ * Vue.nextTick(done); // waiting for next tick
1376
+ * });
1377
+ * ```
1378
+ *
1379
+ * By passing value to `done()` function you can return values.
1380
+ * Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
1381
+ *
1382
+ * ```js
1383
+ * let val = await I.executeAsyncScript(function(url, done) {
1384
+ * // in browser context
1385
+ * $.ajax(url, { success: (data) => done(data); }
1386
+ * }, 'http://ajax.callback.url/');
1387
+ * ```
1388
+ *
1389
+ * @param {string|function} fn function to be executed in browser context.
1390
+ * @param ...args args to be passed to function.
1391
+ * {--end--}
1304
1392
  */
1305
1393
  async executeAsyncScript(fn) {
1306
1394
  this.browser.manage().timeouts().setScriptTimeout(this.options.scriptTimeout);
@@ -1309,12 +1397,13 @@ let val = await I.executeAsyncScript(function(url, done) {
1309
1397
 
1310
1398
  /**
1311
1399
  * Checks that current url contains a provided fragment.
1312
-
1313
- ```js
1314
- I.seeInCurrentUrl('/register'); // we are on registration page
1315
- ```
1316
-
1317
- @param url value to check.
1400
+ *
1401
+ * ```js
1402
+ * I.seeInCurrentUrl('/register'); // we are on registration page
1403
+ * ```
1404
+ *
1405
+ * @param {string} url a fragment to check
1406
+ * {--end--}
1318
1407
  */
1319
1408
  async seeInCurrentUrl(url) {
1320
1409
  return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').assert(url, currentUrl));
@@ -1322,8 +1411,9 @@ I.seeInCurrentUrl('/register'); // we are on registration page
1322
1411
 
1323
1412
  /**
1324
1413
  * Checks that current url does not contain a provided fragment.
1325
-
1326
- @param url value to check.
1414
+ *
1415
+ * @param {string} url value to check.
1416
+ * {--end--}
1327
1417
  */
1328
1418
  async dontSeeInCurrentUrl(url) {
1329
1419
  return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').negate(url, currentUrl));
@@ -1331,15 +1421,16 @@ I.seeInCurrentUrl('/register'); // we are on registration page
1331
1421
 
1332
1422
  /**
1333
1423
  * Checks that current url is equal to provided one.
1334
- If a relative url provided, a configured url will be prepended to it.
1335
- So both examples will work:
1336
-
1337
- ```js
1338
- I.seeCurrentUrlEquals('/register');
1339
- I.seeCurrentUrlEquals('http://my.site.com/register');
1340
- ```
1341
-
1342
- @param url value to check.
1424
+ * If a relative url provided, a configured url will be prepended to it.
1425
+ * So both examples will work:
1426
+ *
1427
+ * ```js
1428
+ * I.seeCurrentUrlEquals('/register');
1429
+ * I.seeCurrentUrlEquals('http://my.site.com/register');
1430
+ * ```
1431
+ *
1432
+ * @param {string} url value to check.
1433
+ * {--end--}
1343
1434
  */
1344
1435
  async seeCurrentUrlEquals(url) {
1345
1436
  return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).assert(url, currentUrl));
@@ -1347,9 +1438,15 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
1347
1438
 
1348
1439
  /**
1349
1440
  * Checks that current url is not equal to provided one.
1350
- If a relative url provided, a configured url will be prepended to it.
1351
-
1352
- @param url value to check.
1441
+ * If a relative url provided, a configured url will be prepended to it.
1442
+ *
1443
+ * ```js
1444
+ * I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
1445
+ * I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
1446
+ * ```
1447
+ *
1448
+ * @param {string} url value to check.
1449
+ * {--end--}
1353
1450
  */
1354
1451
  async dontSeeCurrentUrlEquals(url) {
1355
1452
  return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).negate(url, currentUrl));
@@ -1357,16 +1454,17 @@ If a relative url provided, a configured url will be prepended to it.
1357
1454
 
1358
1455
  /**
1359
1456
  * Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
1360
- Filename is relative to output folder.
1361
- 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.
1362
-
1363
- ```js
1364
- I.saveScreenshot('debug.png');
1365
- I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1366
- ```
1367
-
1368
- @param fileName file name to save.
1369
- @param fullPage (optional) flag to enable fullscreen screenshot mode.
1457
+ * Filename is relative to output folder.
1458
+ * 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.
1459
+ *
1460
+ * ```js
1461
+ * I.saveScreenshot('debug.png');
1462
+ * I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1463
+ * ```
1464
+ *
1465
+ * @param {string} fileName file name to save.
1466
+ * @param {boolean} fullPage (optional, `false` by default) flag to enable fullscreen screenshot mode.
1467
+ * {--end--}
1370
1468
  */
1371
1469
  async saveScreenshot(fileName, fullPage = false) {
1372
1470
  const outputFile = screenshotOutputFolder(fileName);
@@ -1400,14 +1498,15 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
1400
1498
 
1401
1499
  /**
1402
1500
  * Clears a cookie by name,
1403
- if none provided clears all cookies.
1404
-
1405
- ```js
1406
- I.clearCookie();
1407
- I.clearCookie('test');
1408
- ```
1409
-
1410
- @param cookie (optional) cookie name.
1501
+ * if none provided clears all cookies.
1502
+ *
1503
+ * ```js
1504
+ * I.clearCookie();
1505
+ * I.clearCookie('test');
1506
+ * ```
1507
+ *
1508
+ * @param {string} cookie (optional, `null` by default) cookie name
1509
+ * {--end--}
1411
1510
  */
1412
1511
  async clearCookie(cookie = null) {
1413
1512
  if (!cookie) {
@@ -1418,12 +1517,13 @@ I.clearCookie('test');
1418
1517
 
1419
1518
  /**
1420
1519
  * Checks that cookie with given name exists.
1421
-
1422
- ```js
1423
- I.seeCookie('Auth');
1424
- ```
1425
-
1426
- @param name cookie name.
1520
+ *
1521
+ * ```js
1522
+ * I.seeCookie('Auth');
1523
+ * ```
1524
+ *
1525
+ * @param {string} name cookie name.
1526
+ * {--end--}
1427
1527
  */
1428
1528
  async seeCookie(name) {
1429
1529
  return this.browser.manage().getCookie(name).then(res => truth(`cookie ${name}`, 'to be set').assert(res));
@@ -1431,8 +1531,13 @@ I.seeCookie('Auth');
1431
1531
 
1432
1532
  /**
1433
1533
  * Checks that cookie with given name does not exist.
1434
-
1435
- @param name cookie name.
1534
+ *
1535
+ * ```js
1536
+ * I.dontSeeCookie('auth'); // no auth cookie
1537
+ * ```
1538
+ *
1539
+ * @param {string} name cookie name.
1540
+ * {--end--}
1436
1541
  */
1437
1542
  async dontSeeCookie(name) {
1438
1543
  return this.browser.manage().getCookie(name).then(res => truth(`cookie ${name}`, 'to be set').negate(res));
@@ -1440,19 +1545,22 @@ I.seeCookie('Auth');
1440
1545
 
1441
1546
  /**
1442
1547
  * Gets a cookie object by name.
1443
- If none provided gets all cookies.
1444
- * Resumes test execution, so **should be used inside async with `await`** operator.
1445
-
1446
- ```js
1447
- let cookie = await I.grabCookie('auth');
1448
- assert(cookie.value, '123456');
1449
- ```
1450
-
1451
- @param name (optional) cookie name.
1548
+ * If none provided gets all cookies.
1549
+ * * Resumes test execution, so **should be used inside async with `await`** operator.
1550
+ *
1551
+ * ```js
1552
+ * let cookie = await I.grabCookie('auth');
1553
+ * assert(cookie.value, '123456');
1554
+ * ```
1555
+ *
1556
+ * @param [name=null] cookie name.
1557
+ * @returns {Promise<string>} attribute value
1558
+ * {--end--}
1452
1559
  *
1453
1560
  * Returns cookie in JSON [format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
1454
1561
  */
1455
1562
  async grabCookie(name) {
1563
+ if (!name) return this.browser.manage().getCookies();
1456
1564
  return this.browser.manage().getCookie(name);
1457
1565
  }
1458
1566
 
@@ -1510,10 +1618,11 @@ assert(cookie.value, '123456');
1510
1618
 
1511
1619
  /**
1512
1620
  * Resize the current window to provided width and height.
1513
- First parameter can be set to `maximize`.
1514
-
1515
- @param width width in pixels or `maximize`.
1516
- @param height height in pixels.
1621
+ * First parameter can be set to `maximize`.
1622
+ *
1623
+ * @param {number} width width in pixels or `maximize`.
1624
+ * @param {number} height height in pixels.
1625
+ * {--end--}
1517
1626
  */
1518
1627
  async resizeWindow(width, height) {
1519
1628
  if (width === 'maximize') {
@@ -1525,13 +1634,14 @@ First parameter can be set to `maximize`.
1525
1634
 
1526
1635
  /**
1527
1636
  * Drag an item to a destination element.
1528
-
1529
- ```js
1530
- I.dragAndDrop('#dragHandle', '#container');
1531
- ```
1532
-
1533
- @param srcElement located by CSS|XPath|strict locator.
1534
- @param destElement located by CSS|XPath|strict locator.
1637
+ *
1638
+ * ```js
1639
+ * I.dragAndDrop('#dragHandle', '#container');
1640
+ * ```
1641
+ *
1642
+ * @param {string|object} srcElement located by CSS|XPath|strict locator.
1643
+ * @param {string|object} destElement located by CSS|XPath|strict locator.
1644
+ * {--end--}
1535
1645
  */
1536
1646
  async dragAndDrop(srcElement, destElement) {
1537
1647
  const srcEl = await this._locate(srcElement, true);
@@ -1651,10 +1761,13 @@ I.dragAndDrop('#dragHandle', '#container');
1651
1761
 
1652
1762
  /**
1653
1763
  * Grab number of open tabs.
1654
-
1655
- ```js
1656
- I.grabNumberOfOpenTabs();
1657
- ```
1764
+ *
1765
+ * ```js
1766
+ * let tabs = await I.grabNumberOfOpenTabs();
1767
+ * ```
1768
+ *
1769
+ * @returns {Promise<number>} number of open tabs
1770
+ * {--end--}
1658
1771
  */
1659
1772
  async grabNumberOfOpenTabs() {
1660
1773
  const pages = await this.browser.getAllWindowHandles();
@@ -1663,8 +1776,14 @@ I.grabNumberOfOpenTabs();
1663
1776
 
1664
1777
  /**
1665
1778
  * Switches frame or in case of null locator reverts to parent.
1666
-
1667
- @param locator element located by CSS|XPath|strict locator.
1779
+ *
1780
+ * ```js
1781
+ * I.switchTo('iframe'); // switch to first iframe
1782
+ * I.switchTo(); // switch back to main page
1783
+ * ```
1784
+ *
1785
+ * @param {string|object} locator (optional, `null` by default) element located by CSS|XPath|strict locator.
1786
+ * {--end--}
1668
1787
  */
1669
1788
  async switchTo(locator) {
1670
1789
  if (Number.isInteger(locator)) {
@@ -1680,13 +1799,13 @@ I.grabNumberOfOpenTabs();
1680
1799
 
1681
1800
  /**
1682
1801
  * Pauses execution for a number of seconds.
1683
-
1684
- ```js
1685
- I.wait(2); // wait 2 secs
1686
- ```
1687
-
1688
- @param sec number of second to wait.
1689
- @param sec time in seconds to wait.
1802
+ *
1803
+ * ```js
1804
+ * I.wait(2); // wait 2 secs
1805
+ * ```
1806
+ *
1807
+ * @param {number} sec number of second to wait.
1808
+ * {--end--}
1690
1809
  */
1691
1810
  wait(sec) {
1692
1811
  return this.browser.sleep(sec * 1000);
@@ -1695,15 +1814,16 @@ I.wait(2); // wait 2 secs
1695
1814
 
1696
1815
  /**
1697
1816
  * Waits for element to be present on page (by default waits for 1sec).
1698
- Element can be located by CSS or XPath.
1699
-
1700
- ```js
1701
- I.waitForElement('.btn.continue');
1702
- I.waitForElement('.btn.continue', 5); // wait for 5 secs
1703
- ```
1704
-
1705
- @param locator element located by CSS|XPath|strict locator.
1706
- @param sec (optional) time in seconds to wait, 1 by default.
1817
+ * Element can be located by CSS or XPath.
1818
+ *
1819
+ * ```js
1820
+ * I.waitForElement('.btn.continue');
1821
+ * I.waitForElement('.btn.continue', 5); // wait for 5 secs
1822
+ * ```
1823
+ *
1824
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1825
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1826
+ * {--end--}
1707
1827
  */
1708
1828
  async waitForElement(locator, sec = null) {
1709
1829
  const aSec = sec || this.options.waitForTimeout;
@@ -1720,14 +1840,15 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
1720
1840
 
1721
1841
  /**
1722
1842
  * Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
1723
- Element can be located by CSS or XPath.
1724
-
1725
- ```
1726
- I.waitForDetached('#popup');
1727
- ```
1728
-
1729
- @param locator element located by CSS|XPath|strict locator.
1730
- @param sec (optional) time in seconds to wait, 1 by default.
1843
+ * Element can be located by CSS or XPath.
1844
+ *
1845
+ * ```js
1846
+ * I.waitForDetached('#popup');
1847
+ * ```
1848
+ *
1849
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1850
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1851
+ * {--end--}
1731
1852
  */
1732
1853
  async waitForDetached(locator, sec = null) {
1733
1854
  const aSec = sec || this.options.waitForTimeout;
@@ -1754,14 +1875,15 @@ I.waitForDetached('#popup');
1754
1875
 
1755
1876
  /**
1756
1877
  * Waits for an element to become visible on a page (by default waits for 1sec).
1757
- Element can be located by CSS or XPath.
1758
-
1759
- ```
1760
- I.waitForVisible('#popup');
1761
- ```
1762
-
1763
- @param locator element located by CSS|XPath|strict locator.
1764
- @param sec (optional) time in seconds to wait, 1 by default.
1878
+ * Element can be located by CSS or XPath.
1879
+ *
1880
+ * ```js
1881
+ * I.waitForVisible('#popup');
1882
+ * ```
1883
+ *
1884
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1885
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1886
+ * {--end--}
1765
1887
  */
1766
1888
  async waitForVisible(locator, sec = null) {
1767
1889
  const aSec = sec || this.options.waitForTimeout;
@@ -1771,14 +1893,15 @@ I.waitForVisible('#popup');
1771
1893
 
1772
1894
  /**
1773
1895
  * Waits for an element to hide (by default waits for 1sec).
1774
- Element can be located by CSS or XPath.
1775
-
1776
- ```
1777
- I.waitToHide('#popup');
1778
- ```
1779
-
1780
- @param locator element located by CSS|XPath|strict locator.
1781
- @param sec (optional) time in seconds to wait, 1 by default.
1896
+ * Element can be located by CSS or XPath.
1897
+ *
1898
+ * ```js
1899
+ * I.waitToHide('#popup');
1900
+ * ```
1901
+ *
1902
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1903
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1904
+ * {--end--}
1782
1905
  */
1783
1906
  async waitToHide(locator, sec = null) {
1784
1907
  return this.waitForInvisible(locator, sec);
@@ -1786,14 +1909,15 @@ I.waitToHide('#popup');
1786
1909
 
1787
1910
  /**
1788
1911
  * Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1789
- Element can be located by CSS or XPath.
1790
-
1791
- ```
1792
- I.waitForInvisible('#popup');
1793
- ```
1794
-
1795
- @param locator element located by CSS|XPath|strict locator.
1796
- @param sec (optional) time in seconds to wait, 1 by default.
1912
+ * Element can be located by CSS or XPath.
1913
+ *
1914
+ * ```js
1915
+ * I.waitForInvisible('#popup');
1916
+ * ```
1917
+ *
1918
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1919
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1920
+ * {--end--}
1797
1921
  */
1798
1922
  async waitForInvisible(locator, sec = null) {
1799
1923
  const aSec = sec || this.options.waitForTimeout;
@@ -1810,14 +1934,15 @@ I.waitForInvisible('#popup');
1810
1934
 
1811
1935
  /**
1812
1936
  * Waits for a specified number of elements on the page.
1813
-
1814
- ```js
1815
- I.waitNumberOfVisibleElements('a', 3);
1816
- ```
1817
-
1818
- @param locator element located by CSS|XPath|strict locator.
1819
- @param num number of elements.
1820
- @param sec (optional) time in seconds to wait.
1937
+ *
1938
+ * ```js
1939
+ * I.waitNumberOfVisibleElements('a', 3);
1940
+ * ```
1941
+ *
1942
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1943
+ * @param {number} num number of elements.
1944
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1945
+ * {--end--}
1821
1946
  */
1822
1947
  async waitNumberOfVisibleElements(locator, num, sec = null) {
1823
1948
  function visibilityCountOf(loc, expectedCount) {
@@ -1840,10 +1965,11 @@ I.waitNumberOfVisibleElements('a', 3);
1840
1965
 
1841
1966
  /**
1842
1967
  * Waits for element to become enabled (by default waits for 1sec).
1843
- Element can be located by CSS or XPath.
1844
-
1845
- @param locator element located by CSS|XPath|strict locator.
1846
- @param sec (optional) time in seconds to wait, 1 by default.
1968
+ * Element can be located by CSS or XPath.
1969
+ *
1970
+ * @param {string|object} locator element located by CSS|XPath|strict locator.
1971
+ * @param sec (optional) time in seconds to wait, 1 by default.
1972
+ * {--end--}
1847
1973
  */
1848
1974
  async waitForEnabled(locator, sec = null) {
1849
1975
  const aSec = sec || this.options.waitForTimeout;
@@ -1857,14 +1983,15 @@ Element can be located by CSS or XPath.
1857
1983
 
1858
1984
  /**
1859
1985
  * Waits for the specified value to be in value attribute.
1860
-
1861
- ```js
1862
- I.waitForValue('//input', "GoodValue");
1863
- ```
1864
-
1865
- @param field input field.
1866
- @param value expected value.
1867
- @param sec (optional) time in seconds to wait, 1 sec by default.
1986
+ *
1987
+ * ```js
1988
+ * I.waitForValue('//input', "GoodValue");
1989
+ * ```
1990
+ *
1991
+ * @param {string|object} field input field.
1992
+ * @param {string }value expected value.
1993
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
1994
+ * {--end--}
1868
1995
  */
1869
1996
  async waitForValue(field, value, sec = null) {
1870
1997
  const aSec = sec || this.options.waitForTimeout;
@@ -1889,21 +2016,22 @@ I.waitForValue('//input', "GoodValue");
1889
2016
 
1890
2017
  /**
1891
2018
  * Waits for a function to return true (waits for 1 sec by default).
1892
- Running in browser context.
1893
-
1894
- ```js
1895
- I.waitForFunction(fn[, [args[, timeout]])
1896
- ```
1897
-
1898
- ```js
1899
- I.waitForFunction(() => window.requests == 0);
1900
- I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1901
- I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
1902
- ```
1903
-
1904
- @param fn to be executed in browser context.
1905
- @param argsOrSec (optional) arguments for function or seconds.
1906
- @param sec (optional) time in seconds to wait, 1 by default.
2019
+ * Running in browser context.
2020
+ *
2021
+ * ```js
2022
+ * I.waitForFunction(fn[, [args[, timeout]])
2023
+ * ```
2024
+ *
2025
+ * ```js
2026
+ * I.waitForFunction(() => window.requests == 0);
2027
+ * I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
2028
+ * I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
2029
+ * ```
2030
+ *
2031
+ * @param {string|function} fn to be executed in browser context.
2032
+ * @param {array|number} argsOrSec (optional, `1` by default) arguments for function or seconds.
2033
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2034
+ * {--end--}
1907
2035
  */
1908
2036
  async waitForFunction(fn, argsOrSec = null, sec = null) {
1909
2037
  let args = [];
@@ -1921,15 +2049,16 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
1921
2049
 
1922
2050
  /**
1923
2051
  * Waits for a function to return true (waits for 1sec by default).
1924
-
1925
- ```js
1926
- I.waitUntil(() => window.requests == 0);
1927
- I.waitUntil(() => window.requests == 0, 5);
1928
- ```
1929
-
1930
- @param fn function which is executed in browser context.
1931
- @param sec (optional) time in seconds to wait, 1 by default.
1932
- @param timeoutMsg (optional) message to show in case of timeout fail.
2052
+ *
2053
+ * ```js
2054
+ * I.waitUntil(() => window.requests == 0);
2055
+ * I.waitUntil(() => window.requests == 0, 5);
2056
+ * ```
2057
+ *
2058
+ * @param {function|string} fn function which is executed in browser context.
2059
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2060
+ * @param {string} [timeoutMsg=''] message to show in case of timeout fail.
2061
+ * {--end--}
1933
2062
  */
1934
2063
  async waitUntil(fn, sec = null, timeoutMsg = null) {
1935
2064
  const aSec = sec || this.options.waitForTimeout;
@@ -1938,13 +2067,14 @@ I.waitUntil(() => window.requests == 0, 5);
1938
2067
 
1939
2068
  /**
1940
2069
  * Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
1941
-
1942
- ```js
1943
- I.waitInUrl('/info', 2);
1944
- ```
1945
-
1946
- @param urlPart value to check.
1947
- @param sec (optional) time in seconds to wait.
2070
+ *
2071
+ * ```js
2072
+ * I.waitInUrl('/info', 2);
2073
+ * ```
2074
+ *
2075
+ * @param {string} urlPart value to check.
2076
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2077
+ * {--end--}
1948
2078
  */
1949
2079
  async waitInUrl(urlPart, sec = null) {
1950
2080
  const aSec = sec || this.options.waitForTimeout;
@@ -1963,14 +2093,15 @@ I.waitInUrl('/info', 2);
1963
2093
 
1964
2094
  /**
1965
2095
  * Waits for the entire URL to match the expected
1966
-
1967
- ```js
1968
- I.waitUrlEquals('/info', 2);
1969
- I.waitUrlEquals('http://127.0.0.1:8000/info');
1970
- ```
1971
-
1972
- @param urlPart value to check.
1973
- @param sec (optional) time in seconds to wait.
2096
+ *
2097
+ * ```js
2098
+ * I.waitUrlEquals('/info', 2);
2099
+ * I.waitUrlEquals('http://127.0.0.1:8000/info');
2100
+ * ```
2101
+ *
2102
+ * @param {string} urlPart value to check.
2103
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2104
+ * {--end--}
1974
2105
  */
1975
2106
  async waitUrlEquals(urlPart, sec = null) {
1976
2107
  const aSec = sec || this.options.waitForTimeout;
@@ -1993,17 +2124,18 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
1993
2124
 
1994
2125
  /**
1995
2126
  * Waits for a text to appear (by default waits for 1sec).
1996
- Element can be located by CSS or XPath.
1997
- Narrow down search results by providing context.
1998
-
1999
- ```js
2000
- I.waitForText('Thank you, form has been submitted');
2001
- I.waitForText('Thank you, form has been submitted', 5, '#modal');
2002
- ```
2003
-
2004
- @param text to wait for.
2005
- @param sec (optional) time in seconds to wait.
2006
- @param context (optional) element located by CSS|XPath|strict locator.
2127
+ * Element can be located by CSS or XPath.
2128
+ * Narrow down search results by providing context.
2129
+ *
2130
+ * ```js
2131
+ * I.waitForText('Thank you, form has been submitted');
2132
+ * I.waitForText('Thank you, form has been submitted', 5, '#modal');
2133
+ * ```
2134
+ *
2135
+ * @param {string }text to wait for.
2136
+ * @param {number} sec (optional, `1` by default) time in seconds to wait
2137
+ * @param {string|object} context (optional) element located by CSS|XPath|strict locator.
2138
+ * {--end--}
2007
2139
  */
2008
2140
  async waitForText(text, sec = null, context = null) {
2009
2141
  if (!context) {
@@ -2026,11 +2158,11 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
2026
2158
 
2027
2159
  /**
2028
2160
  * Reload the current page.
2029
-
2030
- ```js
2031
- I.refreshPage();
2032
- ```
2033
-
2161
+ *
2162
+ * ```js
2163
+ * I.refreshPage();
2164
+ * ```
2165
+ * {--end--}
2034
2166
  */
2035
2167
  refreshPage() {
2036
2168
  return this.browser.refresh();
@@ -2046,16 +2178,17 @@ I.refreshPage();
2046
2178
 
2047
2179
  /**
2048
2180
  * Scrolls to element matched by locator.
2049
- Extra shift can be set with offsetX and offsetY options.
2050
-
2051
- ```js
2052
- I.scrollTo('footer');
2053
- I.scrollTo('#submit', 5, 5);
2054
- ```
2055
-
2056
- @param locator located by CSS|XPath|strict locator.
2057
- @param offsetX (optional) X-axis offset.
2058
- @param offsetY (optional) Y-axis offset.
2181
+ * Extra shift can be set with offsetX and offsetY options.
2182
+ *
2183
+ * ```js
2184
+ * I.scrollTo('footer');
2185
+ * I.scrollTo('#submit', 5, 5);
2186
+ * ```
2187
+ *
2188
+ * @param {string|object} locator located by CSS|XPath|strict locator.
2189
+ * @param {number} offsetX (optional, `0` by default) X-axis offset.
2190
+ * @param {number} offsetY (optional, `0` by default) Y-axis offset.
2191
+ * {--end--}
2059
2192
  */
2060
2193
  async scrollTo(locator, offsetX = 0, offsetY = 0) {
2061
2194
  if (typeof locator === 'number' && typeof offsetX === 'number') {
@@ -2083,10 +2216,11 @@ I.scrollTo('#submit', 5, 5);
2083
2216
 
2084
2217
  /**
2085
2218
  * Scroll page to the top.
2086
-
2087
- ```js
2088
- I.scrollPageToTop();
2089
- ```
2219
+ *
2220
+ * ```js
2221
+ * I.scrollPageToTop();
2222
+ * ```
2223
+ * {--end--}
2090
2224
  */
2091
2225
  async scrollPageToTop() {
2092
2226
  return this.executeScript('window.scrollTo(0, 0);');
@@ -2094,10 +2228,11 @@ I.scrollPageToTop();
2094
2228
 
2095
2229
  /**
2096
2230
  * Scroll page to the bottom.
2097
-
2098
- ```js
2099
- I.scrollPageToBottom();
2100
- ```
2231
+ *
2232
+ * ```js
2233
+ * I.scrollPageToBottom();
2234
+ * ```
2235
+ * {--end--}
2101
2236
  */
2102
2237
  async scrollPageToBottom() {
2103
2238
  /* eslint-disable prefer-arrow-callback, comma-dangle */
@@ -2114,11 +2249,14 @@ I.scrollPageToBottom();
2114
2249
 
2115
2250
  /**
2116
2251
  * Retrieves a page scroll position and returns it to test.
2117
- Resumes test execution, so **should be used inside an async function with `await`** operator.
2118
-
2119
- ```js
2120
- let { x, y } = await I.grabPageScrollPosition();
2121
- ```
2252
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
2253
+ *
2254
+ * ```js
2255
+ * let { x, y } = await I.grabPageScrollPosition();
2256
+ * ```
2257
+ *
2258
+ * @returns {Promise<object>} scroll position
2259
+ * {--end--}
2122
2260
  */
2123
2261
  async grabPageScrollPosition() {
2124
2262
  /* eslint-disable comma-dangle */
@@ -2162,12 +2300,13 @@ let { x, y } = await I.grabPageScrollPosition();
2162
2300
 
2163
2301
  /**
2164
2302
  * Sets a cookie.
2165
-
2166
- ```js
2167
- I.setCookie({name: 'auth', value: true});
2168
- ```
2169
-
2170
- @param cookie cookie JSON object.
2303
+ *
2304
+ * ```js
2305
+ * I.setCookie({name: 'auth', value: true});
2306
+ * ```
2307
+ *
2308
+ * @param {object} cookie a cookie object.
2309
+ * {--end--}
2171
2310
  */
2172
2311
  setCookie(cookie) {
2173
2312
  return this.browser.manage().addCookie(cookie);