codeceptjs 2.3.4 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +28 -6
- package/bin/codecept.js +42 -0
- package/docs/advanced.md +45 -1
- package/docs/angular.md +3 -3
- package/docs/basics.md +162 -118
- package/docs/bdd.md +30 -5
- package/docs/best.md +8 -6
- package/docs/books.md +6 -1
- package/docs/build/Appium.js +95 -85
- package/docs/build/FileSystem.js +48 -3
- package/docs/build/GraphQL.js +3 -2
- package/docs/build/GraphQLDataFactory.js +1 -0
- package/docs/build/Mochawesome.js +3 -2
- package/docs/build/MockRequest.js +23 -5
- package/docs/build/Nightmare.js +87 -128
- package/docs/build/Protractor.js +107 -155
- package/docs/build/Puppeteer.js +190 -174
- package/docs/build/REST.js +13 -9
- package/docs/build/SeleniumWebdriver.js +0 -17
- package/docs/build/TestCafe.js +164 -158
- package/docs/build/WebDriver.js +236 -211
- package/docs/build/WebDriverIO.js +218 -187
- package/docs/changelog.md +57 -1
- package/docs/commands.md +41 -2
- package/docs/community-helpers.md +12 -1
- package/docs/configuration.md +5 -2
- package/docs/continuous-integration.md +22 -0
- package/docs/{helpers.md → custom-helpers.md} +16 -10
- package/docs/data.md +7 -6
- package/docs/detox.md +6 -6
- package/docs/email.md +4 -2
- package/docs/examples.md +22 -3
- package/docs/helpers/ApiDataFactory.md +15 -13
- package/docs/helpers/Appium.md +1011 -468
- package/docs/helpers/Detox.md +33 -26
- package/docs/helpers/FileSystem.md +43 -13
- package/docs/helpers/GraphQL.md +17 -15
- package/docs/helpers/GraphQLDataFactory.md +15 -13
- package/docs/helpers/Mochawesome.md +3 -1
- package/docs/helpers/MockRequest.md +37 -19
- package/docs/helpers/Nightmare.md +129 -240
- package/docs/helpers/Polly.md +1 -1
- package/docs/helpers/Protractor.md +157 -298
- package/docs/helpers/Puppeteer.md +216 -335
- package/docs/helpers/REST.md +29 -24
- package/docs/helpers/TestCafe.md +137 -235
- package/docs/helpers/WebDriver.md +250 -347
- package/docs/hooks.md +14 -10
- package/docs/index.md +112 -0
- package/docs/installation.md +3 -1
- package/docs/locators.md +19 -8
- package/docs/mobile-react-native-locators.md +2 -2
- package/docs/mobile.md +5 -3
- package/docs/nightmare.md +2 -1
- package/docs/pageobjects.md +4 -2
- package/docs/parallel.md +4 -2
- package/docs/plugins.md +41 -15
- package/docs/puppeteer.md +8 -6
- package/docs/quickstart.md +130 -0
- package/docs/react.md +4 -2
- package/docs/reports.md +6 -4
- package/docs/testcafe.md +10 -8
- package/docs/translation.md +4 -2
- package/docs/ui.md +56 -0
- package/docs/videos.md +11 -2
- package/docs/visual.md +7 -5
- package/docs/vue.md +121 -0
- package/docs/webapi/appendField.mustache +1 -1
- package/docs/webapi/attachFile.mustache +1 -1
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +2 -2
- package/docs/webapi/dontSee.mustache +1 -2
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/dontSeeElement.mustache +1 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +1 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +1 -1
- package/docs/webapi/dragSlider.mustache +1 -1
- package/docs/webapi/executeAsyncScript.mustache +2 -1
- package/docs/webapi/executeScript.mustache +2 -1
- package/docs/webapi/fillField.mustache +1 -1
- package/docs/webapi/grabAttributeFrom.mustache +1 -1
- package/docs/webapi/grabBrowserLogs.mustache +1 -1
- package/docs/webapi/grabCookie.mustache +2 -2
- package/docs/webapi/grabCssPropertyFrom.mustache +1 -1
- package/docs/webapi/grabHTMLFrom.mustache +1 -1
- package/docs/webapi/grabNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/grabPageScrollPosition.mustache +1 -1
- package/docs/webapi/grabTextFrom.mustache +2 -2
- package/docs/webapi/grabValueFrom.mustache +1 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -1
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +1 -1
- package/docs/webapi/scrollIntoView.mustache +10 -0
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +1 -1
- package/docs/webapi/seeAttributesOnElements.mustache +1 -1
- package/docs/webapi/seeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInField.mustache +1 -1
- package/docs/webapi/seeNumberOfElements.mustache +1 -1
- package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/seeTextEquals.mustache +8 -0
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/switchTo.mustache +1 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/waitForClickable.mustache +10 -0
- package/docs/webapi/waitForDetached.mustache +2 -2
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +2 -2
- package/docs/webapi/waitForFunction.mustache +2 -2
- package/docs/webapi/waitForInvisible.mustache +2 -2
- package/docs/webapi/waitForText.mustache +2 -2
- package/docs/webapi/waitForValue.mustache +1 -1
- package/docs/webapi/waitForVisible.mustache +2 -2
- package/docs/webapi/waitInUrl.mustache +1 -1
- package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/waitToHide.mustache +2 -2
- package/docs/webapi/waitUntil.mustache +3 -2
- package/docs/webapi/waitUrlEquals.mustache +1 -1
- package/docs/webdriver.md +20 -18
- package/docs/wiki/.git/FETCH_HEAD +1 -0
- package/docs/wiki/.git/HEAD +1 -0
- package/docs/wiki/.git/ORIG_HEAD +1 -0
- package/docs/wiki/.git/config +11 -0
- package/docs/wiki/.git/description +1 -0
- package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
- package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
- package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +114 -0
- package/docs/wiki/.git/hooks/post-update.sample +8 -0
- package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
- package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
- package/docs/wiki/.git/hooks/pre-push.sample +53 -0
- package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
- package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
- package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
- package/docs/wiki/.git/hooks/update.sample +128 -0
- package/docs/wiki/.git/index +0 -0
- package/docs/wiki/.git/info/exclude +6 -0
- package/docs/wiki/.git/logs/HEAD +4 -0
- package/docs/wiki/.git/logs/refs/heads/master +4 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/master +3 -0
- package/docs/wiki/.git/objects/00/d216b0774d15db2d0a2a0d4ce249b5251acc55 +3 -0
- package/docs/wiki/.git/objects/09/01d87c5241905fdfe3493cfe8f04df4a2685ea +0 -0
- package/docs/wiki/.git/objects/0d/bdd0c20c4deb6a8cc81dbbf32ecf8c09238983 +2 -0
- package/docs/wiki/.git/objects/1a/c29e4fa82422c52392f22f0f2b8d1a759535bf +0 -0
- package/docs/wiki/.git/objects/27/12f92898d3e8f68e229b6cda76570d6c66d781 +0 -0
- package/docs/wiki/.git/objects/2d/dbe22c257166b648928eeb9460ecfb71ba702d +0 -0
- package/docs/wiki/.git/objects/2f/c942ec3773efd2678d9ff98035c61fcded81a1 +0 -0
- package/docs/wiki/.git/objects/40/a2856342c67796b48911a256b764fb06888b94 +5 -0
- package/docs/wiki/.git/objects/47/53181844fc4dc563cf3aa5e80462243cb58d38 +0 -0
- package/docs/wiki/.git/objects/4e/24a95fb2e4f8ffef51f19b694451a205c06f10 +3 -0
- package/docs/wiki/.git/objects/73/31ebd96f3c7e08a9f63f05a25f939afa0d4de1 +0 -0
- package/docs/wiki/.git/objects/86/19cbb2289caa502e33fccf0ed14eecf6ba2ba0 +0 -0
- package/docs/wiki/.git/objects/a4/72f797d9d74b87c9f71a2b1539d75bb07d1e35 +0 -0
- package/docs/wiki/.git/objects/c9/9f3e4bd227d6b050b2e416f9876df49583dbf6 +0 -0
- package/docs/wiki/.git/objects/ca/e609b4ef3e0ef85fcbe0d68d1a58246584b915 +0 -0
- package/docs/wiki/.git/objects/d5/8386ca72f6d550548f3d71d74e3ac73d5ad488 +0 -0
- package/docs/wiki/.git/objects/d9/c6874a6de524bdafeb563a20d847f4fdd59a86 +0 -0
- package/docs/wiki/.git/objects/f1/c944675bb38b40ae553b0be36c14674c79af54 +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.idx +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.pack +0 -0
- package/docs/wiki/.git/packed-refs +2 -0
- package/docs/wiki/.git/refs/heads/master +1 -0
- package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/refs/remotes/origin/master +1 -0
- package/docs/wiki/Books-&-Posts.md +27 -0
- package/docs/wiki/Community-Helpers.md +41 -0
- package/docs/wiki/Examples.md +138 -0
- package/docs/wiki/Home.md +11 -0
- package/docs/wiki/Release-process.md +25 -0
- package/docs/wiki/Roadmap.md +23 -0
- package/docs/wiki/Videos.md +19 -0
- package/lib/actor.js +18 -1
- package/lib/assert/error.js +3 -3
- package/lib/codecept.js +9 -6
- package/lib/command/configMigrate.js +7 -6
- package/lib/command/definitions.js +98 -350
- package/lib/command/generate.js +22 -17
- package/lib/command/gherkin/init.js +2 -1
- package/lib/command/gherkin/snippets.js +6 -6
- package/lib/command/gherkin/steps.js +0 -1
- package/lib/command/info.js +40 -0
- package/lib/command/init.js +54 -41
- package/lib/command/run-multiple.js +5 -4
- package/lib/command/run-rerun.js +39 -0
- package/lib/command/run-workers.js +4 -6
- package/lib/command/run.js +8 -18
- package/lib/command/utils.js +23 -2
- package/lib/command/workers/runTests.js +1 -2
- package/lib/config.js +10 -4
- package/lib/container.js +31 -6
- package/lib/data/dataTableArgument.js +31 -0
- package/lib/data/table.js +4 -0
- package/lib/event.js +65 -1
- package/lib/helper/Appium.js +52 -38
- package/lib/helper/FileSystem.js +48 -3
- package/lib/helper/GraphQL.js +3 -2
- package/lib/helper/GraphQLDataFactory.js +1 -0
- package/lib/helper/Mochawesome.js +3 -2
- package/lib/helper/MockRequest.js +23 -5
- package/lib/helper/Nightmare.js +5 -6
- package/lib/helper/Protractor.js +7 -8
- package/lib/helper/Puppeteer.js +76 -20
- package/lib/helper/REST.js +13 -9
- package/lib/helper/SeleniumWebdriver.js +0 -17
- package/lib/helper/TestCafe.js +84 -36
- package/lib/helper/WebDriver.js +113 -59
- package/lib/helper/WebDriverIO.js +43 -59
- package/lib/helper/clientscripts/nightmare.js +66 -4
- package/lib/helper/scripts/isElementClickable.js +24 -0
- package/lib/helper.js +34 -10
- package/lib/history.js +1 -1
- package/lib/hooks.js +2 -1
- package/lib/index.js +19 -0
- package/lib/interfaces/bdd.js +4 -0
- package/lib/interfaces/featureConfig.js +10 -3
- package/lib/interfaces/gherkin.js +6 -2
- package/lib/interfaces/scenarioConfig.js +17 -6
- package/lib/listener/config.js +1 -1
- package/lib/listener/exit.js +6 -0
- package/lib/listener/steps.js +0 -1
- package/lib/listener/trace.js +0 -1
- package/lib/locator.js +67 -2
- package/lib/output.js +53 -0
- package/lib/parser.js +2 -71
- package/lib/pause.js +3 -2
- package/lib/plugin/allure.js +41 -22
- package/lib/plugin/autoLogin.js +4 -1
- package/lib/plugin/pauseOnFail.js +38 -0
- package/lib/plugin/puppeteerCoverage.js +8 -7
- package/lib/plugin/screenshotOnFail.js +13 -8
- package/lib/plugin/stepByStepReport.js +7 -6
- package/lib/plugin/wdio.js +2 -1
- package/lib/recorder.js +85 -7
- package/lib/rerun.js +81 -0
- package/lib/secret.js +6 -0
- package/lib/session.js +9 -2
- package/lib/step.js +37 -2
- package/lib/store.js +5 -1
- package/lib/ui.js +34 -8
- package/lib/utils.js +6 -13
- package/lib/within.js +5 -0
- package/package.json +49 -29
- package/typings/Mocha.d.ts +21 -0
- package/typings/Protractor.d.ts +16 -0
- package/typings/index.d.ts +169 -0
- package/typings/jsdoc.conf.js +34 -0
- package/typings/jsdoc.namespace.js +29 -0
- package/typings/types.d.ts +9827 -0
- package/typings/utils.d.ts +7 -0
- package/docs/acceptance.md +0 -409
- package/docs/api/codecept.md +0 -75
- package/docs/api/config.md +0 -49
- package/docs/api/container.md +0 -66
- package/docs/api/helper.md +0 -116
- package/docs/api/output.md +0 -67
- package/docs/api/recorder.md +0 -63
- package/docs/helpers/SeleniumWebdriver.md +0 -92
- package/docs/helpers/WebDriverIO.md +0 -1671
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
let webdriverio;
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const path = require('path');
|
|
2
5
|
const requireg = require('requireg');
|
|
6
|
+
|
|
3
7
|
const Helper = require('../helper');
|
|
4
8
|
const stringIncludes = require('../assert/include').includes;
|
|
5
9
|
const { urlEquals, equals } = require('../assert/equal');
|
|
@@ -21,8 +25,6 @@ const {
|
|
|
21
25
|
const ElementNotFound = require('./errors/ElementNotFound');
|
|
22
26
|
const ConnectionRefused = require('./errors/ConnectionRefused');
|
|
23
27
|
|
|
24
|
-
const assert = require('assert');
|
|
25
|
-
const path = require('path');
|
|
26
28
|
|
|
27
29
|
const webRoot = 'body';
|
|
28
30
|
const Locator = require('../locator');
|
|
@@ -92,7 +94,7 @@ let withinStore = {};
|
|
|
92
94
|
* "browser": "chrome",
|
|
93
95
|
* "desiredCapabilities": {
|
|
94
96
|
* "chromeOptions": {
|
|
95
|
-
* "args": [ "--headless", "--disable-gpu", "--
|
|
97
|
+
* "args": [ "--headless", "--disable-gpu", "--no-sandbox" ]
|
|
96
98
|
* }
|
|
97
99
|
* }
|
|
98
100
|
* }
|
|
@@ -446,7 +448,7 @@ class WebDriverIO extends Helper {
|
|
|
446
448
|
* this.helpers['WebDriverIO']._locate({name: 'password'}).then //...
|
|
447
449
|
* ```
|
|
448
450
|
*
|
|
449
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
451
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
450
452
|
*/
|
|
451
453
|
async _locate(locator, smartWait = false) {
|
|
452
454
|
if (!this.options.smartWait || !smartWait) return this.browser.elements(withStrictLocator.call(this, locator));
|
|
@@ -465,7 +467,7 @@ class WebDriverIO extends Helper {
|
|
|
465
467
|
* this.helpers['WebDriverIO']._locateCheckable('I agree with terms and conditions').then // ...
|
|
466
468
|
* ```
|
|
467
469
|
*
|
|
468
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
470
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
469
471
|
*/
|
|
470
472
|
async _locateCheckable(locator) {
|
|
471
473
|
return findCheckable.call(this, locator, this.browser.elements.bind(this)).then(res => res.value);
|
|
@@ -478,7 +480,7 @@ class WebDriverIO extends Helper {
|
|
|
478
480
|
* this.helpers['WebDriverIO']._locateClickable('Next page').then // ...
|
|
479
481
|
* ```
|
|
480
482
|
*
|
|
481
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
483
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
482
484
|
*/
|
|
483
485
|
async _locateClickable(locator) {
|
|
484
486
|
return findClickable.call(this, locator, this.browser.elements.bind(this)).then(res => res.value);
|
|
@@ -491,7 +493,7 @@ class WebDriverIO extends Helper {
|
|
|
491
493
|
* this.helpers['WebDriverIO']._locateFields('Your email').then // ...
|
|
492
494
|
* ```
|
|
493
495
|
*
|
|
494
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
496
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
495
497
|
*/
|
|
496
498
|
async _locateFields(locator) {
|
|
497
499
|
return findFields.call(this, locator).then(res => res.value);
|
|
@@ -507,7 +509,7 @@ class WebDriverIO extends Helper {
|
|
|
507
509
|
* I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
|
|
508
510
|
* ```
|
|
509
511
|
*
|
|
510
|
-
* @param timeouts WebDriver timeouts object.
|
|
512
|
+
* @param {WebdriverIO.Timeouts} timeouts WebDriver timeouts object.
|
|
511
513
|
*/
|
|
512
514
|
async defineTimeout(timeouts) {
|
|
513
515
|
try {
|
|
@@ -543,7 +545,6 @@ class WebDriverIO extends Helper {
|
|
|
543
545
|
* ```
|
|
544
546
|
*
|
|
545
547
|
* @param {string} url url path or global url.
|
|
546
|
-
* {--end--}
|
|
547
548
|
* Appium: support only web testing
|
|
548
549
|
*/
|
|
549
550
|
amOnPage(url) {
|
|
@@ -573,9 +574,9 @@ class WebDriverIO extends Helper {
|
|
|
573
574
|
* I.click({css: 'nav a.login'});
|
|
574
575
|
* ```
|
|
575
576
|
*
|
|
576
|
-
* @param {
|
|
577
|
-
* @param {
|
|
578
|
-
*
|
|
577
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
578
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
579
|
+
*
|
|
579
580
|
* Appium: support
|
|
580
581
|
*/
|
|
581
582
|
async click(locator, context = null) {
|
|
@@ -602,9 +603,9 @@ class WebDriverIO extends Helper {
|
|
|
602
603
|
* I.doubleClick('.btn.edit');
|
|
603
604
|
* ```
|
|
604
605
|
*
|
|
605
|
-
* @param {
|
|
606
|
-
* @param {
|
|
607
|
-
*
|
|
606
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
607
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
608
|
+
*
|
|
608
609
|
* Appium: support only web testing
|
|
609
610
|
*/
|
|
610
611
|
async doubleClick(locator, context = null) {
|
|
@@ -634,9 +635,9 @@ class WebDriverIO extends Helper {
|
|
|
634
635
|
* I.rightClick('Click me', '.context');
|
|
635
636
|
* ```
|
|
636
637
|
*
|
|
637
|
-
* @param {
|
|
638
|
-
* @param {
|
|
639
|
-
*
|
|
638
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
|
|
639
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
640
|
+
*
|
|
640
641
|
* Appium: support, but in apps works as usual click
|
|
641
642
|
*/
|
|
642
643
|
async rightClick(locator) {
|
|
@@ -666,9 +667,9 @@ class WebDriverIO extends Helper {
|
|
|
666
667
|
* // or by strict locator
|
|
667
668
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
668
669
|
* ```
|
|
669
|
-
* @param {
|
|
670
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
670
671
|
* @param {string} value text value to fill.
|
|
671
|
-
*
|
|
672
|
+
*
|
|
672
673
|
* Appium: support
|
|
673
674
|
*/
|
|
674
675
|
async fillField(field, value) {
|
|
@@ -685,9 +686,8 @@ class WebDriverIO extends Helper {
|
|
|
685
686
|
* ```js
|
|
686
687
|
* I.appendField('#myTextField', 'appended');
|
|
687
688
|
* ```
|
|
688
|
-
* @param {
|
|
689
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
689
690
|
* @param {string} value text value to append.
|
|
690
|
-
* {--end--}
|
|
691
691
|
* Appium: support, but it's clear a field before insert in apps
|
|
692
692
|
*/
|
|
693
693
|
async appendField(field, value) {
|
|
@@ -751,9 +751,8 @@ class WebDriverIO extends Helper {
|
|
|
751
751
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
752
752
|
* ```
|
|
753
753
|
*
|
|
754
|
-
* @param {
|
|
754
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
755
755
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
756
|
-
* {--end--}
|
|
757
756
|
* Appium: not tested
|
|
758
757
|
*/
|
|
759
758
|
async attachFile(locator, pathToFile) {
|
|
@@ -780,9 +779,8 @@ class WebDriverIO extends Helper {
|
|
|
780
779
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
781
780
|
* I.checkOption('agree', '//form');
|
|
782
781
|
* ```
|
|
783
|
-
* @param {
|
|
784
|
-
* @param {
|
|
785
|
-
* {--end--}
|
|
782
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
783
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
786
784
|
* Appium: not tested
|
|
787
785
|
*/
|
|
788
786
|
async checkOption(field, context = null) {
|
|
@@ -810,9 +808,8 @@ class WebDriverIO extends Helper {
|
|
|
810
808
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
811
809
|
* I.uncheckOption('agree', '//form');
|
|
812
810
|
* ```
|
|
813
|
-
* @param {
|
|
814
|
-
* @param {
|
|
815
|
-
* {--end--}
|
|
811
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
812
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
816
813
|
* Appium: not tested
|
|
817
814
|
*/
|
|
818
815
|
async uncheckOption(field, context = null) {
|
|
@@ -838,9 +835,8 @@ class WebDriverIO extends Helper {
|
|
|
838
835
|
* ```
|
|
839
836
|
* If multiple elements found returns an array of texts.
|
|
840
837
|
*
|
|
841
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
842
|
-
* @returns {Promise<string>} attribute value
|
|
843
|
-
* {--end--}
|
|
838
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
839
|
+
* @returns {Promise<string|string[]>} attribute value
|
|
844
840
|
* Appium: support
|
|
845
841
|
*/
|
|
846
842
|
async grabTextFrom(locator) {
|
|
@@ -860,9 +856,8 @@ class WebDriverIO extends Helper {
|
|
|
860
856
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
861
857
|
* ```
|
|
862
858
|
*
|
|
863
|
-
* @param
|
|
859
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
864
860
|
* @returns {Promise<string>} HTML code for an element
|
|
865
|
-
* {--end--}
|
|
866
861
|
* Appium: support only web testing
|
|
867
862
|
*/
|
|
868
863
|
async grabHTMLFrom(locator) {
|
|
@@ -878,9 +873,8 @@ class WebDriverIO extends Helper {
|
|
|
878
873
|
* ```js
|
|
879
874
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
880
875
|
* ```
|
|
881
|
-
* @param {
|
|
876
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
882
877
|
* @returns {Promise<string>} attribute value
|
|
883
|
-
* {--end--}
|
|
884
878
|
* Appium: support only web testing
|
|
885
879
|
*/
|
|
886
880
|
async grabValueFrom(locator) {
|
|
@@ -898,10 +892,9 @@ class WebDriverIO extends Helper {
|
|
|
898
892
|
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
899
893
|
* ```
|
|
900
894
|
*
|
|
901
|
-
* @param {
|
|
895
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
902
896
|
* @param {string} cssProperty CSS property name.
|
|
903
897
|
* @returns {Promise<string>} CSS value
|
|
904
|
-
* {--end--}
|
|
905
898
|
*/
|
|
906
899
|
async grabCssPropertyFrom(locator, cssProperty) {
|
|
907
900
|
const res = await this._locate(locator, true);
|
|
@@ -917,10 +910,9 @@ class WebDriverIO extends Helper {
|
|
|
917
910
|
* ```js
|
|
918
911
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
919
912
|
* ```
|
|
920
|
-
* @param {
|
|
913
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
921
914
|
* @param {string} attr attribute name.
|
|
922
915
|
* @returns {Promise<string>} attribute value
|
|
923
|
-
* {--end--}
|
|
924
916
|
* Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
925
917
|
*/
|
|
926
918
|
async grabAttributeFrom(locator, attr) {
|
|
@@ -937,7 +929,6 @@ class WebDriverIO extends Helper {
|
|
|
937
929
|
* ```
|
|
938
930
|
*
|
|
939
931
|
* @param {string} text text value to check.
|
|
940
|
-
* {--end--}
|
|
941
932
|
* Appium: support only web testing
|
|
942
933
|
*/
|
|
943
934
|
async seeInTitle(text) {
|
|
@@ -952,7 +943,7 @@ class WebDriverIO extends Helper {
|
|
|
952
943
|
* I.seeTitleEquals('Test title.');
|
|
953
944
|
* ```
|
|
954
945
|
*
|
|
955
|
-
* @param text value to check.
|
|
946
|
+
* @param {string} text value to check.
|
|
956
947
|
*/
|
|
957
948
|
async seeTitleEquals(text) {
|
|
958
949
|
const title = await this.browser.getTitle();
|
|
@@ -967,7 +958,6 @@ class WebDriverIO extends Helper {
|
|
|
967
958
|
* ```
|
|
968
959
|
*
|
|
969
960
|
* @param {string} text value to check.
|
|
970
|
-
* {--end--}
|
|
971
961
|
* Appium: support only web testing
|
|
972
962
|
*/
|
|
973
963
|
async dontSeeInTitle(text) {
|
|
@@ -984,7 +974,6 @@ class WebDriverIO extends Helper {
|
|
|
984
974
|
* ```
|
|
985
975
|
*
|
|
986
976
|
* @returns {Promise<string>} title
|
|
987
|
-
* {--end--}
|
|
988
977
|
* Appium: support only web testing
|
|
989
978
|
*/
|
|
990
979
|
async grabTitle() {
|
|
@@ -1003,8 +992,7 @@ class WebDriverIO extends Helper {
|
|
|
1003
992
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1004
993
|
* ```
|
|
1005
994
|
* @param {string} text expected on page.
|
|
1006
|
-
* @param {
|
|
1007
|
-
* {--end--}
|
|
995
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1008
996
|
* Appium: support with context in apps
|
|
1009
997
|
*/
|
|
1010
998
|
async see(text, context = null) {
|
|
@@ -1018,8 +1006,8 @@ class WebDriverIO extends Helper {
|
|
|
1018
1006
|
* I.seeTextEquals('text', 'h1');
|
|
1019
1007
|
* ```
|
|
1020
1008
|
*
|
|
1021
|
-
* @param text element value to check.
|
|
1022
|
-
* @param context (optional) element located by CSS|XPath|strict locator.
|
|
1009
|
+
* @param {string} text element value to check.
|
|
1010
|
+
* @param {CodeceptJS.LocatorOrString?} [context] (optional) element located by CSS|XPath|strict locator.
|
|
1023
1011
|
*/
|
|
1024
1012
|
async seeTextEquals(text, context = null) {
|
|
1025
1013
|
return proceedSee.call(this, 'assert', text, context, true);
|
|
@@ -1035,9 +1023,8 @@ class WebDriverIO extends Helper {
|
|
|
1035
1023
|
* ```
|
|
1036
1024
|
*
|
|
1037
1025
|
* @param {string} text which is not present.
|
|
1038
|
-
* @param {
|
|
1039
|
-
*
|
|
1040
|
-
* {--end--}
|
|
1026
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
1027
|
+
*
|
|
1041
1028
|
* Appium: support with context in apps
|
|
1042
1029
|
*/
|
|
1043
1030
|
async dontSee(text, context = null) {
|
|
@@ -1054,9 +1041,9 @@ class WebDriverIO extends Helper {
|
|
|
1054
1041
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1055
1042
|
* I.seeInField('#searchform input','Search');
|
|
1056
1043
|
* ```
|
|
1057
|
-
* @param {
|
|
1044
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1058
1045
|
* @param {string} value value to check.
|
|
1059
|
-
*
|
|
1046
|
+
*
|
|
1060
1047
|
* Appium: support only web testing
|
|
1061
1048
|
*/
|
|
1062
1049
|
async seeInField(field, value) {
|
|
@@ -1072,9 +1059,8 @@ class WebDriverIO extends Helper {
|
|
|
1072
1059
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1073
1060
|
* ```
|
|
1074
1061
|
*
|
|
1075
|
-
* @param {
|
|
1062
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1076
1063
|
* @param {string} value value to check.
|
|
1077
|
-
* {--end--}
|
|
1078
1064
|
* Appium: support only web testing
|
|
1079
1065
|
*/
|
|
1080
1066
|
async dontSeeInField(field, value) {
|
|
@@ -1090,8 +1076,8 @@ class WebDriverIO extends Helper {
|
|
|
1090
1076
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1091
1077
|
* ```
|
|
1092
1078
|
*
|
|
1093
|
-
* @param {
|
|
1094
|
-
*
|
|
1079
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1080
|
+
*
|
|
1095
1081
|
* Appium: not tested
|
|
1096
1082
|
*/
|
|
1097
1083
|
async seeCheckboxIsChecked(field) {
|
|
@@ -1107,8 +1093,8 @@ class WebDriverIO extends Helper {
|
|
|
1107
1093
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1108
1094
|
* ```
|
|
1109
1095
|
*
|
|
1110
|
-
* @param {
|
|
1111
|
-
*
|
|
1096
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1097
|
+
*
|
|
1112
1098
|
* Appium: not tested
|
|
1113
1099
|
*/
|
|
1114
1100
|
async dontSeeCheckboxIsChecked(field) {
|
|
@@ -1122,8 +1108,7 @@ class WebDriverIO extends Helper {
|
|
|
1122
1108
|
* ```js
|
|
1123
1109
|
* I.seeElement('#modal');
|
|
1124
1110
|
* ```
|
|
1125
|
-
* @param {
|
|
1126
|
-
* {--end--}
|
|
1111
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1127
1112
|
* Appium: support
|
|
1128
1113
|
*/
|
|
1129
1114
|
async seeElement(locator) {
|
|
@@ -1156,8 +1141,8 @@ class WebDriverIO extends Helper {
|
|
|
1156
1141
|
* ```js
|
|
1157
1142
|
* I.seeElementInDOM('#modal');
|
|
1158
1143
|
* ```
|
|
1159
|
-
* @param {
|
|
1160
|
-
*
|
|
1144
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1145
|
+
*
|
|
1161
1146
|
* Appium: support
|
|
1162
1147
|
*/
|
|
1163
1148
|
async seeElementInDOM(locator) {
|
|
@@ -1172,8 +1157,7 @@ class WebDriverIO extends Helper {
|
|
|
1172
1157
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1173
1158
|
* ```
|
|
1174
1159
|
*
|
|
1175
|
-
* @param {
|
|
1176
|
-
* {--end--}
|
|
1160
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1177
1161
|
* Appium: support
|
|
1178
1162
|
*/
|
|
1179
1163
|
async dontSeeElementInDOM(locator) {
|
|
@@ -1188,7 +1172,6 @@ class WebDriverIO extends Helper {
|
|
|
1188
1172
|
* I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1189
1173
|
* ```
|
|
1190
1174
|
* @param {string} text value to check.
|
|
1191
|
-
* {--end--}
|
|
1192
1175
|
* Appium: support
|
|
1193
1176
|
*/
|
|
1194
1177
|
async seeInSource(text) {
|
|
@@ -1205,7 +1188,6 @@ class WebDriverIO extends Helper {
|
|
|
1205
1188
|
* ```
|
|
1206
1189
|
*
|
|
1207
1190
|
* @returns {Promise<string>} source code
|
|
1208
|
-
* {--end--}
|
|
1209
1191
|
* Appium: support
|
|
1210
1192
|
*/
|
|
1211
1193
|
async grabSource() {
|
|
@@ -1234,7 +1216,6 @@ class WebDriverIO extends Helper {
|
|
|
1234
1216
|
* ```
|
|
1235
1217
|
*
|
|
1236
1218
|
* @returns {Promise<string>} current URL
|
|
1237
|
-
* {--end--}
|
|
1238
1219
|
*/
|
|
1239
1220
|
async grabCurrentUrl() {
|
|
1240
1221
|
const res = await this.browser.url();
|
|
@@ -1255,7 +1236,7 @@ class WebDriverIO extends Helper {
|
|
|
1255
1236
|
* ```
|
|
1256
1237
|
*
|
|
1257
1238
|
* @param {string} value to check.
|
|
1258
|
-
*
|
|
1239
|
+
*
|
|
1259
1240
|
* Appium: support
|
|
1260
1241
|
*/
|
|
1261
1242
|
async dontSeeInSource(text) {
|
|
@@ -1272,8 +1253,8 @@ class WebDriverIO extends Helper {
|
|
|
1272
1253
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
1273
1254
|
* ```
|
|
1274
1255
|
*
|
|
1275
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
1276
|
-
* @param num number of elements.
|
|
1256
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1257
|
+
* @param {number} [num] number of elements.
|
|
1277
1258
|
*/
|
|
1278
1259
|
async seeNumberOfElements(locator, num) {
|
|
1279
1260
|
const res = await this._locate(withStrictLocator.call(this, locator));
|
|
@@ -1288,9 +1269,9 @@ class WebDriverIO extends Helper {
|
|
|
1288
1269
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
1289
1270
|
* ```
|
|
1290
1271
|
*
|
|
1291
|
-
* @param {
|
|
1272
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1292
1273
|
* @param {number} num number of elements.
|
|
1293
|
-
*
|
|
1274
|
+
*
|
|
1294
1275
|
*/
|
|
1295
1276
|
async seeNumberOfVisibleElements(locator, num) {
|
|
1296
1277
|
const res = await this.grabNumberOfVisibleElements(locator);
|
|
@@ -1304,9 +1285,8 @@ class WebDriverIO extends Helper {
|
|
|
1304
1285
|
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
1305
1286
|
* ```
|
|
1306
1287
|
*
|
|
1307
|
-
* @param {
|
|
1288
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1308
1289
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
1309
|
-
* {--end--}
|
|
1310
1290
|
*/
|
|
1311
1291
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
1312
1292
|
const res = await this._locate(locator);
|
|
@@ -1347,9 +1327,8 @@ class WebDriverIO extends Helper {
|
|
|
1347
1327
|
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
1348
1328
|
* ```
|
|
1349
1329
|
*
|
|
1350
|
-
* @param {
|
|
1330
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1351
1331
|
* @param {object} attributes attributes and their values to check.
|
|
1352
|
-
* {--end--}
|
|
1353
1332
|
*/
|
|
1354
1333
|
async seeAttributesOnElements(locator, attributes) {
|
|
1355
1334
|
const res = await this._locate(locator);
|
|
@@ -1382,9 +1361,8 @@ class WebDriverIO extends Helper {
|
|
|
1382
1361
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1383
1362
|
* ```
|
|
1384
1363
|
*
|
|
1385
|
-
* @param {
|
|
1364
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1386
1365
|
* @returns {Promise<number>} number of visible elements
|
|
1387
|
-
* {--end--}
|
|
1388
1366
|
*/
|
|
1389
1367
|
async grabNumberOfVisibleElements(locator) {
|
|
1390
1368
|
const res = await this._locate(locator);
|
|
@@ -1403,7 +1381,6 @@ class WebDriverIO extends Helper {
|
|
|
1403
1381
|
* ```
|
|
1404
1382
|
*
|
|
1405
1383
|
* @param {string} url a fragment to check
|
|
1406
|
-
* {--end--}
|
|
1407
1384
|
* Appium: support only web testing
|
|
1408
1385
|
*/
|
|
1409
1386
|
async seeInCurrentUrl(url) {
|
|
@@ -1415,7 +1392,6 @@ class WebDriverIO extends Helper {
|
|
|
1415
1392
|
* Checks that current url does not contain a provided fragment.
|
|
1416
1393
|
*
|
|
1417
1394
|
* @param {string} url value to check.
|
|
1418
|
-
* {--end--}
|
|
1419
1395
|
* Appium: support only web testing
|
|
1420
1396
|
*/
|
|
1421
1397
|
async dontSeeInCurrentUrl(url) {
|
|
@@ -1434,7 +1410,6 @@ class WebDriverIO extends Helper {
|
|
|
1434
1410
|
* ```
|
|
1435
1411
|
*
|
|
1436
1412
|
* @param {string} url value to check.
|
|
1437
|
-
* {--end--}
|
|
1438
1413
|
* Appium: support only web testing
|
|
1439
1414
|
*/
|
|
1440
1415
|
async seeCurrentUrlEquals(url) {
|
|
@@ -1452,7 +1427,6 @@ class WebDriverIO extends Helper {
|
|
|
1452
1427
|
* ```
|
|
1453
1428
|
*
|
|
1454
1429
|
* @param {string} url value to check.
|
|
1455
|
-
* {--end--}
|
|
1456
1430
|
* Appium: support only web testing
|
|
1457
1431
|
*/
|
|
1458
1432
|
async dontSeeCurrentUrlEquals(url) {
|
|
@@ -1485,8 +1459,9 @@ class WebDriverIO extends Helper {
|
|
|
1485
1459
|
* ```
|
|
1486
1460
|
*
|
|
1487
1461
|
* @param {string|function} fn function to be executed in browser context.
|
|
1488
|
-
* @param ...
|
|
1489
|
-
* {
|
|
1462
|
+
* @param {...any} args to be passed to function.
|
|
1463
|
+
* @return {Promise<any>}
|
|
1464
|
+
*
|
|
1490
1465
|
* Appium: support only web testing
|
|
1491
1466
|
*
|
|
1492
1467
|
* Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
|
|
@@ -1518,8 +1493,9 @@ class WebDriverIO extends Helper {
|
|
|
1518
1493
|
* ```
|
|
1519
1494
|
*
|
|
1520
1495
|
* @param {string|function} fn function to be executed in browser context.
|
|
1521
|
-
* @param ...
|
|
1522
|
-
* {
|
|
1496
|
+
* @param {...any} args to be passed to function.
|
|
1497
|
+
* @return {Promise<any>}
|
|
1498
|
+
*
|
|
1523
1499
|
* Appium: support only web testing
|
|
1524
1500
|
*/
|
|
1525
1501
|
executeAsyncScript(fn) {
|
|
@@ -1535,9 +1511,9 @@ class WebDriverIO extends Helper {
|
|
|
1535
1511
|
* I.scrollTo('#submit', 5, 5);
|
|
1536
1512
|
* ```
|
|
1537
1513
|
*
|
|
1538
|
-
* @param locator located by CSS|XPath|strict locator.
|
|
1539
|
-
* @param offsetX (optional) X-axis offset.
|
|
1540
|
-
* @param offsetY (optional) Y-axis offset.
|
|
1514
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1515
|
+
* @param {number} [offsetX=0] (optional) X-axis offset.
|
|
1516
|
+
* @param {number} [offsetY=0] (optional) Y-axis offset.
|
|
1541
1517
|
*/
|
|
1542
1518
|
|
|
1543
1519
|
/**
|
|
@@ -1549,10 +1525,9 @@ class WebDriverIO extends Helper {
|
|
|
1549
1525
|
* I.scrollTo('#submit', 5, 5);
|
|
1550
1526
|
* ```
|
|
1551
1527
|
*
|
|
1552
|
-
* @param {
|
|
1553
|
-
* @param {number} offsetX (optional, `0` by default) X-axis offset.
|
|
1554
|
-
* @param {number} offsetY (optional, `0` by default) Y-axis offset.
|
|
1555
|
-
* {--end--}
|
|
1528
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1529
|
+
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
1530
|
+
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
1556
1531
|
* Appium: support only web testing
|
|
1557
1532
|
*/
|
|
1558
1533
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -1584,7 +1559,18 @@ class WebDriverIO extends Helper {
|
|
|
1584
1559
|
}
|
|
1585
1560
|
|
|
1586
1561
|
/**
|
|
1587
|
-
*
|
|
1562
|
+
* Moves cursor to element matched by locator.
|
|
1563
|
+
* Extra shift can be set with offsetX and offsetY options.
|
|
1564
|
+
*
|
|
1565
|
+
* ```js
|
|
1566
|
+
* I.moveCursorTo('.tooltip');
|
|
1567
|
+
* I.moveCursorTo('#submit', 5,5);
|
|
1568
|
+
* ```
|
|
1569
|
+
*
|
|
1570
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1571
|
+
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
1572
|
+
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
1573
|
+
*
|
|
1588
1574
|
* Appium: support only web testing
|
|
1589
1575
|
*/
|
|
1590
1576
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -1658,7 +1644,15 @@ class WebDriverIO extends Helper {
|
|
|
1658
1644
|
}
|
|
1659
1645
|
|
|
1660
1646
|
/**
|
|
1661
|
-
*
|
|
1647
|
+
* Clears a cookie by name,
|
|
1648
|
+
* if none provided clears all cookies.
|
|
1649
|
+
*
|
|
1650
|
+
* ```js
|
|
1651
|
+
* I.clearCookie();
|
|
1652
|
+
* I.clearCookie('test');
|
|
1653
|
+
* ```
|
|
1654
|
+
*
|
|
1655
|
+
* @param {?string} [cookie=null] (optional, `null` by default) cookie name
|
|
1662
1656
|
* Appium: support only web testing
|
|
1663
1657
|
*/
|
|
1664
1658
|
async clearCookie(cookie) {
|
|
@@ -1666,7 +1660,14 @@ class WebDriverIO extends Helper {
|
|
|
1666
1660
|
}
|
|
1667
1661
|
|
|
1668
1662
|
/**
|
|
1669
|
-
*
|
|
1663
|
+
* Checks that cookie with given name exists.
|
|
1664
|
+
*
|
|
1665
|
+
* ```js
|
|
1666
|
+
* I.seeCookie('Auth');
|
|
1667
|
+
* ```
|
|
1668
|
+
*
|
|
1669
|
+
* @param {string} name cookie name.
|
|
1670
|
+
*
|
|
1670
1671
|
* Appium: support only web testing
|
|
1671
1672
|
*/
|
|
1672
1673
|
async seeCookie(name) {
|
|
@@ -1675,7 +1676,13 @@ class WebDriverIO extends Helper {
|
|
|
1675
1676
|
}
|
|
1676
1677
|
|
|
1677
1678
|
/**
|
|
1678
|
-
*
|
|
1679
|
+
* Checks that cookie with given name does not exist.
|
|
1680
|
+
*
|
|
1681
|
+
* ```js
|
|
1682
|
+
* I.dontSeeCookie('auth'); // no auth cookie
|
|
1683
|
+
* ```
|
|
1684
|
+
*
|
|
1685
|
+
* @param {string} name cookie name.
|
|
1679
1686
|
* Appium: support only web testing
|
|
1680
1687
|
*/
|
|
1681
1688
|
async dontSeeCookie(name) {
|
|
@@ -1684,7 +1691,17 @@ class WebDriverIO extends Helper {
|
|
|
1684
1691
|
}
|
|
1685
1692
|
|
|
1686
1693
|
/**
|
|
1687
|
-
*
|
|
1694
|
+
* Gets a cookie object by name.
|
|
1695
|
+
* If none provided gets all cookies.
|
|
1696
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1697
|
+
*
|
|
1698
|
+
* ```js
|
|
1699
|
+
* let cookie = await I.grabCookie('auth');
|
|
1700
|
+
* assert(cookie.value, '123456');
|
|
1701
|
+
* ```
|
|
1702
|
+
*
|
|
1703
|
+
* @param {?string} [name=null] cookie name.
|
|
1704
|
+
* @returns {Promise<string>} attribute value
|
|
1688
1705
|
* Appium: support only web testing
|
|
1689
1706
|
*/
|
|
1690
1707
|
async grabCookie(name) {
|
|
@@ -1720,7 +1737,7 @@ class WebDriverIO extends Helper {
|
|
|
1720
1737
|
* Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1721
1738
|
* given string. Appium: support only web testing
|
|
1722
1739
|
*
|
|
1723
|
-
* @param text value to check.
|
|
1740
|
+
* @param {string} text value to check.
|
|
1724
1741
|
*/
|
|
1725
1742
|
async seeInPopup(text) {
|
|
1726
1743
|
return this.browser.alertText().then((res) => {
|
|
@@ -1744,28 +1761,66 @@ class WebDriverIO extends Helper {
|
|
|
1744
1761
|
}
|
|
1745
1762
|
|
|
1746
1763
|
/**
|
|
1747
|
-
* Presses a key on a focused element.
|
|
1748
|
-
*
|
|
1749
|
-
*
|
|
1750
|
-
* If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
|
|
1764
|
+
* Presses a key in the browser (on a focused element).
|
|
1765
|
+
*
|
|
1766
|
+
* _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
|
|
1751
1767
|
*
|
|
1752
1768
|
* ```js
|
|
1753
|
-
* I.pressKey('
|
|
1754
|
-
* I.pressKey(['Control','a']);
|
|
1769
|
+
* I.pressKey('Backspace');
|
|
1755
1770
|
* ```
|
|
1756
1771
|
*
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1772
|
+
* To press a key in combination with modifier keys, pass the sequence as an array. All modifier keys (`'Alt'`, `'Control'`, `'Meta'`, `'Shift'`) will be released afterwards.
|
|
1773
|
+
*
|
|
1774
|
+
* ```js
|
|
1775
|
+
* I.pressKey(['Control', 'Z']);
|
|
1776
|
+
* ```
|
|
1777
|
+
*
|
|
1778
|
+
* For specifying operation modifier key based on operating system it is suggested to use `'CommandOrControl'`.
|
|
1779
|
+
* This will press `'Command'` (also known as `'Meta'`) on macOS machines and `'Control'` on non-macOS machines.
|
|
1780
|
+
*
|
|
1764
1781
|
* ```js
|
|
1765
|
-
* I.pressKey('
|
|
1766
|
-
* I.click('#someelement');
|
|
1767
|
-
* I.pressKey('Control');
|
|
1782
|
+
* I.pressKey(['CommandOrControl', 'Z']);
|
|
1768
1783
|
* ```
|
|
1784
|
+
*
|
|
1785
|
+
* Some of the supported key names are:
|
|
1786
|
+
* - `'AltLeft'` or `'Alt'`
|
|
1787
|
+
* - `'AltRight'`
|
|
1788
|
+
* - `'ArrowDown'`
|
|
1789
|
+
* - `'ArrowLeft'`
|
|
1790
|
+
* - `'ArrowRight'`
|
|
1791
|
+
* - `'ArrowUp'`
|
|
1792
|
+
* - `'Backspace'`
|
|
1793
|
+
* - `'Clear'`
|
|
1794
|
+
* - `'ControlLeft'` or `'Control'`
|
|
1795
|
+
* - `'ControlRight'`
|
|
1796
|
+
* - `'Command'`
|
|
1797
|
+
* - `'CommandOrControl'`
|
|
1798
|
+
* - `'Delete'`
|
|
1799
|
+
* - `'End'`
|
|
1800
|
+
* - `'Enter'`
|
|
1801
|
+
* - `'Escape'`
|
|
1802
|
+
* - `'F1'` to `'F12'`
|
|
1803
|
+
* - `'Home'`
|
|
1804
|
+
* - `'Insert'`
|
|
1805
|
+
* - `'MetaLeft'` or `'Meta'`
|
|
1806
|
+
* - `'MetaRight'`
|
|
1807
|
+
* - `'Numpad0'` to `'Numpad9'`
|
|
1808
|
+
* - `'NumpadAdd'`
|
|
1809
|
+
* - `'NumpadDecimal'`
|
|
1810
|
+
* - `'NumpadDivide'`
|
|
1811
|
+
* - `'NumpadMultiply'`
|
|
1812
|
+
* - `'NumpadSubtract'`
|
|
1813
|
+
* - `'PageDown'`
|
|
1814
|
+
* - `'PageUp'`
|
|
1815
|
+
* - `'Pause'`
|
|
1816
|
+
* - `'Return'`
|
|
1817
|
+
* - `'ShiftLeft'` or `'Shift'`
|
|
1818
|
+
* - `'ShiftRight'`
|
|
1819
|
+
* - `'Space'`
|
|
1820
|
+
* - `'Tab'`
|
|
1821
|
+
*
|
|
1822
|
+
* @param {string|string[]} key key or array of keys to press.
|
|
1823
|
+
*
|
|
1769
1824
|
*/
|
|
1770
1825
|
async pressKey(key) {
|
|
1771
1826
|
let modifier;
|
|
@@ -1784,7 +1839,6 @@ class WebDriverIO extends Helper {
|
|
|
1784
1839
|
*
|
|
1785
1840
|
* @param {number} width width in pixels or `maximize`.
|
|
1786
1841
|
* @param {number} height height in pixels.
|
|
1787
|
-
* {--end--}
|
|
1788
1842
|
* Appium: not tested in web, in apps doesn't work
|
|
1789
1843
|
*/
|
|
1790
1844
|
async resizeWindow(width, height) {
|
|
@@ -1813,7 +1867,6 @@ class WebDriverIO extends Helper {
|
|
|
1813
1867
|
*
|
|
1814
1868
|
* @param {string|object} srcElement located by CSS|XPath|strict locator.
|
|
1815
1869
|
* @param {string|object} destElement located by CSS|XPath|strict locator.
|
|
1816
|
-
* {--end--}
|
|
1817
1870
|
* Appium: not tested
|
|
1818
1871
|
*/
|
|
1819
1872
|
async dragAndDrop(srcElement, destElement) {
|
|
@@ -1879,7 +1932,6 @@ class WebDriverIO extends Helper {
|
|
|
1879
1932
|
* ```
|
|
1880
1933
|
*
|
|
1881
1934
|
* @param {number} sec number of second to wait.
|
|
1882
|
-
* {--end--}
|
|
1883
1935
|
* Appium: support
|
|
1884
1936
|
*/
|
|
1885
1937
|
async wait(sec) {
|
|
@@ -1890,9 +1942,8 @@ class WebDriverIO extends Helper {
|
|
|
1890
1942
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
1891
1943
|
* Element can be located by CSS or XPath.
|
|
1892
1944
|
*
|
|
1893
|
-
* @param {
|
|
1894
|
-
* @param sec (optional) time in seconds to wait, 1 by default.
|
|
1895
|
-
* {--end--}
|
|
1945
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1946
|
+
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
1896
1947
|
* Appium: support
|
|
1897
1948
|
*/
|
|
1898
1949
|
async waitForEnabled(locator, sec = null) {
|
|
@@ -1920,9 +1971,8 @@ class WebDriverIO extends Helper {
|
|
|
1920
1971
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1921
1972
|
* ```
|
|
1922
1973
|
*
|
|
1923
|
-
* @param {
|
|
1924
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1925
|
-
* {--end--}
|
|
1974
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1975
|
+
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
1926
1976
|
* Appium: support
|
|
1927
1977
|
*/
|
|
1928
1978
|
async waitForElement(locator, sec = null) {
|
|
@@ -1949,8 +1999,7 @@ class WebDriverIO extends Helper {
|
|
|
1949
1999
|
* ```
|
|
1950
2000
|
*
|
|
1951
2001
|
* @param {string} urlPart value to check.
|
|
1952
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1953
|
-
* {--end--}
|
|
2002
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1954
2003
|
*/
|
|
1955
2004
|
async waitInUrl(urlPart, sec = null) {
|
|
1956
2005
|
const client = this.browser;
|
|
@@ -1980,8 +2029,7 @@ class WebDriverIO extends Helper {
|
|
|
1980
2029
|
* ```
|
|
1981
2030
|
*
|
|
1982
2031
|
* @param {string} urlPart value to check.
|
|
1983
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1984
|
-
* {--end--}
|
|
2032
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1985
2033
|
*/
|
|
1986
2034
|
async waitUrlEquals(urlPart, sec = null) {
|
|
1987
2035
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2015,9 +2063,8 @@ class WebDriverIO extends Helper {
|
|
|
2015
2063
|
* ```
|
|
2016
2064
|
*
|
|
2017
2065
|
* @param {string }text to wait for.
|
|
2018
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2019
|
-
* @param {
|
|
2020
|
-
* {--end--}
|
|
2066
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2067
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
2021
2068
|
* Appium: support
|
|
2022
2069
|
*/
|
|
2023
2070
|
async waitForText(text, sec = null, context = null) {
|
|
@@ -2046,8 +2093,7 @@ class WebDriverIO extends Helper {
|
|
|
2046
2093
|
*
|
|
2047
2094
|
* @param {string|object} field input field.
|
|
2048
2095
|
* @param {string }value expected value.
|
|
2049
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2050
|
-
* {--end--}
|
|
2096
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2051
2097
|
*/
|
|
2052
2098
|
async waitForValue(field, value, sec = null) {
|
|
2053
2099
|
const client = this.browser;
|
|
@@ -2074,9 +2120,8 @@ class WebDriverIO extends Helper {
|
|
|
2074
2120
|
* I.waitForVisible('#popup');
|
|
2075
2121
|
* ```
|
|
2076
2122
|
*
|
|
2077
|
-
* @param {
|
|
2078
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2079
|
-
* {--end--}
|
|
2123
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2124
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2080
2125
|
* Appium: support
|
|
2081
2126
|
*/
|
|
2082
2127
|
async waitForVisible(locator, sec = null) {
|
|
@@ -2099,10 +2144,9 @@ class WebDriverIO extends Helper {
|
|
|
2099
2144
|
* I.waitNumberOfVisibleElements('a', 3);
|
|
2100
2145
|
* ```
|
|
2101
2146
|
*
|
|
2102
|
-
* @param {
|
|
2147
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2103
2148
|
* @param {number} num number of elements.
|
|
2104
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2105
|
-
* {--end--}
|
|
2149
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2106
2150
|
*/
|
|
2107
2151
|
async waitNumberOfVisibleElements(locator, num, sec = null) {
|
|
2108
2152
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2124,9 +2168,8 @@ class WebDriverIO extends Helper {
|
|
|
2124
2168
|
* I.waitForInvisible('#popup');
|
|
2125
2169
|
* ```
|
|
2126
2170
|
*
|
|
2127
|
-
* @param {
|
|
2128
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2129
|
-
* {--end--}
|
|
2171
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2172
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2130
2173
|
* Appium: support
|
|
2131
2174
|
*/
|
|
2132
2175
|
async waitForInvisible(locator, sec = null) {
|
|
@@ -2150,9 +2193,8 @@ class WebDriverIO extends Helper {
|
|
|
2150
2193
|
* I.waitToHide('#popup');
|
|
2151
2194
|
* ```
|
|
2152
2195
|
*
|
|
2153
|
-
* @param {
|
|
2154
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2155
|
-
* {--end--}
|
|
2196
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2197
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2156
2198
|
* Appium: support
|
|
2157
2199
|
*/
|
|
2158
2200
|
async waitToHide(locator, sec = null) {
|
|
@@ -2172,9 +2214,8 @@ class WebDriverIO extends Helper {
|
|
|
2172
2214
|
* I.waitForDetached('#popup');
|
|
2173
2215
|
* ```
|
|
2174
2216
|
*
|
|
2175
|
-
* @param {
|
|
2176
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2177
|
-
* {--end--}
|
|
2217
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2218
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2178
2219
|
* Appium: support
|
|
2179
2220
|
*/
|
|
2180
2221
|
async waitForDetached(locator, sec = null) {
|
|
@@ -2203,9 +2244,9 @@ class WebDriverIO extends Helper {
|
|
|
2203
2244
|
* ```
|
|
2204
2245
|
*
|
|
2205
2246
|
* @param {string|function} fn to be executed in browser context.
|
|
2206
|
-
* @param {
|
|
2207
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2208
|
-
*
|
|
2247
|
+
* @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
|
|
2248
|
+
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2249
|
+
*
|
|
2209
2250
|
* Appium: support
|
|
2210
2251
|
*/
|
|
2211
2252
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
@@ -2232,10 +2273,9 @@ class WebDriverIO extends Helper {
|
|
|
2232
2273
|
* ```
|
|
2233
2274
|
*
|
|
2234
2275
|
* @param {function|string} fn function which is executed in browser context.
|
|
2235
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2276
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2236
2277
|
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
2237
|
-
* {
|
|
2238
|
-
* @param interval (optional) time in seconds between condition checks.
|
|
2278
|
+
* @param {?number} [interval=null]
|
|
2239
2279
|
* * *Appium*: supported
|
|
2240
2280
|
*/
|
|
2241
2281
|
async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) {
|
|
@@ -2252,16 +2292,17 @@ class WebDriverIO extends Helper {
|
|
|
2252
2292
|
* I.switchTo(); // switch back to main page
|
|
2253
2293
|
* ```
|
|
2254
2294
|
*
|
|
2255
|
-
* @param {
|
|
2256
|
-
* {--end--}
|
|
2295
|
+
* @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
2257
2296
|
* Appium: support only web testing
|
|
2258
2297
|
*/
|
|
2259
2298
|
async switchTo(locator) {
|
|
2260
2299
|
if (Number.isInteger(locator)) {
|
|
2261
2300
|
return this.browser.frame(locator);
|
|
2262
|
-
}
|
|
2301
|
+
}
|
|
2302
|
+
if (!locator) {
|
|
2263
2303
|
return this.browser.frame(null);
|
|
2264
2304
|
}
|
|
2305
|
+
|
|
2265
2306
|
const res = await this._locate(withStrictLocator.call(this, locator), true);
|
|
2266
2307
|
assertElementExists(res, locator);
|
|
2267
2308
|
return this.browser.frame(res.value[0]);
|
|
@@ -2275,8 +2316,8 @@ class WebDriverIO extends Helper {
|
|
|
2275
2316
|
* I.switchToNextTab(2);
|
|
2276
2317
|
* ```
|
|
2277
2318
|
*
|
|
2278
|
-
* @param num (optional) number of tabs to switch forward, default: 1.
|
|
2279
|
-
* @param sec (optional) time in seconds to wait.
|
|
2319
|
+
* @param {number} [num=1] (optional) number of tabs to switch forward, default: 1.
|
|
2320
|
+
* @param {?number} [sec=null] (optional) time in seconds to wait.
|
|
2280
2321
|
*/
|
|
2281
2322
|
async switchToNextTab(num = 1, sec = null) {
|
|
2282
2323
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2301,8 +2342,8 @@ class WebDriverIO extends Helper {
|
|
|
2301
2342
|
* I.switchToPreviousTab(2);
|
|
2302
2343
|
* ```
|
|
2303
2344
|
*
|
|
2304
|
-
* @param num (optional) number of tabs to switch backward, default: 1.
|
|
2305
|
-
* @param sec (optional) time in seconds to wait.
|
|
2345
|
+
* @param {number} [num=1] (optional) number of tabs to switch backward, default: 1.
|
|
2346
|
+
* @param {?number} [sec] (optional) time in seconds to wait.
|
|
2306
2347
|
*/
|
|
2307
2348
|
async switchToPreviousTab(num = 1, sec = null) {
|
|
2308
2349
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2350,7 +2391,6 @@ class WebDriverIO extends Helper {
|
|
|
2350
2391
|
* ```
|
|
2351
2392
|
*
|
|
2352
2393
|
* @returns {Promise<number>} number of open tabs
|
|
2353
|
-
* {--end--}
|
|
2354
2394
|
*/
|
|
2355
2395
|
async grabNumberOfOpenTabs() {
|
|
2356
2396
|
const pages = await this.browser.getTabIds();
|
|
@@ -2363,7 +2403,7 @@ class WebDriverIO extends Helper {
|
|
|
2363
2403
|
* ```js
|
|
2364
2404
|
* I.refreshPage();
|
|
2365
2405
|
* ```
|
|
2366
|
-
*
|
|
2406
|
+
*
|
|
2367
2407
|
*/
|
|
2368
2408
|
async refreshPage() {
|
|
2369
2409
|
const client = this.browser;
|
|
@@ -2376,7 +2416,7 @@ class WebDriverIO extends Helper {
|
|
|
2376
2416
|
* ```js
|
|
2377
2417
|
* I.scrollPageToTop();
|
|
2378
2418
|
* ```
|
|
2379
|
-
*
|
|
2419
|
+
*
|
|
2380
2420
|
*/
|
|
2381
2421
|
scrollPageToTop() {
|
|
2382
2422
|
const client = this.browser;
|
|
@@ -2393,7 +2433,7 @@ class WebDriverIO extends Helper {
|
|
|
2393
2433
|
* ```js
|
|
2394
2434
|
* I.scrollPageToBottom();
|
|
2395
2435
|
* ```
|
|
2396
|
-
*
|
|
2436
|
+
*
|
|
2397
2437
|
*/
|
|
2398
2438
|
scrollPageToBottom() {
|
|
2399
2439
|
const client = this.browser;
|
|
@@ -2492,16 +2532,11 @@ async function forEachAsync(array, callback, option = {}) {
|
|
|
2492
2532
|
const inputArray = Array.isArray(array) ? array : [array];
|
|
2493
2533
|
const values = [];
|
|
2494
2534
|
for (let index = 0; index < inputArray.length; index++) {
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
res
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
} else if (res) {
|
|
2501
|
-
values.push(res);
|
|
2502
|
-
}
|
|
2503
|
-
} catch (err) {
|
|
2504
|
-
throw err;
|
|
2535
|
+
const res = await callback(inputArray[index], index, inputArray);
|
|
2536
|
+
if (Array.isArray(res) && expandArrayResults) {
|
|
2537
|
+
res.forEach(val => values.push(val));
|
|
2538
|
+
} else if (res) {
|
|
2539
|
+
values.push(res);
|
|
2505
2540
|
}
|
|
2506
2541
|
}
|
|
2507
2542
|
if (unifyResults) {
|
|
@@ -2525,15 +2560,11 @@ async function filterAsync(array, callback, option = {}) {
|
|
|
2525
2560
|
const inputArray = Array.isArray(array) ? array : [array];
|
|
2526
2561
|
const values = [];
|
|
2527
2562
|
for (let index = 0; index < inputArray.length; index++) {
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
const value = Array.isArray(res) ? res[0] : res;
|
|
2563
|
+
const res = unify(await callback(inputArray[index], index, inputArray), { extractValue });
|
|
2564
|
+
const value = Array.isArray(res) ? res[0] : res;
|
|
2531
2565
|
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
}
|
|
2535
|
-
} catch (err) {
|
|
2536
|
-
throw err;
|
|
2566
|
+
if (value) {
|
|
2567
|
+
values.push(inputArray[index]);
|
|
2537
2568
|
}
|
|
2538
2569
|
}
|
|
2539
2570
|
return values;
|
|
@@ -2543,8 +2574,8 @@ async function filterAsync(array, callback, option = {}) {
|
|
|
2543
2574
|
// Internal helper method to handle command results (similar behaviour as the unify function from WebDriverIO
|
|
2544
2575
|
// except it does not resolve promises)
|
|
2545
2576
|
//
|
|
2546
|
-
// @param
|
|
2547
|
-
// @param
|
|
2577
|
+
// @param {object[]} items list of items
|
|
2578
|
+
// @param {object} [option] extractValue: set to try to return the .value property of the input items
|
|
2548
2579
|
function unify(items, option = {}) {
|
|
2549
2580
|
const { extractValue = false } = option;
|
|
2550
2581
|
|