codeceptjs 2.1.3 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -37
- package/README.md +15 -22
- package/bin/codecept.js +4 -1
- package/docs/acceptance.md +44 -1
- package/docs/advanced.md +1 -1
- package/docs/angular.md +6 -9
- package/docs/basics.md +388 -75
- package/docs/bdd.md +4 -3
- package/docs/best.md +1 -1
- package/docs/books.md +31 -0
- package/docs/build/Appium.js +215 -176
- package/docs/build/Nightmare.js +618 -489
- package/docs/build/Polly.js +189 -0
- package/docs/build/Protractor.js +747 -608
- package/docs/build/Puppeteer.js +914 -633
- package/docs/build/REST.js +1 -1
- package/docs/build/TestCafe.js +1835 -0
- package/docs/build/WebDriver.js +861 -805
- package/docs/build/WebDriverIO.js +616 -617
- package/docs/changelog.md +410 -316
- package/docs/commands.md +6 -6
- package/docs/community-helpers.md +2 -0
- package/docs/detox.md +235 -0
- package/docs/examples.md +23 -0
- package/docs/helpers/ApiDataFactory.md +11 -10
- package/docs/helpers/Appium.md +130 -61
- package/docs/helpers/Detox.md +579 -0
- package/docs/helpers/FileSystem.md +2 -1
- package/docs/helpers/Mochawesome.md +1 -0
- package/docs/helpers/Nightmare.md +348 -128
- package/docs/helpers/Polly.md +85 -0
- package/docs/helpers/Protractor.md +451 -184
- package/docs/helpers/Puppeteer-firefox.md +55 -0
- package/docs/helpers/Puppeteer.md +619 -183
- package/docs/helpers/REST.md +17 -16
- package/docs/helpers/SeleniumWebdriver.md +9 -8
- package/docs/helpers/TestCafe.md +1168 -0
- package/docs/helpers/WebDriver.md +600 -291
- package/docs/helpers/WebDriverIO.md +393 -278
- package/docs/helpers.md +37 -18
- package/docs/locators.md +2 -0
- package/docs/mobile-react-native-locators.md +64 -0
- package/docs/mobile.md +5 -0
- package/docs/plugins.md +54 -13
- package/docs/puppeteer.md +74 -26
- package/docs/quickstart.md +47 -12
- package/docs/react.md +67 -0
- package/docs/reports.md +1 -1
- package/docs/{webapi/_keys.mustache → shared/keys.mustache} +0 -0
- package/docs/shared/react.mustache +1 -0
- package/docs/testcafe.md +157 -0
- package/docs/videos.md +19 -0
- package/docs/webapi/amOnPage.mustache +1 -1
- package/docs/webapi/appendField.mustache +2 -2
- package/docs/webapi/attachFile.mustache +2 -2
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/clearField.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +3 -3
- package/docs/webapi/dontSee.mustache +6 -3
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +7 -1
- package/docs/webapi/dontSeeCookie.mustache +5 -1
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +6 -1
- package/docs/webapi/dontSeeElement.mustache +5 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +5 -1
- package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +7 -2
- package/docs/webapi/dontSeeInSource.mustache +5 -1
- package/docs/webapi/dontSeeInTitle.mustache +5 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +2 -2
- package/docs/webapi/dragAndDrop.mustache +2 -2
- package/docs/webapi/dragSlider.mustache +2 -2
- package/docs/webapi/executeAsyncScript.mustache +1 -1
- package/docs/webapi/executeScript.mustache +1 -1
- package/docs/webapi/fillField.mustache +2 -2
- package/docs/webapi/grabAttributeFrom.mustache +3 -2
- package/docs/webapi/grabBrowserLogs.mustache +3 -1
- package/docs/webapi/grabCookie.mustache +2 -1
- package/docs/webapi/grabCssPropertyFrom.mustache +3 -2
- package/docs/webapi/grabCurrentUrl.mustache +3 -1
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +19 -0
- package/docs/webapi/grabHTMLFrom.mustache +2 -1
- package/docs/webapi/grabNumberOfOpenTabs.mustache +4 -2
- package/docs/webapi/grabNumberOfVisibleElements.mustache +3 -2
- package/docs/webapi/grabPageScrollPosition.mustache +3 -1
- package/docs/webapi/grabSource.mustache +3 -1
- package/docs/webapi/grabTextFrom.mustache +2 -1
- package/docs/webapi/grabTitle.mustache +3 -1
- package/docs/webapi/grabValueFrom.mustache +2 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/resizeWindow.mustache +2 -2
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +3 -3
- package/docs/webapi/say.mustache +2 -2
- package/docs/webapi/scrollPageToBottom.mustache +1 -1
- package/docs/webapi/scrollPageToTop.mustache +1 -1
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +2 -2
- package/docs/webapi/seeAttributesOnElements.mustache +3 -3
- package/docs/webapi/seeCheckboxIsChecked.mustache +2 -1
- package/docs/webapi/seeCookie.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -2
- package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInCurrentUrl.mustache +1 -1
- package/docs/webapi/seeInField.mustache +2 -2
- package/docs/webapi/seeInSource.mustache +1 -1
- package/docs/webapi/seeInTitle.mustache +5 -1
- package/docs/webapi/seeNumberOfElements.mustache +10 -0
- package/docs/webapi/seeNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/setCookie.mustache +1 -1
- package/docs/webapi/switchTo.mustache +6 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/wait.mustache +1 -2
- package/docs/webapi/waitForDetached.mustache +3 -3
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +1 -1
- package/docs/webapi/waitForFunction.mustache +3 -3
- package/docs/webapi/waitForInvisible.mustache +3 -3
- package/docs/webapi/waitForText.mustache +3 -3
- package/docs/webapi/waitForValue.mustache +3 -3
- package/docs/webapi/waitForVisible.mustache +3 -3
- package/docs/webapi/waitInUrl.mustache +2 -2
- package/docs/webapi/waitNumberOfVisibleElements.mustache +3 -3
- package/docs/webapi/waitToHide.mustache +3 -3
- package/docs/webapi/waitUntil.mustache +3 -3
- package/docs/webapi/waitUrlEquals.mustache +2 -2
- package/docs/webdriver.md +453 -0
- package/lib/codecept.js +11 -9
- package/lib/command/definitions.js +183 -30
- package/lib/command/gherkin/snippets.js +29 -9
- package/lib/command/init.js +31 -9
- package/lib/command/run-multiple.js +46 -59
- package/lib/command/utils.js +1 -1
- package/lib/container.js +30 -4
- package/lib/data/dataScenarioConfig.js +18 -0
- package/lib/helper/Appium.js +24 -24
- package/lib/helper/Nightmare.js +81 -84
- package/lib/helper/Polly.js +189 -0
- package/lib/helper/Protractor.js +96 -86
- package/lib/helper/Puppeteer.js +238 -113
- package/lib/helper/REST.js +1 -1
- package/lib/helper/TestCafe.js +1257 -0
- package/lib/helper/WebDriver.js +217 -277
- package/lib/helper/WebDriverIO.js +75 -75
- package/lib/helper/clientscripts/nightmare.js +8 -0
- package/lib/helper/extras/React.js +55 -0
- package/lib/helper/testcafe/testControllerHolder.js +42 -0
- package/lib/helper/testcafe/testcafe-utils.js +63 -0
- package/lib/history.js +39 -0
- package/lib/hooks.js +25 -1
- package/lib/interfaces/gherkin.js +17 -1
- package/lib/interfaces/scenarioConfig.js +2 -2
- package/lib/listener/config.js +3 -3
- package/lib/locator.js +6 -0
- package/lib/pause.js +22 -1
- package/lib/plugin/allure.js +63 -0
- package/lib/plugin/autoLogin.js +65 -16
- package/lib/plugin/puppeteerCoverage.js +6 -1
- package/lib/plugin/stepByStepReport.js +4 -3
- package/lib/scenario.js +23 -17
- package/lib/step.js +5 -2
- package/lib/ui.js +1 -1
- package/lib/utils.js +70 -20
- package/package.json +20 -19
- package/translations/de-DE.js +69 -0
- package/translations/index.js +1 -0
- package/docs/video.md +0 -26
package/lib/helper/Protractor.js
CHANGED
|
@@ -13,7 +13,6 @@ const truth = require('../assert/truth').truth;
|
|
|
13
13
|
const {
|
|
14
14
|
xpathLocator,
|
|
15
15
|
fileExists,
|
|
16
|
-
clearString,
|
|
17
16
|
convertCssPropertiesToCamelCase,
|
|
18
17
|
screenshotOutputFolder,
|
|
19
18
|
} = require('../utils');
|
|
@@ -25,7 +24,6 @@ const ElementNotFound = require('./errors/ElementNotFound');
|
|
|
25
24
|
const ConnectionRefused = require('./errors/ConnectionRefused');
|
|
26
25
|
const Locator = require('../locator');
|
|
27
26
|
const path = require('path');
|
|
28
|
-
const recorder = require('../recorder');
|
|
29
27
|
|
|
30
28
|
let withinStore = {};
|
|
31
29
|
let Runner;
|
|
@@ -424,7 +422,7 @@ class Protractor extends Helper {
|
|
|
424
422
|
}
|
|
425
423
|
|
|
426
424
|
/**
|
|
427
|
-
* {{>
|
|
425
|
+
* {{> amOnPage }}
|
|
428
426
|
*/
|
|
429
427
|
async amOnPage(url) {
|
|
430
428
|
if (!(/^\w+\:\/\//.test(url))) {
|
|
@@ -436,7 +434,7 @@ class Protractor extends Helper {
|
|
|
436
434
|
}
|
|
437
435
|
|
|
438
436
|
/**
|
|
439
|
-
* {{>
|
|
437
|
+
* {{> click }}
|
|
440
438
|
*/
|
|
441
439
|
async click(locator, context = null) {
|
|
442
440
|
let matcher = this.browser;
|
|
@@ -450,7 +448,7 @@ class Protractor extends Helper {
|
|
|
450
448
|
}
|
|
451
449
|
|
|
452
450
|
/**
|
|
453
|
-
* {{>
|
|
451
|
+
* {{> doubleClick }}
|
|
454
452
|
*/
|
|
455
453
|
async doubleClick(locator, context = null) {
|
|
456
454
|
let matcher = this.browser;
|
|
@@ -464,7 +462,7 @@ class Protractor extends Helper {
|
|
|
464
462
|
}
|
|
465
463
|
|
|
466
464
|
/**
|
|
467
|
-
* {{>
|
|
465
|
+
* {{> rightClick }}
|
|
468
466
|
*/
|
|
469
467
|
async rightClick(locator, context = null) {
|
|
470
468
|
/**
|
|
@@ -486,7 +484,7 @@ class Protractor extends Helper {
|
|
|
486
484
|
}
|
|
487
485
|
|
|
488
486
|
/**
|
|
489
|
-
* {{>
|
|
487
|
+
* {{> moveCursorTo }}
|
|
490
488
|
*/
|
|
491
489
|
async moveCursorTo(locator, offsetX = null, offsetY = null) {
|
|
492
490
|
let offset = null;
|
|
@@ -499,7 +497,7 @@ class Protractor extends Helper {
|
|
|
499
497
|
}
|
|
500
498
|
|
|
501
499
|
/**
|
|
502
|
-
* {{>
|
|
500
|
+
* {{> see }}
|
|
503
501
|
*/
|
|
504
502
|
async see(text, context = null) {
|
|
505
503
|
return proceedSee.call(this, 'assert', text, context);
|
|
@@ -517,28 +515,28 @@ class Protractor extends Helper {
|
|
|
517
515
|
}
|
|
518
516
|
|
|
519
517
|
/**
|
|
520
|
-
* {{>
|
|
518
|
+
* {{> dontSee }}
|
|
521
519
|
*/
|
|
522
520
|
dontSee(text, context = null) {
|
|
523
521
|
return proceedSee.call(this, 'negate', text, context);
|
|
524
522
|
}
|
|
525
523
|
|
|
526
524
|
/**
|
|
527
|
-
* {{>
|
|
525
|
+
* {{> grabBrowserLogs }}
|
|
528
526
|
*/
|
|
529
527
|
async grabBrowserLogs() {
|
|
530
528
|
return this.browser.manage().logs().get('browser');
|
|
531
529
|
}
|
|
532
530
|
|
|
533
531
|
/**
|
|
534
|
-
* {{>
|
|
532
|
+
* {{> grabCurrentUrl }}
|
|
535
533
|
*/
|
|
536
534
|
async grabCurrentUrl() {
|
|
537
535
|
return this.browser.getCurrentUrl();
|
|
538
536
|
}
|
|
539
537
|
|
|
540
538
|
/**
|
|
541
|
-
* {{>
|
|
539
|
+
* {{> selectOption }}
|
|
542
540
|
*/
|
|
543
541
|
async selectOption(select, option) {
|
|
544
542
|
const fields = await findFields(this.browser, select);
|
|
@@ -561,7 +559,7 @@ class Protractor extends Helper {
|
|
|
561
559
|
}
|
|
562
560
|
|
|
563
561
|
/**
|
|
564
|
-
* {{>
|
|
562
|
+
* {{> fillField }}
|
|
565
563
|
*/
|
|
566
564
|
async fillField(field, value) {
|
|
567
565
|
const els = await findFields(this.browser, field);
|
|
@@ -570,8 +568,8 @@ class Protractor extends Helper {
|
|
|
570
568
|
}
|
|
571
569
|
|
|
572
570
|
/**
|
|
573
|
-
* {{>
|
|
574
|
-
* {{
|
|
571
|
+
* {{> pressKey }}
|
|
572
|
+
* {{ keys }}
|
|
575
573
|
*/
|
|
576
574
|
async pressKey(key) {
|
|
577
575
|
let modifier;
|
|
@@ -593,7 +591,7 @@ class Protractor extends Helper {
|
|
|
593
591
|
}
|
|
594
592
|
|
|
595
593
|
/**
|
|
596
|
-
* {{>
|
|
594
|
+
* {{> attachFile }}
|
|
597
595
|
*/
|
|
598
596
|
async attachFile(locator, pathToFile) {
|
|
599
597
|
const file = path.join(global.codecept_dir, pathToFile);
|
|
@@ -610,21 +608,21 @@ class Protractor extends Helper {
|
|
|
610
608
|
}
|
|
611
609
|
|
|
612
610
|
/**
|
|
613
|
-
* {{>
|
|
611
|
+
* {{> seeInField }}
|
|
614
612
|
*/
|
|
615
613
|
async seeInField(field, value) {
|
|
616
614
|
return proceedSeeInField.call(this, 'assert', field, value);
|
|
617
615
|
}
|
|
618
616
|
|
|
619
617
|
/**
|
|
620
|
-
* {{>
|
|
618
|
+
* {{> dontSeeInField }}
|
|
621
619
|
*/
|
|
622
620
|
async dontSeeInField(field, value) {
|
|
623
621
|
return proceedSeeInField.call(this, 'negate', field, value);
|
|
624
622
|
}
|
|
625
623
|
|
|
626
624
|
/**
|
|
627
|
-
* {{>
|
|
625
|
+
* {{> appendField }}
|
|
628
626
|
*/
|
|
629
627
|
async appendField(field, value) {
|
|
630
628
|
const els = await findFields(this.browser, field);
|
|
@@ -633,7 +631,7 @@ class Protractor extends Helper {
|
|
|
633
631
|
}
|
|
634
632
|
|
|
635
633
|
/**
|
|
636
|
-
* {{>
|
|
634
|
+
* {{> clearField }}
|
|
637
635
|
*/
|
|
638
636
|
async clearField(field) {
|
|
639
637
|
const els = await findFields(this.browser, field);
|
|
@@ -642,7 +640,7 @@ class Protractor extends Helper {
|
|
|
642
640
|
}
|
|
643
641
|
|
|
644
642
|
/**
|
|
645
|
-
* {{>
|
|
643
|
+
* {{> checkOption }}
|
|
646
644
|
*/
|
|
647
645
|
async checkOption(field, context = null) {
|
|
648
646
|
let matcher = this.browser;
|
|
@@ -658,21 +656,37 @@ class Protractor extends Helper {
|
|
|
658
656
|
}
|
|
659
657
|
|
|
660
658
|
/**
|
|
661
|
-
* {{>
|
|
659
|
+
* {{> uncheckOption }}
|
|
660
|
+
*/
|
|
661
|
+
async uncheckOption(field, context = null) {
|
|
662
|
+
let matcher = this.browser;
|
|
663
|
+
if (context) {
|
|
664
|
+
const els = await this._locate(context, true);
|
|
665
|
+
assertElementExists(els, context);
|
|
666
|
+
matcher = els[0];
|
|
667
|
+
}
|
|
668
|
+
const els = await findCheckable(matcher, field);
|
|
669
|
+
assertElementExists(els, field, 'Checkbox or radio');
|
|
670
|
+
const isSelected = await els[0].isSelected();
|
|
671
|
+
if (isSelected) return els[0].click();
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* {{> seeCheckboxIsChecked }}
|
|
662
676
|
*/
|
|
663
677
|
async seeCheckboxIsChecked(field) {
|
|
664
678
|
return proceedIsChecked.call(this, 'assert', field);
|
|
665
679
|
}
|
|
666
680
|
|
|
667
681
|
/**
|
|
668
|
-
* {{>
|
|
682
|
+
* {{> dontSeeCheckboxIsChecked }}
|
|
669
683
|
*/
|
|
670
684
|
async dontSeeCheckboxIsChecked(field) {
|
|
671
685
|
return proceedIsChecked.call(this, 'negate', field);
|
|
672
686
|
}
|
|
673
687
|
|
|
674
688
|
/**
|
|
675
|
-
* {{>
|
|
689
|
+
* {{> grabTextFrom }}
|
|
676
690
|
*/
|
|
677
691
|
async grabTextFrom(locator) {
|
|
678
692
|
const els = await this._locate(locator);
|
|
@@ -686,7 +700,7 @@ class Protractor extends Helper {
|
|
|
686
700
|
}
|
|
687
701
|
|
|
688
702
|
/**
|
|
689
|
-
* {{>
|
|
703
|
+
* {{> grabHTMLFrom }}
|
|
690
704
|
*/
|
|
691
705
|
async grabHTMLFrom(locator) {
|
|
692
706
|
const els = await this._locate(locator);
|
|
@@ -703,7 +717,7 @@ class Protractor extends Helper {
|
|
|
703
717
|
}
|
|
704
718
|
|
|
705
719
|
/**
|
|
706
|
-
* {{>
|
|
720
|
+
* {{> grabValueFrom }}
|
|
707
721
|
*/
|
|
708
722
|
async grabValueFrom(locator) {
|
|
709
723
|
const els = await findFields(this.browser, locator);
|
|
@@ -712,7 +726,7 @@ class Protractor extends Helper {
|
|
|
712
726
|
}
|
|
713
727
|
|
|
714
728
|
/**
|
|
715
|
-
* {{>
|
|
729
|
+
* {{> grabCssPropertyFrom }}
|
|
716
730
|
*/
|
|
717
731
|
async grabCssPropertyFrom(locator, cssProperty) {
|
|
718
732
|
const els = await this._locate(locator, true);
|
|
@@ -726,7 +740,7 @@ class Protractor extends Helper {
|
|
|
726
740
|
}
|
|
727
741
|
|
|
728
742
|
/**
|
|
729
|
-
* {{>
|
|
743
|
+
* {{> grabAttributeFrom }}
|
|
730
744
|
*/
|
|
731
745
|
async grabAttributeFrom(locator, attr) {
|
|
732
746
|
const els = await this._locate(locator);
|
|
@@ -740,7 +754,7 @@ class Protractor extends Helper {
|
|
|
740
754
|
return array.length === 1 ? array[0] : array;
|
|
741
755
|
}
|
|
742
756
|
/**
|
|
743
|
-
* {{>
|
|
757
|
+
* {{> seeInTitle }}
|
|
744
758
|
*/
|
|
745
759
|
async seeInTitle(text) {
|
|
746
760
|
return this.browser.getTitle().then(title => stringIncludes('web page title').assert(text, title));
|
|
@@ -759,14 +773,14 @@ class Protractor extends Helper {
|
|
|
759
773
|
}
|
|
760
774
|
|
|
761
775
|
/**
|
|
762
|
-
* {{>
|
|
776
|
+
* {{> dontSeeInTitle }}
|
|
763
777
|
*/
|
|
764
778
|
async dontSeeInTitle(text) {
|
|
765
779
|
return this.browser.getTitle().then(title => stringIncludes('web page title').negate(text, title));
|
|
766
780
|
}
|
|
767
781
|
|
|
768
782
|
/**
|
|
769
|
-
* {{>
|
|
783
|
+
* {{> grabTitle }}
|
|
770
784
|
*/
|
|
771
785
|
async grabTitle() {
|
|
772
786
|
return this.browser.getTitle().then((title) => {
|
|
@@ -776,7 +790,7 @@ class Protractor extends Helper {
|
|
|
776
790
|
}
|
|
777
791
|
|
|
778
792
|
/**
|
|
779
|
-
* {{>
|
|
793
|
+
* {{> seeElement }}
|
|
780
794
|
*/
|
|
781
795
|
async seeElement(locator) {
|
|
782
796
|
let els = await this._locate(locator, true);
|
|
@@ -785,7 +799,7 @@ class Protractor extends Helper {
|
|
|
785
799
|
}
|
|
786
800
|
|
|
787
801
|
/**
|
|
788
|
-
* {{>
|
|
802
|
+
* {{> dontSeeElement }}
|
|
789
803
|
*/
|
|
790
804
|
async dontSeeElement(locator) {
|
|
791
805
|
let els = await this._locate(locator, false);
|
|
@@ -794,55 +808,50 @@ class Protractor extends Helper {
|
|
|
794
808
|
}
|
|
795
809
|
|
|
796
810
|
/**
|
|
797
|
-
* {{>
|
|
811
|
+
* {{> seeElementInDOM }}
|
|
798
812
|
*/
|
|
799
813
|
async seeElementInDOM(locator) {
|
|
800
814
|
return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').negate(els.fill('ELEMENT')));
|
|
801
815
|
}
|
|
802
816
|
|
|
803
817
|
/**
|
|
804
|
-
* {{>
|
|
818
|
+
* {{> dontSeeElementInDOM }}
|
|
805
819
|
*/
|
|
806
820
|
async dontSeeElementInDOM(locator) {
|
|
807
821
|
return this.browser.findElements(guessLocator(locator) || global.by.css(locator)).then(els => empty('elements').assert(els.fill('ELEMENT')));
|
|
808
822
|
}
|
|
809
823
|
|
|
810
824
|
/**
|
|
811
|
-
* {{>
|
|
825
|
+
* {{> seeInSource }}
|
|
812
826
|
*/
|
|
813
827
|
async seeInSource(text) {
|
|
814
828
|
return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').assert(text, source));
|
|
815
829
|
}
|
|
816
830
|
|
|
817
831
|
/**
|
|
818
|
-
* {{>
|
|
832
|
+
* {{> grabSource }}
|
|
819
833
|
*/
|
|
820
834
|
async grabSource() {
|
|
821
835
|
return this.browser.getPageSource();
|
|
822
836
|
}
|
|
823
837
|
|
|
824
838
|
/**
|
|
825
|
-
* {{>
|
|
839
|
+
* {{> dontSeeInSource }}
|
|
826
840
|
*/
|
|
827
841
|
async dontSeeInSource(text) {
|
|
828
842
|
return this.browser.getPageSource().then(source => stringIncludes('HTML source of a page').negate(text, source));
|
|
829
843
|
}
|
|
830
844
|
|
|
831
845
|
/**
|
|
832
|
-
*
|
|
833
|
-
* Element is located by label or name or CSS or XPath.
|
|
834
|
-
*
|
|
835
|
-
* ```js
|
|
836
|
-
* I.seeNumberOfElements('#submitBtn', 1);
|
|
837
|
-
* ```
|
|
846
|
+
* {{> seeNumberOfElements }}
|
|
838
847
|
*/
|
|
839
|
-
async seeNumberOfElements(
|
|
840
|
-
const elements = await this._locate(
|
|
841
|
-
return equals(`expected number of elements (${
|
|
848
|
+
async seeNumberOfElements(locator, num) {
|
|
849
|
+
const elements = await this._locate(locator);
|
|
850
|
+
return equals(`expected number of elements (${locator}) is ${num}, but found ${elements.length}`).assert(elements.length, num);
|
|
842
851
|
}
|
|
843
852
|
|
|
844
853
|
/**
|
|
845
|
-
* {{>
|
|
854
|
+
* {{> seeNumberOfVisibleElements }}
|
|
846
855
|
*/
|
|
847
856
|
async seeNumberOfVisibleElements(locator, num) {
|
|
848
857
|
const res = await this.grabNumberOfVisibleElements(locator);
|
|
@@ -850,7 +859,7 @@ class Protractor extends Helper {
|
|
|
850
859
|
}
|
|
851
860
|
|
|
852
861
|
/**
|
|
853
|
-
* {{>
|
|
862
|
+
* {{> grabNumberOfVisibleElements }}
|
|
854
863
|
*/
|
|
855
864
|
async grabNumberOfVisibleElements(locator) {
|
|
856
865
|
let els = await this._locate(locator);
|
|
@@ -859,7 +868,7 @@ class Protractor extends Helper {
|
|
|
859
868
|
}
|
|
860
869
|
|
|
861
870
|
/**
|
|
862
|
-
* {{>
|
|
871
|
+
* {{> seeCssPropertiesOnElements }}
|
|
863
872
|
*/
|
|
864
873
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
865
874
|
const els = await this._locate(locator);
|
|
@@ -890,7 +899,7 @@ class Protractor extends Helper {
|
|
|
890
899
|
}
|
|
891
900
|
|
|
892
901
|
/**
|
|
893
|
-
* {{>
|
|
902
|
+
* {{> seeAttributesOnElements }}
|
|
894
903
|
*/
|
|
895
904
|
async seeAttributesOnElements(locator, attributes) {
|
|
896
905
|
const els = await this._locate(locator);
|
|
@@ -917,14 +926,14 @@ class Protractor extends Helper {
|
|
|
917
926
|
}
|
|
918
927
|
|
|
919
928
|
/**
|
|
920
|
-
* {{>
|
|
929
|
+
* {{> executeScript }}
|
|
921
930
|
*/
|
|
922
931
|
async executeScript(fn) {
|
|
923
932
|
return this.browser.executeScript.apply(this.browser, arguments);
|
|
924
933
|
}
|
|
925
934
|
|
|
926
935
|
/**
|
|
927
|
-
* {{>
|
|
936
|
+
* {{> executeAsyncScript }}
|
|
928
937
|
*/
|
|
929
938
|
async executeAsyncScript(fn) {
|
|
930
939
|
this.browser.manage().timeouts().setScriptTimeout(this.options.scriptTimeout);
|
|
@@ -932,35 +941,35 @@ class Protractor extends Helper {
|
|
|
932
941
|
}
|
|
933
942
|
|
|
934
943
|
/**
|
|
935
|
-
* {{>
|
|
944
|
+
* {{> seeInCurrentUrl }}
|
|
936
945
|
*/
|
|
937
946
|
async seeInCurrentUrl(url) {
|
|
938
947
|
return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').assert(url, currentUrl));
|
|
939
948
|
}
|
|
940
949
|
|
|
941
950
|
/**
|
|
942
|
-
* {{>
|
|
951
|
+
* {{> dontSeeInCurrentUrl }}
|
|
943
952
|
*/
|
|
944
953
|
async dontSeeInCurrentUrl(url) {
|
|
945
954
|
return this.browser.getCurrentUrl().then(currentUrl => stringIncludes('url').negate(url, currentUrl));
|
|
946
955
|
}
|
|
947
956
|
|
|
948
957
|
/**
|
|
949
|
-
* {{>
|
|
958
|
+
* {{> seeCurrentUrlEquals }}
|
|
950
959
|
*/
|
|
951
960
|
async seeCurrentUrlEquals(url) {
|
|
952
961
|
return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).assert(url, currentUrl));
|
|
953
962
|
}
|
|
954
963
|
|
|
955
964
|
/**
|
|
956
|
-
* {{>
|
|
965
|
+
* {{> dontSeeCurrentUrlEquals }}
|
|
957
966
|
*/
|
|
958
967
|
async dontSeeCurrentUrlEquals(url) {
|
|
959
968
|
return this.browser.getCurrentUrl().then(currentUrl => urlEquals(this.options.url).negate(url, currentUrl));
|
|
960
969
|
}
|
|
961
970
|
|
|
962
971
|
/**
|
|
963
|
-
* {{>
|
|
972
|
+
* {{> saveScreenshot }}
|
|
964
973
|
*/
|
|
965
974
|
async saveScreenshot(fileName, fullPage = false) {
|
|
966
975
|
const outputFile = screenshotOutputFolder(fileName);
|
|
@@ -993,7 +1002,7 @@ class Protractor extends Helper {
|
|
|
993
1002
|
}
|
|
994
1003
|
|
|
995
1004
|
/**
|
|
996
|
-
* {{>
|
|
1005
|
+
* {{> clearCookie }}
|
|
997
1006
|
*/
|
|
998
1007
|
async clearCookie(cookie = null) {
|
|
999
1008
|
if (!cookie) {
|
|
@@ -1003,25 +1012,26 @@ class Protractor extends Helper {
|
|
|
1003
1012
|
}
|
|
1004
1013
|
|
|
1005
1014
|
/**
|
|
1006
|
-
* {{>
|
|
1015
|
+
* {{> seeCookie }}
|
|
1007
1016
|
*/
|
|
1008
1017
|
async seeCookie(name) {
|
|
1009
1018
|
return this.browser.manage().getCookie(name).then(res => truth(`cookie ${name}`, 'to be set').assert(res));
|
|
1010
1019
|
}
|
|
1011
1020
|
|
|
1012
1021
|
/**
|
|
1013
|
-
* {{>
|
|
1022
|
+
* {{> dontSeeCookie }}
|
|
1014
1023
|
*/
|
|
1015
1024
|
async dontSeeCookie(name) {
|
|
1016
1025
|
return this.browser.manage().getCookie(name).then(res => truth(`cookie ${name}`, 'to be set').negate(res));
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
1019
1028
|
/**
|
|
1020
|
-
* {{>
|
|
1029
|
+
* {{> grabCookie }}
|
|
1021
1030
|
*
|
|
1022
1031
|
* Returns cookie in JSON [format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
|
|
1023
1032
|
*/
|
|
1024
1033
|
async grabCookie(name) {
|
|
1034
|
+
if (!name) return this.browser.manage().getCookies();
|
|
1025
1035
|
return this.browser.manage().getCookie(name);
|
|
1026
1036
|
}
|
|
1027
1037
|
|
|
@@ -1078,7 +1088,7 @@ class Protractor extends Helper {
|
|
|
1078
1088
|
}
|
|
1079
1089
|
|
|
1080
1090
|
/**
|
|
1081
|
-
* {{>
|
|
1091
|
+
* {{> resizeWindow }}
|
|
1082
1092
|
*/
|
|
1083
1093
|
async resizeWindow(width, height) {
|
|
1084
1094
|
if (width === 'maximize') {
|
|
@@ -1089,7 +1099,7 @@ class Protractor extends Helper {
|
|
|
1089
1099
|
}
|
|
1090
1100
|
|
|
1091
1101
|
/**
|
|
1092
|
-
* {{>
|
|
1102
|
+
* {{> dragAndDrop }}
|
|
1093
1103
|
*/
|
|
1094
1104
|
async dragAndDrop(srcElement, destElement) {
|
|
1095
1105
|
const srcEl = await this._locate(srcElement, true);
|
|
@@ -1208,7 +1218,7 @@ class Protractor extends Helper {
|
|
|
1208
1218
|
}
|
|
1209
1219
|
|
|
1210
1220
|
/**
|
|
1211
|
-
* {{>
|
|
1221
|
+
* {{> grabNumberOfOpenTabs }}
|
|
1212
1222
|
*/
|
|
1213
1223
|
async grabNumberOfOpenTabs() {
|
|
1214
1224
|
const pages = await this.browser.getAllWindowHandles();
|
|
@@ -1216,7 +1226,7 @@ class Protractor extends Helper {
|
|
|
1216
1226
|
}
|
|
1217
1227
|
|
|
1218
1228
|
/**
|
|
1219
|
-
* {{>
|
|
1229
|
+
* {{> switchTo }}
|
|
1220
1230
|
*/
|
|
1221
1231
|
async switchTo(locator) {
|
|
1222
1232
|
if (Number.isInteger(locator)) {
|
|
@@ -1231,7 +1241,7 @@ class Protractor extends Helper {
|
|
|
1231
1241
|
}
|
|
1232
1242
|
|
|
1233
1243
|
/**
|
|
1234
|
-
* {{>
|
|
1244
|
+
* {{> wait }}
|
|
1235
1245
|
*/
|
|
1236
1246
|
wait(sec) {
|
|
1237
1247
|
return this.browser.sleep(sec * 1000);
|
|
@@ -1239,7 +1249,7 @@ class Protractor extends Helper {
|
|
|
1239
1249
|
|
|
1240
1250
|
|
|
1241
1251
|
/**
|
|
1242
|
-
* {{>
|
|
1252
|
+
* {{> waitForElement }}
|
|
1243
1253
|
*/
|
|
1244
1254
|
async waitForElement(locator, sec = null) {
|
|
1245
1255
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1255,7 +1265,7 @@ class Protractor extends Helper {
|
|
|
1255
1265
|
}
|
|
1256
1266
|
|
|
1257
1267
|
/**
|
|
1258
|
-
* {{>
|
|
1268
|
+
* {{> waitForDetached }}
|
|
1259
1269
|
*/
|
|
1260
1270
|
async waitForDetached(locator, sec = null) {
|
|
1261
1271
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1281,7 +1291,7 @@ class Protractor extends Helper {
|
|
|
1281
1291
|
}
|
|
1282
1292
|
|
|
1283
1293
|
/**
|
|
1284
|
-
* {{>
|
|
1294
|
+
* {{> waitForVisible }}
|
|
1285
1295
|
*/
|
|
1286
1296
|
async waitForVisible(locator, sec = null) {
|
|
1287
1297
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1290,14 +1300,14 @@ class Protractor extends Helper {
|
|
|
1290
1300
|
}
|
|
1291
1301
|
|
|
1292
1302
|
/**
|
|
1293
|
-
* {{>
|
|
1303
|
+
* {{> waitToHide }}
|
|
1294
1304
|
*/
|
|
1295
1305
|
async waitToHide(locator, sec = null) {
|
|
1296
1306
|
return this.waitForInvisible(locator, sec);
|
|
1297
1307
|
}
|
|
1298
1308
|
|
|
1299
1309
|
/**
|
|
1300
|
-
* {{>
|
|
1310
|
+
* {{> waitForInvisible }}
|
|
1301
1311
|
*/
|
|
1302
1312
|
async waitForInvisible(locator, sec = null) {
|
|
1303
1313
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1313,7 +1323,7 @@ class Protractor extends Helper {
|
|
|
1313
1323
|
}
|
|
1314
1324
|
|
|
1315
1325
|
/**
|
|
1316
|
-
* {{>
|
|
1326
|
+
* {{> waitNumberOfVisibleElements }}
|
|
1317
1327
|
*/
|
|
1318
1328
|
async waitNumberOfVisibleElements(locator, num, sec = null) {
|
|
1319
1329
|
function visibilityCountOf(loc, expectedCount) {
|
|
@@ -1335,7 +1345,7 @@ class Protractor extends Helper {
|
|
|
1335
1345
|
}
|
|
1336
1346
|
|
|
1337
1347
|
/**
|
|
1338
|
-
* {{>
|
|
1348
|
+
* {{> waitForEnabled }}
|
|
1339
1349
|
*/
|
|
1340
1350
|
async waitForEnabled(locator, sec = null) {
|
|
1341
1351
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1348,7 +1358,7 @@ class Protractor extends Helper {
|
|
|
1348
1358
|
}
|
|
1349
1359
|
|
|
1350
1360
|
/**
|
|
1351
|
-
* {{>
|
|
1361
|
+
* {{> waitForValue }}
|
|
1352
1362
|
*/
|
|
1353
1363
|
async waitForValue(field, value, sec = null) {
|
|
1354
1364
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1372,7 +1382,7 @@ class Protractor extends Helper {
|
|
|
1372
1382
|
}
|
|
1373
1383
|
|
|
1374
1384
|
/**
|
|
1375
|
-
* {{>
|
|
1385
|
+
* {{> waitForFunction }}
|
|
1376
1386
|
*/
|
|
1377
1387
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
1378
1388
|
let args = [];
|
|
@@ -1389,7 +1399,7 @@ class Protractor extends Helper {
|
|
|
1389
1399
|
}
|
|
1390
1400
|
|
|
1391
1401
|
/**
|
|
1392
|
-
* {{>
|
|
1402
|
+
* {{> waitUntil }}
|
|
1393
1403
|
*/
|
|
1394
1404
|
async waitUntil(fn, sec = null, timeoutMsg = null) {
|
|
1395
1405
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1397,7 +1407,7 @@ class Protractor extends Helper {
|
|
|
1397
1407
|
}
|
|
1398
1408
|
|
|
1399
1409
|
/**
|
|
1400
|
-
* {{>
|
|
1410
|
+
* {{> waitInUrl }}
|
|
1401
1411
|
*/
|
|
1402
1412
|
async waitInUrl(urlPart, sec = null) {
|
|
1403
1413
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1415,7 +1425,7 @@ class Protractor extends Helper {
|
|
|
1415
1425
|
}
|
|
1416
1426
|
|
|
1417
1427
|
/**
|
|
1418
|
-
* {{>
|
|
1428
|
+
* {{> waitUrlEquals }}
|
|
1419
1429
|
*/
|
|
1420
1430
|
async waitUrlEquals(urlPart, sec = null) {
|
|
1421
1431
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1437,7 +1447,7 @@ class Protractor extends Helper {
|
|
|
1437
1447
|
}
|
|
1438
1448
|
|
|
1439
1449
|
/**
|
|
1440
|
-
* {{>
|
|
1450
|
+
* {{> waitForText }}
|
|
1441
1451
|
*/
|
|
1442
1452
|
async waitForText(text, sec = null, context = null) {
|
|
1443
1453
|
if (!context) {
|
|
@@ -1459,7 +1469,7 @@ class Protractor extends Helper {
|
|
|
1459
1469
|
|
|
1460
1470
|
|
|
1461
1471
|
/**
|
|
1462
|
-
* {{>
|
|
1472
|
+
* {{> refreshPage }}
|
|
1463
1473
|
*/
|
|
1464
1474
|
refreshPage() {
|
|
1465
1475
|
return this.browser.refresh();
|
|
@@ -1474,7 +1484,7 @@ class Protractor extends Helper {
|
|
|
1474
1484
|
}
|
|
1475
1485
|
|
|
1476
1486
|
/**
|
|
1477
|
-
* {{>
|
|
1487
|
+
* {{> scrollTo }}
|
|
1478
1488
|
*/
|
|
1479
1489
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
1480
1490
|
if (typeof locator === 'number' && typeof offsetX === 'number') {
|
|
@@ -1501,14 +1511,14 @@ class Protractor extends Helper {
|
|
|
1501
1511
|
}
|
|
1502
1512
|
|
|
1503
1513
|
/**
|
|
1504
|
-
* {{>
|
|
1514
|
+
* {{> scrollPageToTop }}
|
|
1505
1515
|
*/
|
|
1506
1516
|
async scrollPageToTop() {
|
|
1507
1517
|
return this.executeScript('window.scrollTo(0, 0);');
|
|
1508
1518
|
}
|
|
1509
1519
|
|
|
1510
1520
|
/**
|
|
1511
|
-
* {{>
|
|
1521
|
+
* {{> scrollPageToBottom }}
|
|
1512
1522
|
*/
|
|
1513
1523
|
async scrollPageToBottom() {
|
|
1514
1524
|
/* eslint-disable prefer-arrow-callback, comma-dangle */
|
|
@@ -1524,7 +1534,7 @@ class Protractor extends Helper {
|
|
|
1524
1534
|
}
|
|
1525
1535
|
|
|
1526
1536
|
/**
|
|
1527
|
-
* {{>
|
|
1537
|
+
* {{> grabPageScrollPosition }}
|
|
1528
1538
|
*/
|
|
1529
1539
|
async grabPageScrollPosition() {
|
|
1530
1540
|
/* eslint-disable comma-dangle */
|
|
@@ -1567,7 +1577,7 @@ class Protractor extends Helper {
|
|
|
1567
1577
|
}
|
|
1568
1578
|
|
|
1569
1579
|
/**
|
|
1570
|
-
* {{>
|
|
1580
|
+
* {{> setCookie }}
|
|
1571
1581
|
*/
|
|
1572
1582
|
setCookie(cookie) {
|
|
1573
1583
|
return this.browser.manage().addCookie(cookie);
|