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
package/docs/build/Nightmare.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
const path = require('path');
|
|
1
2
|
const requireg = require('requireg');
|
|
3
|
+
const urlResolve = require('url').resolve;
|
|
4
|
+
|
|
2
5
|
const Helper = require('../helper');
|
|
3
6
|
const stringIncludes = require('../assert/include').includes;
|
|
4
7
|
const urlEquals = require('../assert/equal').urlEquals;
|
|
@@ -6,9 +9,7 @@ const equals = require('../assert/equal').equals;
|
|
|
6
9
|
const empty = require('../assert/empty').empty;
|
|
7
10
|
const truth = require('../assert/truth').truth;
|
|
8
11
|
const Locator = require('../locator');
|
|
9
|
-
const path = require('path');
|
|
10
12
|
const ElementNotFound = require('./errors/ElementNotFound');
|
|
11
|
-
const urlResolve = require('url').resolve;
|
|
12
13
|
const {
|
|
13
14
|
xpathLocator,
|
|
14
15
|
fileExists,
|
|
@@ -405,8 +406,7 @@ class Nightmare extends Helper {
|
|
|
405
406
|
* ```
|
|
406
407
|
*
|
|
407
408
|
* @param {string} url url path or global url.
|
|
408
|
-
* {
|
|
409
|
-
* @param headers {object} list of request headers can be passed
|
|
409
|
+
* @param {?object} headers list of request headers can be passed
|
|
410
410
|
*
|
|
411
411
|
*/
|
|
412
412
|
async amOnPage(url, headers = null) {
|
|
@@ -433,7 +433,6 @@ class Nightmare extends Helper {
|
|
|
433
433
|
* ```
|
|
434
434
|
*
|
|
435
435
|
* @param {string} text text value to check.
|
|
436
|
-
* {--end--}
|
|
437
436
|
*/
|
|
438
437
|
async seeInTitle(text) {
|
|
439
438
|
const title = await this.browser.title();
|
|
@@ -448,7 +447,6 @@ class Nightmare extends Helper {
|
|
|
448
447
|
* ```
|
|
449
448
|
*
|
|
450
449
|
* @param {string} text value to check.
|
|
451
|
-
* {--end--}
|
|
452
450
|
*/
|
|
453
451
|
async dontSeeInTitle(text) {
|
|
454
452
|
const title = await this.browser.title();
|
|
@@ -464,7 +462,6 @@ class Nightmare extends Helper {
|
|
|
464
462
|
* ```
|
|
465
463
|
*
|
|
466
464
|
* @returns {Promise<string>} title
|
|
467
|
-
* {--end--}
|
|
468
465
|
*/
|
|
469
466
|
async grabTitle() {
|
|
470
467
|
return this.browser.title();
|
|
@@ -480,7 +477,6 @@ class Nightmare extends Helper {
|
|
|
480
477
|
* ```
|
|
481
478
|
*
|
|
482
479
|
* @returns {Promise<string>} current URL
|
|
483
|
-
* {--end--}
|
|
484
480
|
*/
|
|
485
481
|
async grabCurrentUrl() {
|
|
486
482
|
return this.browser.url();
|
|
@@ -494,7 +490,6 @@ class Nightmare extends Helper {
|
|
|
494
490
|
* ```
|
|
495
491
|
*
|
|
496
492
|
* @param {string} url a fragment to check
|
|
497
|
-
* {--end--}
|
|
498
493
|
*/
|
|
499
494
|
async seeInCurrentUrl(url) {
|
|
500
495
|
const currentUrl = await this.browser.url();
|
|
@@ -505,7 +500,6 @@ class Nightmare extends Helper {
|
|
|
505
500
|
* Checks that current url does not contain a provided fragment.
|
|
506
501
|
*
|
|
507
502
|
* @param {string} url value to check.
|
|
508
|
-
* {--end--}
|
|
509
503
|
*/
|
|
510
504
|
async dontSeeInCurrentUrl(url) {
|
|
511
505
|
const currentUrl = await this.browser.url();
|
|
@@ -523,7 +517,6 @@ class Nightmare extends Helper {
|
|
|
523
517
|
* ```
|
|
524
518
|
*
|
|
525
519
|
* @param {string} url value to check.
|
|
526
|
-
* {--end--}
|
|
527
520
|
*/
|
|
528
521
|
async seeCurrentUrlEquals(url) {
|
|
529
522
|
const currentUrl = await this.browser.url();
|
|
@@ -540,7 +533,6 @@ class Nightmare extends Helper {
|
|
|
540
533
|
* ```
|
|
541
534
|
*
|
|
542
535
|
* @param {string} url value to check.
|
|
543
|
-
* {--end--}
|
|
544
536
|
*/
|
|
545
537
|
async dontSeeCurrentUrlEquals(url) {
|
|
546
538
|
const currentUrl = await this.browser.url();
|
|
@@ -557,8 +549,7 @@ class Nightmare extends Helper {
|
|
|
557
549
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
558
550
|
* ```
|
|
559
551
|
* @param {string} text expected on page.
|
|
560
|
-
* @param {
|
|
561
|
-
* {--end--}
|
|
552
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
562
553
|
*/
|
|
563
554
|
async see(text, context = null) {
|
|
564
555
|
return proceedSee.call(this, 'assert', text, context);
|
|
@@ -574,9 +565,8 @@ class Nightmare extends Helper {
|
|
|
574
565
|
* ```
|
|
575
566
|
*
|
|
576
567
|
* @param {string} text which is not present.
|
|
577
|
-
* @param {
|
|
578
|
-
*
|
|
579
|
-
* {--end--}
|
|
568
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
569
|
+
*
|
|
580
570
|
*/
|
|
581
571
|
dontSee(text, context = null) {
|
|
582
572
|
return proceedSee.call(this, 'negate', text, context);
|
|
@@ -589,8 +579,7 @@ class Nightmare extends Helper {
|
|
|
589
579
|
* ```js
|
|
590
580
|
* I.seeElement('#modal');
|
|
591
581
|
* ```
|
|
592
|
-
* @param {
|
|
593
|
-
* {--end--}
|
|
582
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
594
583
|
*/
|
|
595
584
|
async seeElement(locator) {
|
|
596
585
|
locator = new Locator(locator, 'css');
|
|
@@ -607,8 +596,7 @@ class Nightmare extends Helper {
|
|
|
607
596
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
608
597
|
* ```
|
|
609
598
|
*
|
|
610
|
-
* @param {
|
|
611
|
-
* {--end--}
|
|
599
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
612
600
|
*/
|
|
613
601
|
async dontSeeElement(locator) {
|
|
614
602
|
locator = new Locator(locator, 'css');
|
|
@@ -626,8 +614,8 @@ class Nightmare extends Helper {
|
|
|
626
614
|
* ```js
|
|
627
615
|
* I.seeElementInDOM('#modal');
|
|
628
616
|
* ```
|
|
629
|
-
* @param {
|
|
630
|
-
*
|
|
617
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
618
|
+
*
|
|
631
619
|
*/
|
|
632
620
|
async seeElementInDOM(locator) {
|
|
633
621
|
locator = new Locator(locator, 'css');
|
|
@@ -642,8 +630,7 @@ class Nightmare extends Helper {
|
|
|
642
630
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
643
631
|
* ```
|
|
644
632
|
*
|
|
645
|
-
* @param {
|
|
646
|
-
* {--end--}
|
|
633
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
647
634
|
*/
|
|
648
635
|
async dontSeeElementInDOM(locator) {
|
|
649
636
|
locator = new Locator(locator, 'css');
|
|
@@ -658,7 +645,6 @@ class Nightmare extends Helper {
|
|
|
658
645
|
* I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
659
646
|
* ```
|
|
660
647
|
* @param {string} text value to check.
|
|
661
|
-
* {--end--}
|
|
662
648
|
*/
|
|
663
649
|
async seeInSource(text) {
|
|
664
650
|
const source = await this.browser.evaluate(() => document.documentElement.outerHTML);
|
|
@@ -673,7 +659,7 @@ class Nightmare extends Helper {
|
|
|
673
659
|
* ```
|
|
674
660
|
*
|
|
675
661
|
* @param {string} value to check.
|
|
676
|
-
*
|
|
662
|
+
*
|
|
677
663
|
*/
|
|
678
664
|
async dontSeeInSource(text) {
|
|
679
665
|
const source = await this.browser.evaluate(() => document.documentElement.outerHTML);
|
|
@@ -689,9 +675,9 @@ class Nightmare extends Helper {
|
|
|
689
675
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
690
676
|
* ```
|
|
691
677
|
*
|
|
692
|
-
* @param {
|
|
678
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
693
679
|
* @param {number} num number of elements.
|
|
694
|
-
*
|
|
680
|
+
*
|
|
695
681
|
*/
|
|
696
682
|
async seeNumberOfElements(locator, num) {
|
|
697
683
|
const elements = await this._locate(locator);
|
|
@@ -706,9 +692,9 @@ class Nightmare extends Helper {
|
|
|
706
692
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
707
693
|
* ```
|
|
708
694
|
*
|
|
709
|
-
* @param {
|
|
695
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
710
696
|
* @param {number} num number of elements.
|
|
711
|
-
*
|
|
697
|
+
*
|
|
712
698
|
*/
|
|
713
699
|
async seeNumberOfVisibleElements(locator, num) {
|
|
714
700
|
const res = await this.grabNumberOfVisibleElements(locator);
|
|
@@ -722,9 +708,8 @@ class Nightmare extends Helper {
|
|
|
722
708
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
723
709
|
* ```
|
|
724
710
|
*
|
|
725
|
-
* @param {
|
|
711
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
726
712
|
* @returns {Promise<number>} number of visible elements
|
|
727
|
-
* {--end--}
|
|
728
713
|
*/
|
|
729
714
|
async grabNumberOfVisibleElements(locator) {
|
|
730
715
|
locator = new Locator(locator, 'css');
|
|
@@ -760,9 +745,9 @@ class Nightmare extends Helper {
|
|
|
760
745
|
* I.click({css: 'nav a.login'});
|
|
761
746
|
* ```
|
|
762
747
|
*
|
|
763
|
-
* @param {
|
|
764
|
-
* @param {
|
|
765
|
-
*
|
|
748
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
749
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
750
|
+
*
|
|
766
751
|
*/
|
|
767
752
|
async click(locator, context = null) {
|
|
768
753
|
const el = await findClickable.call(this, locator, context);
|
|
@@ -782,9 +767,9 @@ class Nightmare extends Helper {
|
|
|
782
767
|
* I.doubleClick('.btn.edit');
|
|
783
768
|
* ```
|
|
784
769
|
*
|
|
785
|
-
* @param {
|
|
786
|
-
* @param {
|
|
787
|
-
*
|
|
770
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
771
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
772
|
+
*
|
|
788
773
|
*/
|
|
789
774
|
async doubleClick(locator, context = null) {
|
|
790
775
|
const el = await findClickable.call(this, locator, context);
|
|
@@ -806,9 +791,9 @@ class Nightmare extends Helper {
|
|
|
806
791
|
* I.rightClick('Click me', '.context');
|
|
807
792
|
* ```
|
|
808
793
|
*
|
|
809
|
-
* @param {
|
|
810
|
-
* @param {
|
|
811
|
-
*
|
|
794
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
|
|
795
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
796
|
+
*
|
|
812
797
|
*/
|
|
813
798
|
async rightClick(locator, context = null) {
|
|
814
799
|
const el = await findClickable.call(this, locator, context);
|
|
@@ -827,10 +812,10 @@ class Nightmare extends Helper {
|
|
|
827
812
|
* I.moveCursorTo('#submit', 5,5);
|
|
828
813
|
* ```
|
|
829
814
|
*
|
|
830
|
-
* @param {
|
|
831
|
-
* @param {number} offsetX (optional, `0` by default) X-axis offset.
|
|
832
|
-
* @param {number} offsetY (optional, `0` by default) Y-axis offset.
|
|
833
|
-
*
|
|
815
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
816
|
+
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
817
|
+
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
818
|
+
*
|
|
834
819
|
*/
|
|
835
820
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
836
821
|
locator = new Locator(locator, 'css');
|
|
@@ -866,8 +851,9 @@ class Nightmare extends Helper {
|
|
|
866
851
|
* ```
|
|
867
852
|
*
|
|
868
853
|
* @param {string|function} fn function to be executed in browser context.
|
|
869
|
-
* @param ...
|
|
870
|
-
* {
|
|
854
|
+
* @param {...any} args to be passed to function.
|
|
855
|
+
* @return {Promise<any>}
|
|
856
|
+
*
|
|
871
857
|
*
|
|
872
858
|
* Wrapper for synchronous [evaluate](https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2)
|
|
873
859
|
*/
|
|
@@ -899,8 +885,9 @@ class Nightmare extends Helper {
|
|
|
899
885
|
* ```
|
|
900
886
|
*
|
|
901
887
|
* @param {string|function} fn function to be executed in browser context.
|
|
902
|
-
* @param ...
|
|
903
|
-
* {
|
|
888
|
+
* @param {...any} args to be passed to function.
|
|
889
|
+
* @return {Promise<any>}
|
|
890
|
+
*
|
|
904
891
|
*
|
|
905
892
|
* Wrapper for asynchronous [evaluate](https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2).
|
|
906
893
|
* Unlike NightmareJS implementation calling `done` will return its first argument.
|
|
@@ -916,7 +903,6 @@ class Nightmare extends Helper {
|
|
|
916
903
|
*
|
|
917
904
|
* @param {number} width width in pixels or `maximize`.
|
|
918
905
|
* @param {number} height height in pixels.
|
|
919
|
-
* {--end--}
|
|
920
906
|
*/
|
|
921
907
|
async resizeWindow(width, height) {
|
|
922
908
|
if (width === 'maximize') {
|
|
@@ -936,9 +922,8 @@ class Nightmare extends Helper {
|
|
|
936
922
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
937
923
|
* I.checkOption('agree', '//form');
|
|
938
924
|
* ```
|
|
939
|
-
* @param {
|
|
940
|
-
* @param {
|
|
941
|
-
* {--end--}
|
|
925
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
926
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
942
927
|
*/
|
|
943
928
|
async checkOption(field, context = null) {
|
|
944
929
|
const els = await findCheckable.call(this, field, context);
|
|
@@ -958,9 +943,8 @@ class Nightmare extends Helper {
|
|
|
958
943
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
959
944
|
* I.uncheckOption('agree', '//form');
|
|
960
945
|
* ```
|
|
961
|
-
* @param {
|
|
962
|
-
* @param {
|
|
963
|
-
* {--end--}
|
|
946
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
947
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
964
948
|
*/
|
|
965
949
|
async uncheckOption(field, context = null) {
|
|
966
950
|
const els = await findCheckable.call(this, field, context);
|
|
@@ -983,9 +967,9 @@ class Nightmare extends Helper {
|
|
|
983
967
|
* // or by strict locator
|
|
984
968
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
985
969
|
* ```
|
|
986
|
-
* @param {
|
|
970
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
987
971
|
* @param {string} value text value to fill.
|
|
988
|
-
*
|
|
972
|
+
*
|
|
989
973
|
*/
|
|
990
974
|
async fillField(field, value) {
|
|
991
975
|
const el = await findField.call(this, field);
|
|
@@ -1003,7 +987,6 @@ class Nightmare extends Helper {
|
|
|
1003
987
|
* I.clearField('#email');
|
|
1004
988
|
* ```
|
|
1005
989
|
* @param {string|object} editable field located by label|name|CSS|XPath|strict locator.
|
|
1006
|
-
* {--end--}
|
|
1007
990
|
*/
|
|
1008
991
|
async clearField(field) {
|
|
1009
992
|
return this.fillField(field, '');
|
|
@@ -1016,9 +999,8 @@ class Nightmare extends Helper {
|
|
|
1016
999
|
* ```js
|
|
1017
1000
|
* I.appendField('#myTextField', 'appended');
|
|
1018
1001
|
* ```
|
|
1019
|
-
* @param {
|
|
1002
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
1020
1003
|
* @param {string} value text value to append.
|
|
1021
|
-
* {--end--}
|
|
1022
1004
|
*/
|
|
1023
1005
|
async appendField(field, value) {
|
|
1024
1006
|
const el = await findField.call(this, field);
|
|
@@ -1037,9 +1019,9 @@ class Nightmare extends Helper {
|
|
|
1037
1019
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1038
1020
|
* I.seeInField('#searchform input','Search');
|
|
1039
1021
|
* ```
|
|
1040
|
-
* @param {
|
|
1022
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1041
1023
|
* @param {string} value value to check.
|
|
1042
|
-
*
|
|
1024
|
+
*
|
|
1043
1025
|
*/
|
|
1044
1026
|
async seeInField(field, value) {
|
|
1045
1027
|
return proceedSeeInField.call(this, 'assert', field, value);
|
|
@@ -1054,9 +1036,8 @@ class Nightmare extends Helper {
|
|
|
1054
1036
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1055
1037
|
* ```
|
|
1056
1038
|
*
|
|
1057
|
-
* @param {
|
|
1039
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1058
1040
|
* @param {string} value value to check.
|
|
1059
|
-
* {--end--}
|
|
1060
1041
|
*/
|
|
1061
1042
|
async dontSeeInField(field, value) {
|
|
1062
1043
|
return proceedSeeInField.call(this, 'negate', field, value);
|
|
@@ -1099,8 +1080,8 @@ class Nightmare extends Helper {
|
|
|
1099
1080
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1100
1081
|
* ```
|
|
1101
1082
|
*
|
|
1102
|
-
* @param {
|
|
1103
|
-
*
|
|
1083
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1084
|
+
*
|
|
1104
1085
|
*/
|
|
1105
1086
|
async seeCheckboxIsChecked(field) {
|
|
1106
1087
|
return proceedIsChecked.call(this, 'assert', field);
|
|
@@ -1115,8 +1096,8 @@ class Nightmare extends Helper {
|
|
|
1115
1096
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1116
1097
|
* ```
|
|
1117
1098
|
*
|
|
1118
|
-
* @param {
|
|
1119
|
-
*
|
|
1099
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1100
|
+
*
|
|
1120
1101
|
*/
|
|
1121
1102
|
async dontSeeCheckboxIsChecked(field) {
|
|
1122
1103
|
return proceedIsChecked.call(this, 'negate', field);
|
|
@@ -1132,13 +1113,10 @@ class Nightmare extends Helper {
|
|
|
1132
1113
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1133
1114
|
* ```
|
|
1134
1115
|
*
|
|
1135
|
-
* @param {
|
|
1116
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1136
1117
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
1137
|
-
* {--end--}
|
|
1138
1118
|
*
|
|
1139
1119
|
* Doesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more](https://github.com/rosshinkley/nightmare-upload#important-note-about-setting-file-upload-inputs))
|
|
1140
|
-
*
|
|
1141
|
-
* @param locator CSS locator (XPath not allowed)
|
|
1142
1120
|
*/
|
|
1143
1121
|
async attachFile(locator, pathToFile) {
|
|
1144
1122
|
const file = path.join(global.codecept_dir, pathToFile);
|
|
@@ -1163,9 +1141,8 @@ class Nightmare extends Helper {
|
|
|
1163
1141
|
* ```
|
|
1164
1142
|
* If multiple elements found returns an array of texts.
|
|
1165
1143
|
*
|
|
1166
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
1167
|
-
* @returns {Promise<string>} attribute value
|
|
1168
|
-
* {--end--}
|
|
1144
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1145
|
+
* @returns {Promise<string|string[]>} attribute value
|
|
1169
1146
|
*/
|
|
1170
1147
|
async grabTextFrom(locator) {
|
|
1171
1148
|
locator = new Locator(locator, 'css');
|
|
@@ -1187,9 +1164,8 @@ class Nightmare extends Helper {
|
|
|
1187
1164
|
* ```js
|
|
1188
1165
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
1189
1166
|
* ```
|
|
1190
|
-
* @param {
|
|
1167
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1191
1168
|
* @returns {Promise<string>} attribute value
|
|
1192
|
-
* {--end--}
|
|
1193
1169
|
*/
|
|
1194
1170
|
async grabValueFrom(locator) {
|
|
1195
1171
|
const el = await findField.call(this, locator);
|
|
@@ -1205,10 +1181,9 @@ class Nightmare extends Helper {
|
|
|
1205
1181
|
* ```js
|
|
1206
1182
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
1207
1183
|
* ```
|
|
1208
|
-
* @param {
|
|
1184
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1209
1185
|
* @param {string} attr attribute name.
|
|
1210
1186
|
* @returns {Promise<string>} attribute value
|
|
1211
|
-
* {--end--}
|
|
1212
1187
|
*/
|
|
1213
1188
|
async grabAttributeFrom(locator, attr) {
|
|
1214
1189
|
locator = new Locator(locator, 'css');
|
|
@@ -1233,9 +1208,8 @@ class Nightmare extends Helper {
|
|
|
1233
1208
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
1234
1209
|
* ```
|
|
1235
1210
|
*
|
|
1236
|
-
* @param
|
|
1211
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
1237
1212
|
* @returns {Promise<string>} HTML code for an element
|
|
1238
|
-
* {--end--}
|
|
1239
1213
|
*/
|
|
1240
1214
|
async grabHTMLFrom(locator) {
|
|
1241
1215
|
locator = new Locator(locator, 'css');
|
|
@@ -1276,9 +1250,8 @@ class Nightmare extends Helper {
|
|
|
1276
1250
|
* ```js
|
|
1277
1251
|
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1278
1252
|
* ```
|
|
1279
|
-
* @param {
|
|
1280
|
-
* @param {string|
|
|
1281
|
-
* {--end--}
|
|
1253
|
+
* @param {CodeceptJS.LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
|
|
1254
|
+
* @param {string|Array<*>} option visible text or value of option.
|
|
1282
1255
|
*/
|
|
1283
1256
|
async selectOption(select, option) {
|
|
1284
1257
|
const fetchAndCheckOption = function (el, locator) {
|
|
@@ -1328,7 +1301,6 @@ class Nightmare extends Helper {
|
|
|
1328
1301
|
* ```
|
|
1329
1302
|
*
|
|
1330
1303
|
* @param {object} cookie a cookie object.
|
|
1331
|
-
* {--end--}
|
|
1332
1304
|
*
|
|
1333
1305
|
* Wrapper for `.cookies.set(cookie)`.
|
|
1334
1306
|
* [See more](https://github.com/segmentio/nightmare/blob/master/Readme.md#cookiessetcookie)
|
|
@@ -1345,7 +1317,7 @@ class Nightmare extends Helper {
|
|
|
1345
1317
|
* ```
|
|
1346
1318
|
*
|
|
1347
1319
|
* @param {string} name cookie name.
|
|
1348
|
-
*
|
|
1320
|
+
*
|
|
1349
1321
|
*
|
|
1350
1322
|
*/
|
|
1351
1323
|
async seeCookie(name) {
|
|
@@ -1361,7 +1333,6 @@ class Nightmare extends Helper {
|
|
|
1361
1333
|
* ```
|
|
1362
1334
|
*
|
|
1363
1335
|
* @param {string} name cookie name.
|
|
1364
|
-
* {--end--}
|
|
1365
1336
|
*/
|
|
1366
1337
|
async dontSeeCookie(name) {
|
|
1367
1338
|
const res = await this.browser.cookies.get(name);
|
|
@@ -1371,18 +1342,17 @@ class Nightmare extends Helper {
|
|
|
1371
1342
|
/**
|
|
1372
1343
|
* Gets a cookie object by name.
|
|
1373
1344
|
* If none provided gets all cookies.
|
|
1374
|
-
*
|
|
1345
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1375
1346
|
*
|
|
1376
1347
|
* ```js
|
|
1377
1348
|
* let cookie = await I.grabCookie('auth');
|
|
1378
1349
|
* assert(cookie.value, '123456');
|
|
1379
1350
|
* ```
|
|
1380
1351
|
*
|
|
1381
|
-
* @param [name=null] cookie name.
|
|
1352
|
+
* @param {?string} [name=null] cookie name.
|
|
1382
1353
|
* @returns {Promise<string>} attribute value
|
|
1383
|
-
* {--end--}
|
|
1384
1354
|
*
|
|
1385
|
-
*
|
|
1355
|
+
* Cookie in JSON format. If name not passed returns all cookies for this domain.
|
|
1386
1356
|
*
|
|
1387
1357
|
* Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
|
|
1388
1358
|
*/
|
|
@@ -1399,8 +1369,7 @@ class Nightmare extends Helper {
|
|
|
1399
1369
|
* I.clearCookie('test');
|
|
1400
1370
|
* ```
|
|
1401
1371
|
*
|
|
1402
|
-
* @param {string} cookie (optional, `null` by default) cookie name
|
|
1403
|
-
* {--end--}
|
|
1372
|
+
* @param {?string} [cookie=null] (optional, `null` by default) cookie name
|
|
1404
1373
|
*/
|
|
1405
1374
|
async clearCookie(cookie) {
|
|
1406
1375
|
if (!cookie) {
|
|
@@ -1424,9 +1393,9 @@ class Nightmare extends Helper {
|
|
|
1424
1393
|
* ```
|
|
1425
1394
|
*
|
|
1426
1395
|
* @param {string|function} fn to be executed in browser context.
|
|
1427
|
-
* @param {
|
|
1428
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1429
|
-
*
|
|
1396
|
+
* @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
|
|
1397
|
+
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
1398
|
+
*
|
|
1430
1399
|
*/
|
|
1431
1400
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
1432
1401
|
let args = [];
|
|
@@ -1449,7 +1418,6 @@ class Nightmare extends Helper {
|
|
|
1449
1418
|
* ```
|
|
1450
1419
|
*
|
|
1451
1420
|
* @param {number} sec number of second to wait.
|
|
1452
|
-
* {--end--}
|
|
1453
1421
|
*/
|
|
1454
1422
|
async wait(sec) {
|
|
1455
1423
|
return new Promise(((done) => {
|
|
@@ -1468,9 +1436,8 @@ class Nightmare extends Helper {
|
|
|
1468
1436
|
* ```
|
|
1469
1437
|
*
|
|
1470
1438
|
* @param {string }text to wait for.
|
|
1471
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1472
|
-
* @param {
|
|
1473
|
-
* {--end--}
|
|
1439
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1440
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
1474
1441
|
*/
|
|
1475
1442
|
async waitForText(text, sec, context = null) {
|
|
1476
1443
|
if (!context) {
|
|
@@ -1497,9 +1464,8 @@ class Nightmare extends Helper {
|
|
|
1497
1464
|
* I.waitForVisible('#popup');
|
|
1498
1465
|
* ```
|
|
1499
1466
|
*
|
|
1500
|
-
* @param {
|
|
1501
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1502
|
-
* {--end--}
|
|
1467
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1468
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1503
1469
|
*/
|
|
1504
1470
|
waitForVisible(locator, sec) {
|
|
1505
1471
|
this.browser.options.waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -1524,9 +1490,8 @@ class Nightmare extends Helper {
|
|
|
1524
1490
|
* I.waitToHide('#popup');
|
|
1525
1491
|
* ```
|
|
1526
1492
|
*
|
|
1527
|
-
* @param {
|
|
1528
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1529
|
-
* {--end--}
|
|
1493
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1494
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1530
1495
|
*/
|
|
1531
1496
|
async waitToHide(locator, sec = null) {
|
|
1532
1497
|
return this.waitForInvisible(locator, sec);
|
|
@@ -1540,9 +1505,8 @@ class Nightmare extends Helper {
|
|
|
1540
1505
|
* I.waitForInvisible('#popup');
|
|
1541
1506
|
* ```
|
|
1542
1507
|
*
|
|
1543
|
-
* @param {
|
|
1544
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1545
|
-
* {--end--}
|
|
1508
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1509
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1546
1510
|
*/
|
|
1547
1511
|
waitForInvisible(locator, sec) {
|
|
1548
1512
|
this.browser.options.waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -1568,9 +1532,8 @@ class Nightmare extends Helper {
|
|
|
1568
1532
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1569
1533
|
* ```
|
|
1570
1534
|
*
|
|
1571
|
-
* @param {
|
|
1572
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1573
|
-
* {--end--}
|
|
1535
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1536
|
+
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
1574
1537
|
*/
|
|
1575
1538
|
async waitForElement(locator, sec) {
|
|
1576
1539
|
this.browser.options.waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -1598,9 +1561,8 @@ class Nightmare extends Helper {
|
|
|
1598
1561
|
* I.waitForDetached('#popup');
|
|
1599
1562
|
* ```
|
|
1600
1563
|
*
|
|
1601
|
-
* @param {
|
|
1602
|
-
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1603
|
-
* {--end--}
|
|
1564
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1565
|
+
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
1604
1566
|
*/
|
|
1605
1567
|
async waitForDetached(locator, sec) {
|
|
1606
1568
|
this.browser.options.waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -1620,7 +1582,7 @@ class Nightmare extends Helper {
|
|
|
1620
1582
|
* ```js
|
|
1621
1583
|
* I.refreshPage();
|
|
1622
1584
|
* ```
|
|
1623
|
-
*
|
|
1585
|
+
*
|
|
1624
1586
|
*/
|
|
1625
1587
|
async refreshPage() {
|
|
1626
1588
|
return this.browser.refresh();
|
|
@@ -1645,8 +1607,7 @@ class Nightmare extends Helper {
|
|
|
1645
1607
|
* ```
|
|
1646
1608
|
*
|
|
1647
1609
|
* @param {string} fileName file name to save.
|
|
1648
|
-
* @param {boolean} fullPage (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1649
|
-
* {--end--}
|
|
1610
|
+
* @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
1650
1611
|
*/
|
|
1651
1612
|
async saveScreenshot(fileName, fullPage = this.options.fullPageScreenshots) {
|
|
1652
1613
|
const outputFile = screenshotOutputFolder(fileName);
|
|
@@ -1677,10 +1638,9 @@ class Nightmare extends Helper {
|
|
|
1677
1638
|
* I.scrollTo('#submit', 5, 5);
|
|
1678
1639
|
* ```
|
|
1679
1640
|
*
|
|
1680
|
-
* @param {
|
|
1681
|
-
* @param {number} offsetX (optional, `0` by default) X-axis offset.
|
|
1682
|
-
* @param {number} offsetY (optional, `0` by default) Y-axis offset.
|
|
1683
|
-
* {--end--}
|
|
1641
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1642
|
+
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
1643
|
+
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
1684
1644
|
*/
|
|
1685
1645
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
1686
1646
|
if (typeof locator === 'number' && typeof offsetX === 'number') {
|
|
@@ -1707,7 +1667,7 @@ class Nightmare extends Helper {
|
|
|
1707
1667
|
* ```js
|
|
1708
1668
|
* I.scrollPageToTop();
|
|
1709
1669
|
* ```
|
|
1710
|
-
*
|
|
1670
|
+
*
|
|
1711
1671
|
*/
|
|
1712
1672
|
async scrollPageToTop() {
|
|
1713
1673
|
return this.executeScript(() => window.scrollTo(0, 0));
|
|
@@ -1719,7 +1679,7 @@ class Nightmare extends Helper {
|
|
|
1719
1679
|
* ```js
|
|
1720
1680
|
* I.scrollPageToBottom();
|
|
1721
1681
|
* ```
|
|
1722
|
-
*
|
|
1682
|
+
*
|
|
1723
1683
|
*/
|
|
1724
1684
|
async scrollPageToBottom() {
|
|
1725
1685
|
/* eslint-disable prefer-arrow-callback, comma-dangle */
|
|
@@ -1742,8 +1702,7 @@ class Nightmare extends Helper {
|
|
|
1742
1702
|
* let { x, y } = await I.grabPageScrollPosition();
|
|
1743
1703
|
* ```
|
|
1744
1704
|
*
|
|
1745
|
-
* @returns {Promise<
|
|
1746
|
-
* {--end--}
|
|
1705
|
+
* @returns {Promise<Object<string, *>>} scroll position
|
|
1747
1706
|
*/
|
|
1748
1707
|
async grabPageScrollPosition() {
|
|
1749
1708
|
/* eslint-disable comma-dangle */
|