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
|
@@ -534,15 +534,16 @@ class WebDriverIO extends Helper {
|
|
|
534
534
|
|
|
535
535
|
/**
|
|
536
536
|
* Opens a web page in a browser. Requires relative or absolute url.
|
|
537
|
-
If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
538
|
-
|
|
539
|
-
```js
|
|
540
|
-
I.amOnPage('/'); // opens main page of website
|
|
541
|
-
I.amOnPage('https://github.com'); // opens github
|
|
542
|
-
I.amOnPage('/login'); // opens a login page
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
@param url url path or global url.
|
|
537
|
+
* If url starts with `/`, opens a web page of a site defined in `url` config parameter.
|
|
538
|
+
*
|
|
539
|
+
* ```js
|
|
540
|
+
* I.amOnPage('/'); // opens main page of website
|
|
541
|
+
* I.amOnPage('https://github.com'); // opens github
|
|
542
|
+
* I.amOnPage('/login'); // opens a login page
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @param {string} url url path or global url.
|
|
546
|
+
* {--end--}
|
|
546
547
|
* Appium: support only web testing
|
|
547
548
|
*/
|
|
548
549
|
amOnPage(url) {
|
|
@@ -551,29 +552,30 @@ I.amOnPage('/login'); // opens a login page
|
|
|
551
552
|
|
|
552
553
|
/**
|
|
553
554
|
* Perform a click on a link or a button, given by a locator.
|
|
554
|
-
If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
555
|
-
For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
556
|
-
For images, the "alt" attribute and inner text of any parent links are searched.
|
|
557
|
-
|
|
558
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
559
|
-
|
|
560
|
-
```js
|
|
561
|
-
// simple link
|
|
562
|
-
I.click('Logout');
|
|
563
|
-
// button of form
|
|
564
|
-
I.click('Submit');
|
|
565
|
-
// CSS button
|
|
566
|
-
I.click('#form input[type=submit]');
|
|
567
|
-
// XPath
|
|
568
|
-
I.click('//form/*[@type=submit]');
|
|
569
|
-
// link in context
|
|
570
|
-
I.click('Logout', '#nav');
|
|
571
|
-
// using strict locator
|
|
572
|
-
I.click({css: 'nav a.login'});
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
@param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
576
|
-
@param context (optional) element to search in CSS|XPath|Strict locator.
|
|
555
|
+
* If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
|
|
556
|
+
* For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
|
|
557
|
+
* For images, the "alt" attribute and inner text of any parent links are searched.
|
|
558
|
+
*
|
|
559
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
560
|
+
*
|
|
561
|
+
* ```js
|
|
562
|
+
* // simple link
|
|
563
|
+
* I.click('Logout');
|
|
564
|
+
* // button of form
|
|
565
|
+
* I.click('Submit');
|
|
566
|
+
* // CSS button
|
|
567
|
+
* I.click('#form input[type=submit]');
|
|
568
|
+
* // XPath
|
|
569
|
+
* I.click('//form/*[@type=submit]');
|
|
570
|
+
* // link in context
|
|
571
|
+
* I.click('Logout', '#nav');
|
|
572
|
+
* // using strict locator
|
|
573
|
+
* I.click({css: 'nav a.login'});
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
577
|
+
* @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
578
|
+
* {--end--}
|
|
577
579
|
* Appium: support
|
|
578
580
|
*/
|
|
579
581
|
async click(locator, context = null) {
|
|
@@ -591,17 +593,18 @@ I.click({css: 'nav a.login'});
|
|
|
591
593
|
|
|
592
594
|
/**
|
|
593
595
|
* Performs a double-click on an element matched by link|button|label|CSS or XPath.
|
|
594
|
-
Context can be specified as second parameter to narrow search.
|
|
595
|
-
|
|
596
|
-
```js
|
|
597
|
-
I.doubleClick('Edit');
|
|
598
|
-
I.doubleClick('Edit', '.actions');
|
|
599
|
-
I.doubleClick({css: 'button.accept'});
|
|
600
|
-
I.doubleClick('.btn.edit');
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
@param locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
604
|
-
@param context (optional) element to search in CSS|XPath|Strict locator.
|
|
596
|
+
* Context can be specified as second parameter to narrow search.
|
|
597
|
+
*
|
|
598
|
+
* ```js
|
|
599
|
+
* I.doubleClick('Edit');
|
|
600
|
+
* I.doubleClick('Edit', '.actions');
|
|
601
|
+
* I.doubleClick({css: 'button.accept'});
|
|
602
|
+
* I.doubleClick('.btn.edit');
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @param {string|object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
606
|
+
* @param {string|object} context (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
607
|
+
* {--end--}
|
|
605
608
|
* Appium: support only web testing
|
|
606
609
|
*/
|
|
607
610
|
async doubleClick(locator, context = null) {
|
|
@@ -621,19 +624,19 @@ I.doubleClick('.btn.edit');
|
|
|
621
624
|
|
|
622
625
|
/**
|
|
623
626
|
* Performs right click on a clickable element matched by semantic locator, CSS or XPath.
|
|
624
|
-
|
|
625
|
-
```js
|
|
626
|
-
// right click element with id el
|
|
627
|
-
I.rightClick('#el');
|
|
628
|
-
// right click link or button with text "Click me"
|
|
629
|
-
I.rightClick('Click me');
|
|
630
|
-
// right click button with text "Click me" inside .context
|
|
631
|
-
I.rightClick('Click me', '.context');
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
@param locator clickable element located by CSS|XPath|strict locator.
|
|
635
|
-
@param context (optional) element located by CSS|XPath|strict locator.
|
|
636
|
-
|
|
627
|
+
*
|
|
628
|
+
* ```js
|
|
629
|
+
* // right click element with id el
|
|
630
|
+
* I.rightClick('#el');
|
|
631
|
+
* // right click link or button with text "Click me"
|
|
632
|
+
* I.rightClick('Click me');
|
|
633
|
+
* // right click button with text "Click me" inside .context
|
|
634
|
+
* I.rightClick('Click me', '.context');
|
|
635
|
+
* ```
|
|
636
|
+
*
|
|
637
|
+
* @param {string|object} locator clickable element located by CSS|XPath|strict locator.
|
|
638
|
+
* @param {string|object} context (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
639
|
+
* {--end--}
|
|
637
640
|
* Appium: support, but in apps works as usual click
|
|
638
641
|
*/
|
|
639
642
|
async rightClick(locator) {
|
|
@@ -651,21 +654,21 @@ I.rightClick('Click me', '.context');
|
|
|
651
654
|
|
|
652
655
|
/**
|
|
653
656
|
* Fills a text field or textarea, after clearing its value, with the given string.
|
|
654
|
-
Field is located by name, label, CSS, or XPath.
|
|
655
|
-
|
|
656
|
-
```js
|
|
657
|
-
// by label
|
|
658
|
-
I.fillField('Email', 'hello@world.com');
|
|
659
|
-
// by name
|
|
660
|
-
I.fillField('password', secret('123456'));
|
|
661
|
-
// by CSS
|
|
662
|
-
I.fillField('form#login input[name=username]', 'John');
|
|
663
|
-
// or by strict locator
|
|
664
|
-
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
665
|
-
```
|
|
666
|
-
@param field located by label|name|CSS|XPath|strict locator.
|
|
667
|
-
@param value text value to fill.
|
|
668
|
-
|
|
657
|
+
* Field is located by name, label, CSS, or XPath.
|
|
658
|
+
*
|
|
659
|
+
* ```js
|
|
660
|
+
* // by label
|
|
661
|
+
* I.fillField('Email', 'hello@world.com');
|
|
662
|
+
* // by name
|
|
663
|
+
* I.fillField('password', secret('123456'));
|
|
664
|
+
* // by CSS
|
|
665
|
+
* I.fillField('form#login input[name=username]', 'John');
|
|
666
|
+
* // or by strict locator
|
|
667
|
+
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
668
|
+
* ```
|
|
669
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator.
|
|
670
|
+
* @param {string} value text value to fill.
|
|
671
|
+
* {--end--}
|
|
669
672
|
* Appium: support
|
|
670
673
|
*/
|
|
671
674
|
async fillField(field, value) {
|
|
@@ -677,13 +680,14 @@ I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
|
677
680
|
|
|
678
681
|
/**
|
|
679
682
|
* Appends text to a input field or textarea.
|
|
680
|
-
Field is located by name, label, CSS or XPath
|
|
681
|
-
|
|
682
|
-
```js
|
|
683
|
-
I.appendField('#myTextField', 'appended');
|
|
684
|
-
```
|
|
685
|
-
@param field located by label|name|CSS|XPath|strict locator
|
|
686
|
-
@param value text value to append.
|
|
683
|
+
* Field is located by name, label, CSS or XPath
|
|
684
|
+
*
|
|
685
|
+
* ```js
|
|
686
|
+
* I.appendField('#myTextField', 'appended');
|
|
687
|
+
* ```
|
|
688
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator
|
|
689
|
+
* @param {string} value text value to append.
|
|
690
|
+
* {--end--}
|
|
687
691
|
* Appium: support, but it's clear a field before insert in apps
|
|
688
692
|
*/
|
|
689
693
|
async appendField(field, value) {
|
|
@@ -695,14 +699,7 @@ I.appendField('#myTextField', 'appended');
|
|
|
695
699
|
|
|
696
700
|
|
|
697
701
|
/**
|
|
698
|
-
*
|
|
699
|
-
|
|
700
|
-
```js
|
|
701
|
-
I.clearField('Email');
|
|
702
|
-
I.clearField('user[email]');
|
|
703
|
-
I.clearField('#email');
|
|
704
|
-
```
|
|
705
|
-
@param field located by label|name|CSS|XPath|strict locator.
|
|
702
|
+
* {{> clearField}}
|
|
706
703
|
* Appium: support
|
|
707
704
|
*/
|
|
708
705
|
async clearField(field) {
|
|
@@ -714,26 +711,7 @@ I.clearField('#email');
|
|
|
714
711
|
|
|
715
712
|
|
|
716
713
|
/**
|
|
717
|
-
*
|
|
718
|
-
Field is searched by label | name | CSS | XPath.
|
|
719
|
-
Option is selected by visible text or by value.
|
|
720
|
-
|
|
721
|
-
```js
|
|
722
|
-
I.selectOption('Choose Plan', 'Monthly'); // select by label
|
|
723
|
-
I.selectOption('subscription', 'Monthly'); // match option by text
|
|
724
|
-
I.selectOption('subscription', '0'); // or by value
|
|
725
|
-
I.selectOption('//form/select[@name=account]','Premium');
|
|
726
|
-
I.selectOption('form select[name=account]', 'Premium');
|
|
727
|
-
I.selectOption({css: 'form select[name=account]'}, 'Premium');
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
Provide an array for the second argument to select multiple options.
|
|
731
|
-
|
|
732
|
-
```js
|
|
733
|
-
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
734
|
-
```
|
|
735
|
-
@param select field located by label|name|CSS|XPath|strict locator.
|
|
736
|
-
@param option visible text or value of option.
|
|
714
|
+
* {{> selectOption}}
|
|
737
715
|
*/
|
|
738
716
|
async selectOption(select, option) {
|
|
739
717
|
const res = await findFields.call(this, select);
|
|
@@ -765,16 +743,17 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
765
743
|
|
|
766
744
|
/**
|
|
767
745
|
* Attaches a file to element located by label, name, CSS or XPath
|
|
768
|
-
Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
|
|
769
|
-
File will be uploaded to remote system (if tests are running remotely).
|
|
770
|
-
|
|
771
|
-
```js
|
|
772
|
-
I.attachFile('Avatar', 'data/avatar.jpg');
|
|
773
|
-
I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
774
|
-
```
|
|
775
|
-
|
|
776
|
-
@param locator field located by label|name|CSS|XPath|strict locator.
|
|
777
|
-
@param pathToFile local file path relative to codecept.json config file.
|
|
746
|
+
* Path to file is relative current codecept directory (where codecept.json or codecept.conf.js is located).
|
|
747
|
+
* File will be uploaded to remote system (if tests are running remotely).
|
|
748
|
+
*
|
|
749
|
+
* ```js
|
|
750
|
+
* I.attachFile('Avatar', 'data/avatar.jpg');
|
|
751
|
+
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
752
|
+
* ```
|
|
753
|
+
*
|
|
754
|
+
* @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
|
|
755
|
+
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
756
|
+
* {--end--}
|
|
778
757
|
* Appium: not tested
|
|
779
758
|
*/
|
|
780
759
|
async attachFile(locator, pathToFile) {
|
|
@@ -792,17 +771,18 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
|
792
771
|
|
|
793
772
|
/**
|
|
794
773
|
* Selects a checkbox or radio button.
|
|
795
|
-
Element is located by label or name or CSS or XPath.
|
|
796
|
-
|
|
797
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
798
|
-
|
|
799
|
-
```js
|
|
800
|
-
I.checkOption('#agree');
|
|
801
|
-
I.checkOption('I Agree to Terms and Conditions');
|
|
802
|
-
I.checkOption('agree', '//form');
|
|
803
|
-
```
|
|
804
|
-
@param field checkbox located by label | name | CSS | XPath | strict locator.
|
|
805
|
-
@param context (optional) element located by CSS | XPath | strict locator.
|
|
774
|
+
* Element is located by label or name or CSS or XPath.
|
|
775
|
+
*
|
|
776
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
777
|
+
*
|
|
778
|
+
* ```js
|
|
779
|
+
* I.checkOption('#agree');
|
|
780
|
+
* I.checkOption('I Agree to Terms and Conditions');
|
|
781
|
+
* I.checkOption('agree', '//form');
|
|
782
|
+
* ```
|
|
783
|
+
* @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
784
|
+
* @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
785
|
+
* {--end--}
|
|
806
786
|
* Appium: not tested
|
|
807
787
|
*/
|
|
808
788
|
async checkOption(field, context = null) {
|
|
@@ -821,17 +801,18 @@ I.checkOption('agree', '//form');
|
|
|
821
801
|
|
|
822
802
|
/**
|
|
823
803
|
* Unselects a checkbox or radio button.
|
|
824
|
-
Element is located by label or name or CSS or XPath.
|
|
825
|
-
|
|
826
|
-
The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
827
|
-
|
|
828
|
-
```js
|
|
829
|
-
I.uncheckOption('#agree');
|
|
830
|
-
I.uncheckOption('I Agree to Terms and Conditions');
|
|
831
|
-
I.uncheckOption('agree', '//form');
|
|
832
|
-
```
|
|
833
|
-
@param field checkbox located by label | name | CSS | XPath | strict locator.
|
|
834
|
-
@param context (optional) element located by CSS | XPath | strict locator.
|
|
804
|
+
* Element is located by label or name or CSS or XPath.
|
|
805
|
+
*
|
|
806
|
+
* The second parameter is a context (CSS or XPath locator) to narrow the search.
|
|
807
|
+
*
|
|
808
|
+
* ```js
|
|
809
|
+
* I.uncheckOption('#agree');
|
|
810
|
+
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
811
|
+
* I.uncheckOption('agree', '//form');
|
|
812
|
+
* ```
|
|
813
|
+
* @param {string|object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
814
|
+
* @param {string} context (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
815
|
+
* {--end--}
|
|
835
816
|
* Appium: not tested
|
|
836
817
|
*/
|
|
837
818
|
async uncheckOption(field, context = null) {
|
|
@@ -850,14 +831,16 @@ I.uncheckOption('agree', '//form');
|
|
|
850
831
|
|
|
851
832
|
/**
|
|
852
833
|
* Retrieves a text from an element located by CSS or XPath and returns it to test.
|
|
853
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
854
|
-
|
|
855
|
-
```js
|
|
856
|
-
let pin = await I.grabTextFrom('#pin');
|
|
857
|
-
```
|
|
858
|
-
If multiple elements found returns an array of texts.
|
|
859
|
-
|
|
860
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
834
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
835
|
+
*
|
|
836
|
+
* ```js
|
|
837
|
+
* let pin = await I.grabTextFrom('#pin');
|
|
838
|
+
* ```
|
|
839
|
+
* If multiple elements found returns an array of texts.
|
|
840
|
+
*
|
|
841
|
+
* @param locator element located by CSS|XPath|strict locator.
|
|
842
|
+
* @returns {Promise<string>} attribute value
|
|
843
|
+
* {--end--}
|
|
861
844
|
* Appium: support
|
|
862
845
|
*/
|
|
863
846
|
async grabTextFrom(locator) {
|
|
@@ -870,14 +853,16 @@ If multiple elements found returns an array of texts.
|
|
|
870
853
|
|
|
871
854
|
/**
|
|
872
855
|
* Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
|
|
873
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
874
|
-
If more than one element is found - an array of HTMLs returned.
|
|
875
|
-
|
|
876
|
-
```js
|
|
877
|
-
let postHTML = await I.grabHTMLFrom('#post');
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
856
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
857
|
+
* If more than one element is found - an array of HTMLs returned.
|
|
858
|
+
*
|
|
859
|
+
* ```js
|
|
860
|
+
* let postHTML = await I.grabHTMLFrom('#post');
|
|
861
|
+
* ```
|
|
862
|
+
*
|
|
863
|
+
* @param locator element located by CSS|XPath|strict locator.
|
|
864
|
+
* @returns {Promise<string>} HTML code for an element
|
|
865
|
+
* {--end--}
|
|
881
866
|
* Appium: support only web testing
|
|
882
867
|
*/
|
|
883
868
|
async grabHTMLFrom(locator) {
|
|
@@ -888,12 +873,14 @@ let postHTML = await I.grabHTMLFrom('#post');
|
|
|
888
873
|
|
|
889
874
|
/**
|
|
890
875
|
* Retrieves a value from a form element located by CSS or XPath and returns it to test.
|
|
891
|
-
Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
892
|
-
|
|
893
|
-
```js
|
|
894
|
-
let email = await I.grabValueFrom('input[name=email]');
|
|
895
|
-
```
|
|
896
|
-
@param locator field located by label|name|CSS|XPath|strict locator.
|
|
876
|
+
* Resumes test execution, so **should be used inside async function with `await`** operator.
|
|
877
|
+
*
|
|
878
|
+
* ```js
|
|
879
|
+
* let email = await I.grabValueFrom('input[name=email]');
|
|
880
|
+
* ```
|
|
881
|
+
* @param {string|object} locator field located by label|name|CSS|XPath|strict locator.
|
|
882
|
+
* @returns {Promise<string>} attribute value
|
|
883
|
+
* {--end--}
|
|
897
884
|
* Appium: support only web testing
|
|
898
885
|
*/
|
|
899
886
|
async grabValueFrom(locator) {
|
|
@@ -905,14 +892,16 @@ let email = await I.grabValueFrom('input[name=email]');
|
|
|
905
892
|
|
|
906
893
|
/**
|
|
907
894
|
* Grab CSS property for given locator
|
|
908
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
909
|
-
|
|
910
|
-
```js
|
|
911
|
-
const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
912
|
-
```
|
|
913
|
-
|
|
914
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
915
|
-
@param cssProperty CSS property name.
|
|
895
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
896
|
+
*
|
|
897
|
+
* ```js
|
|
898
|
+
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
899
|
+
* ```
|
|
900
|
+
*
|
|
901
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
902
|
+
* @param {string} cssProperty CSS property name.
|
|
903
|
+
* @returns {Promise<string>} CSS value
|
|
904
|
+
* {--end--}
|
|
916
905
|
*/
|
|
917
906
|
async grabCssPropertyFrom(locator, cssProperty) {
|
|
918
907
|
const res = await this._locate(locator, true);
|
|
@@ -922,14 +911,16 @@ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
|
922
911
|
|
|
923
912
|
/**
|
|
924
913
|
* Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
925
|
-
An array as a result will be returned if there are more than one matched element.
|
|
926
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
927
|
-
|
|
928
|
-
```js
|
|
929
|
-
let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
930
|
-
```
|
|
931
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
932
|
-
@param attr attribute name.
|
|
914
|
+
* An array as a result will be returned if there are more than one matched element.
|
|
915
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
916
|
+
*
|
|
917
|
+
* ```js
|
|
918
|
+
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
919
|
+
* ```
|
|
920
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
921
|
+
* @param {string} attr attribute name.
|
|
922
|
+
* @returns {Promise<string>} attribute value
|
|
923
|
+
* {--end--}
|
|
933
924
|
* Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
934
925
|
*/
|
|
935
926
|
async grabAttributeFrom(locator, attr) {
|
|
@@ -940,8 +931,13 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
940
931
|
|
|
941
932
|
/**
|
|
942
933
|
* Checks that title contains text.
|
|
943
|
-
|
|
944
|
-
|
|
934
|
+
*
|
|
935
|
+
* ```js
|
|
936
|
+
* I.seeInTitle('Home Page');
|
|
937
|
+
* ```
|
|
938
|
+
*
|
|
939
|
+
* @param {string} text text value to check.
|
|
940
|
+
* {--end--}
|
|
945
941
|
* Appium: support only web testing
|
|
946
942
|
*/
|
|
947
943
|
async seeInTitle(text) {
|
|
@@ -965,8 +961,13 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
965
961
|
|
|
966
962
|
/**
|
|
967
963
|
* Checks that title does not contain text.
|
|
968
|
-
|
|
969
|
-
|
|
964
|
+
*
|
|
965
|
+
* ```js
|
|
966
|
+
* I.dontSeeInTitle('Error');
|
|
967
|
+
* ```
|
|
968
|
+
*
|
|
969
|
+
* @param {string} text value to check.
|
|
970
|
+
* {--end--}
|
|
970
971
|
* Appium: support only web testing
|
|
971
972
|
*/
|
|
972
973
|
async dontSeeInTitle(text) {
|
|
@@ -976,11 +977,14 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
976
977
|
|
|
977
978
|
/**
|
|
978
979
|
* Retrieves a page title and returns it to test.
|
|
979
|
-
Resumes test execution, so **should be used inside async with `await`** operator.
|
|
980
|
-
|
|
981
|
-
```js
|
|
982
|
-
let title = await I.grabTitle();
|
|
983
|
-
```
|
|
980
|
+
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
981
|
+
*
|
|
982
|
+
* ```js
|
|
983
|
+
* let title = await I.grabTitle();
|
|
984
|
+
* ```
|
|
985
|
+
*
|
|
986
|
+
* @returns {Promise<string>} title
|
|
987
|
+
* {--end--}
|
|
984
988
|
* Appium: support only web testing
|
|
985
989
|
*/
|
|
986
990
|
async grabTitle() {
|
|
@@ -991,15 +995,16 @@ let title = await I.grabTitle();
|
|
|
991
995
|
|
|
992
996
|
/**
|
|
993
997
|
* Checks that a page contains a visible text.
|
|
994
|
-
Use context parameter to narrow down the search.
|
|
995
|
-
|
|
996
|
-
```js
|
|
997
|
-
I.see('Welcome'); // text welcome on a page
|
|
998
|
-
I.see('Welcome', '.content'); // text inside .content div
|
|
999
|
-
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1000
|
-
```
|
|
1001
|
-
@param text expected on page.
|
|
1002
|
-
@param context (optional) element located by CSS|Xpath|strict locator in which to search for text.
|
|
998
|
+
* Use context parameter to narrow down the search.
|
|
999
|
+
*
|
|
1000
|
+
* ```js
|
|
1001
|
+
* I.see('Welcome'); // text welcome on a page
|
|
1002
|
+
* I.see('Welcome', '.content'); // text inside .content div
|
|
1003
|
+
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1004
|
+
* ```
|
|
1005
|
+
* @param {string} text expected on page.
|
|
1006
|
+
* @param {string|object} context (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1007
|
+
* {--end--}
|
|
1003
1008
|
* Appium: support with context in apps
|
|
1004
1009
|
*/
|
|
1005
1010
|
async see(text, context = null) {
|
|
@@ -1022,13 +1027,17 @@ I.see('Register', {css: 'form.register'}); // use strict locator
|
|
|
1022
1027
|
|
|
1023
1028
|
/**
|
|
1024
1029
|
* Opposite to `see`. Checks that a text is not present on a page.
|
|
1025
|
-
Use context parameter to narrow down the search.
|
|
1026
|
-
|
|
1027
|
-
```js
|
|
1028
|
-
I.dontSee('Login'); // assume we are already logged in
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1030
|
+
* Use context parameter to narrow down the search.
|
|
1031
|
+
*
|
|
1032
|
+
* ```js
|
|
1033
|
+
* I.dontSee('Login'); // assume we are already logged in.
|
|
1034
|
+
* I.dontSee('Login', '.nav'); // no login inside .nav element
|
|
1035
|
+
* ```
|
|
1036
|
+
*
|
|
1037
|
+
* @param {string} text which is not present.
|
|
1038
|
+
* @param {string|object} context (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
1039
|
+
*
|
|
1040
|
+
* {--end--}
|
|
1032
1041
|
* Appium: support with context in apps
|
|
1033
1042
|
*/
|
|
1034
1043
|
async dontSee(text, context = null) {
|
|
@@ -1037,16 +1046,17 @@ I.dontSee('Login'); // assume we are already logged in
|
|
|
1037
1046
|
|
|
1038
1047
|
/**
|
|
1039
1048
|
* Checks that the given input field or textarea equals to given value.
|
|
1040
|
-
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1041
|
-
|
|
1042
|
-
```js
|
|
1043
|
-
I.seeInField('Username', 'davert');
|
|
1044
|
-
I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1045
|
-
I.seeInField('form input[type=hidden]','hidden_value');
|
|
1046
|
-
I.seeInField('#searchform input','Search');
|
|
1047
|
-
```
|
|
1048
|
-
@param field located by label|name|CSS|XPath|strict locator.
|
|
1049
|
-
@param value value to check.
|
|
1049
|
+
* For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
|
|
1050
|
+
*
|
|
1051
|
+
* ```js
|
|
1052
|
+
* I.seeInField('Username', 'davert');
|
|
1053
|
+
* I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
1054
|
+
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1055
|
+
* I.seeInField('#searchform input','Search');
|
|
1056
|
+
* ```
|
|
1057
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator.
|
|
1058
|
+
* @param {string} value value to check.
|
|
1059
|
+
* {--end--}
|
|
1050
1060
|
* Appium: support only web testing
|
|
1051
1061
|
*/
|
|
1052
1062
|
async seeInField(field, value) {
|
|
@@ -1055,10 +1065,16 @@ I.seeInField('#searchform input','Search');
|
|
|
1055
1065
|
|
|
1056
1066
|
/**
|
|
1057
1067
|
* Checks that value of input field or textare doesn't equal to given value
|
|
1058
|
-
Opposite to `seeInField`.
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
@
|
|
1068
|
+
* Opposite to `seeInField`.
|
|
1069
|
+
*
|
|
1070
|
+
* ```js
|
|
1071
|
+
* I.dontSeeInField('email', 'user@user.com'); // field by name
|
|
1072
|
+
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1073
|
+
* ```
|
|
1074
|
+
*
|
|
1075
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator.
|
|
1076
|
+
* @param {string} value value to check.
|
|
1077
|
+
* {--end--}
|
|
1062
1078
|
* Appium: support only web testing
|
|
1063
1079
|
*/
|
|
1064
1080
|
async dontSeeInField(field, value) {
|
|
@@ -1067,13 +1083,15 @@ Opposite to `seeInField`.
|
|
|
1067
1083
|
|
|
1068
1084
|
/**
|
|
1069
1085
|
* Verifies that the specified checkbox is checked.
|
|
1070
|
-
|
|
1071
|
-
```js
|
|
1072
|
-
I.seeCheckboxIsChecked('Agree');
|
|
1073
|
-
I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1074
|
-
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1075
|
-
```
|
|
1076
|
-
|
|
1086
|
+
*
|
|
1087
|
+
* ```js
|
|
1088
|
+
* I.seeCheckboxIsChecked('Agree');
|
|
1089
|
+
* I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
1090
|
+
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1091
|
+
* ```
|
|
1092
|
+
*
|
|
1093
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator.
|
|
1094
|
+
* {--end--}
|
|
1077
1095
|
* Appium: not tested
|
|
1078
1096
|
*/
|
|
1079
1097
|
async seeCheckboxIsChecked(field) {
|
|
@@ -1082,8 +1100,15 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
|
1082
1100
|
|
|
1083
1101
|
/**
|
|
1084
1102
|
* Verifies that the specified checkbox is not checked.
|
|
1085
|
-
|
|
1086
|
-
|
|
1103
|
+
*
|
|
1104
|
+
* ```js
|
|
1105
|
+
* I.dontSeeeCheckboxIsChedcked('#agree'); // located by ID
|
|
1106
|
+
* I.dontSeeeCheckboxIsChedcked('I agree to terms'); // located by label
|
|
1107
|
+
* I.dontSeeeCheckboxIsChedcked('agree'); // located by name
|
|
1108
|
+
* ```
|
|
1109
|
+
*
|
|
1110
|
+
* @param {string|object} field located by label|name|CSS|XPath|strict locator.
|
|
1111
|
+
* {--end--}
|
|
1087
1112
|
* Appium: not tested
|
|
1088
1113
|
*/
|
|
1089
1114
|
async dontSeeCheckboxIsChecked(field) {
|
|
@@ -1092,12 +1117,13 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
|
1092
1117
|
|
|
1093
1118
|
/**
|
|
1094
1119
|
* Checks that a given Element is visible
|
|
1095
|
-
Element is located by CSS or XPath.
|
|
1096
|
-
|
|
1097
|
-
```js
|
|
1098
|
-
I.seeElement('#modal');
|
|
1099
|
-
```
|
|
1100
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1120
|
+
* Element is located by CSS or XPath.
|
|
1121
|
+
*
|
|
1122
|
+
* ```js
|
|
1123
|
+
* I.seeElement('#modal');
|
|
1124
|
+
* ```
|
|
1125
|
+
* @param {string|object} locator located by CSS|XPath|strict locator.
|
|
1126
|
+
* {--end--}
|
|
1101
1127
|
* Appium: support
|
|
1102
1128
|
*/
|
|
1103
1129
|
async seeElement(locator) {
|
|
@@ -1111,9 +1137,7 @@ I.seeElement('#modal');
|
|
|
1111
1137
|
}
|
|
1112
1138
|
|
|
1113
1139
|
/**
|
|
1114
|
-
*
|
|
1115
|
-
|
|
1116
|
-
@param locator located by CSS|XPath|Strict locator.
|
|
1140
|
+
* {{> dontSeeElement}}
|
|
1117
1141
|
* Appium: support
|
|
1118
1142
|
*/
|
|
1119
1143
|
async dontSeeElement(locator) {
|
|
@@ -1127,12 +1151,13 @@ I.seeElement('#modal');
|
|
|
1127
1151
|
|
|
1128
1152
|
/**
|
|
1129
1153
|
* Checks that a given Element is present in the DOM
|
|
1130
|
-
Element is located by CSS or XPath.
|
|
1131
|
-
|
|
1132
|
-
```js
|
|
1133
|
-
I.seeElementInDOM('#modal');
|
|
1134
|
-
```
|
|
1135
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1154
|
+
* Element is located by CSS or XPath.
|
|
1155
|
+
*
|
|
1156
|
+
* ```js
|
|
1157
|
+
* I.seeElementInDOM('#modal');
|
|
1158
|
+
* ```
|
|
1159
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
1160
|
+
* {--end--}
|
|
1136
1161
|
* Appium: support
|
|
1137
1162
|
*/
|
|
1138
1163
|
async seeElementInDOM(locator) {
|
|
@@ -1142,8 +1167,13 @@ I.seeElementInDOM('#modal');
|
|
|
1142
1167
|
|
|
1143
1168
|
/**
|
|
1144
1169
|
* Opposite to `seeElementInDOM`. Checks that element is not on page.
|
|
1145
|
-
|
|
1146
|
-
|
|
1170
|
+
*
|
|
1171
|
+
* ```js
|
|
1172
|
+
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1173
|
+
* ```
|
|
1174
|
+
*
|
|
1175
|
+
* @param {string|object} locator located by CSS|XPath|Strict locator.
|
|
1176
|
+
* {--end--}
|
|
1147
1177
|
* Appium: support
|
|
1148
1178
|
*/
|
|
1149
1179
|
async dontSeeElementInDOM(locator) {
|
|
@@ -1153,11 +1183,12 @@ I.seeElementInDOM('#modal');
|
|
|
1153
1183
|
|
|
1154
1184
|
/**
|
|
1155
1185
|
* Checks that the current page contains the given string in its raw source code.
|
|
1156
|
-
|
|
1157
|
-
```js
|
|
1158
|
-
I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1159
|
-
```
|
|
1160
|
-
@param text value to check.
|
|
1186
|
+
*
|
|
1187
|
+
* ```js
|
|
1188
|
+
* I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
1189
|
+
* ```
|
|
1190
|
+
* @param {string} text value to check.
|
|
1191
|
+
* {--end--}
|
|
1161
1192
|
* Appium: support
|
|
1162
1193
|
*/
|
|
1163
1194
|
async seeInSource(text) {
|
|
@@ -1167,11 +1198,14 @@ I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
|
1167
1198
|
|
|
1168
1199
|
/**
|
|
1169
1200
|
* Retrieves page source and returns it to test.
|
|
1170
|
-
Resumes test execution, so should be used inside an async function.
|
|
1171
|
-
|
|
1172
|
-
```js
|
|
1173
|
-
let pageSource = await I.grabSource();
|
|
1174
|
-
```
|
|
1201
|
+
* Resumes test execution, so should be used inside an async function.
|
|
1202
|
+
*
|
|
1203
|
+
* ```js
|
|
1204
|
+
* let pageSource = await I.grabSource();
|
|
1205
|
+
* ```
|
|
1206
|
+
*
|
|
1207
|
+
* @returns {Promise<string>} source code
|
|
1208
|
+
* {--end--}
|
|
1175
1209
|
* Appium: support
|
|
1176
1210
|
*/
|
|
1177
1211
|
async grabSource() {
|
|
@@ -1192,12 +1226,15 @@ let pageSource = await I.grabSource();
|
|
|
1192
1226
|
|
|
1193
1227
|
/**
|
|
1194
1228
|
* Get current URL from browser.
|
|
1195
|
-
Resumes test execution, so should be used inside an async function.
|
|
1196
|
-
|
|
1197
|
-
```js
|
|
1198
|
-
let url = await I.grabCurrentUrl();
|
|
1199
|
-
console.log(`Current URL is [${url}]`);
|
|
1200
|
-
```
|
|
1229
|
+
* Resumes test execution, so should be used inside an async function.
|
|
1230
|
+
*
|
|
1231
|
+
* ```js
|
|
1232
|
+
* let url = await I.grabCurrentUrl();
|
|
1233
|
+
* console.log(`Current URL is [${url}]`);
|
|
1234
|
+
* ```
|
|
1235
|
+
*
|
|
1236
|
+
* @returns {Promise<string>} current URL
|
|
1237
|
+
* {--end--}
|
|
1201
1238
|
*/
|
|
1202
1239
|
async grabCurrentUrl() {
|
|
1203
1240
|
const res = await this.browser.url();
|
|
@@ -1212,9 +1249,13 @@ console.log(`Current URL is [${url}]`);
|
|
|
1212
1249
|
|
|
1213
1250
|
/**
|
|
1214
1251
|
* Checks that the current page does not contains the given string in its raw source code.
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1252
|
+
*
|
|
1253
|
+
* ```js
|
|
1254
|
+
* I.dontSeeInSource('<!--'); // no comments in source
|
|
1255
|
+
* ```
|
|
1256
|
+
*
|
|
1257
|
+
* @param {string} value to check.
|
|
1258
|
+
* {--end--}
|
|
1218
1259
|
* Appium: support
|
|
1219
1260
|
*/
|
|
1220
1261
|
async dontSeeInSource(text) {
|
|
@@ -1241,14 +1282,15 @@ console.log(`Current URL is [${url}]`);
|
|
|
1241
1282
|
|
|
1242
1283
|
/**
|
|
1243
1284
|
* Asserts that an element is visible a given number of times.
|
|
1244
|
-
Element is located by CSS or XPath.
|
|
1245
|
-
|
|
1246
|
-
```js
|
|
1247
|
-
I.seeNumberOfVisibleElements('.buttons', 3);
|
|
1248
|
-
```
|
|
1249
|
-
|
|
1250
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
1251
|
-
@param num number of elements.
|
|
1285
|
+
* Element is located by CSS or XPath.
|
|
1286
|
+
*
|
|
1287
|
+
* ```js
|
|
1288
|
+
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
1289
|
+
* ```
|
|
1290
|
+
*
|
|
1291
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
1292
|
+
* @param {number} num number of elements.
|
|
1293
|
+
* {--end--}
|
|
1252
1294
|
*/
|
|
1253
1295
|
async seeNumberOfVisibleElements(locator, num) {
|
|
1254
1296
|
const res = await this.grabNumberOfVisibleElements(locator);
|
|
@@ -1257,13 +1299,14 @@ I.seeNumberOfVisibleElements('.buttons', 3);
|
|
|
1257
1299
|
|
|
1258
1300
|
/**
|
|
1259
1301
|
* Checks that all elements with given locator have given CSS properties.
|
|
1260
|
-
|
|
1261
|
-
```js
|
|
1262
|
-
I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
1263
|
-
```
|
|
1264
|
-
|
|
1265
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1266
|
-
@param cssProperties object with CSS properties and their values to check.
|
|
1302
|
+
*
|
|
1303
|
+
* ```js
|
|
1304
|
+
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
1305
|
+
* ```
|
|
1306
|
+
*
|
|
1307
|
+
* @param {string|object} locator located by CSS|XPath|strict locator.
|
|
1308
|
+
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
1309
|
+
* {--end--}
|
|
1267
1310
|
*/
|
|
1268
1311
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
1269
1312
|
const res = await this._locate(locator);
|
|
@@ -1299,13 +1342,14 @@ I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
|
1299
1342
|
|
|
1300
1343
|
/**
|
|
1301
1344
|
* Checks that all elements with given locator have given attributes.
|
|
1302
|
-
|
|
1303
|
-
```js
|
|
1304
|
-
I.seeAttributesOnElements('//form', {
|
|
1305
|
-
```
|
|
1306
|
-
|
|
1307
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1308
|
-
@param
|
|
1345
|
+
*
|
|
1346
|
+
* ```js
|
|
1347
|
+
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
1348
|
+
* ```
|
|
1349
|
+
*
|
|
1350
|
+
* @param {string|object} locator located by CSS|XPath|strict locator.
|
|
1351
|
+
* @param {object} attributes attributes and their values to check.
|
|
1352
|
+
* {--end--}
|
|
1309
1353
|
*/
|
|
1310
1354
|
async seeAttributesOnElements(locator, attributes) {
|
|
1311
1355
|
const res = await this._locate(locator);
|
|
@@ -1333,12 +1377,14 @@ I.seeAttributesOnElements('//form', {'method': "post"});
|
|
|
1333
1377
|
|
|
1334
1378
|
/**
|
|
1335
1379
|
* Grab number of visible elements by locator.
|
|
1336
|
-
|
|
1337
|
-
```js
|
|
1338
|
-
I.grabNumberOfVisibleElements('p');
|
|
1339
|
-
```
|
|
1340
|
-
|
|
1341
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1380
|
+
*
|
|
1381
|
+
* ```js
|
|
1382
|
+
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1383
|
+
* ```
|
|
1384
|
+
*
|
|
1385
|
+
* @param {string|object} locator located by CSS|XPath|strict locator.
|
|
1386
|
+
* @returns {Promise<number>} number of visible elements
|
|
1387
|
+
* {--end--}
|
|
1342
1388
|
*/
|
|
1343
1389
|
async grabNumberOfVisibleElements(locator) {
|
|
1344
1390
|
const res = await this._locate(locator);
|
|
@@ -1351,12 +1397,13 @@ I.grabNumberOfVisibleElements('p');
|
|
|
1351
1397
|
|
|
1352
1398
|
/**
|
|
1353
1399
|
* Checks that current url contains a provided fragment.
|
|
1354
|
-
|
|
1355
|
-
```js
|
|
1356
|
-
I.seeInCurrentUrl('/register'); // we are on registration page
|
|
1357
|
-
```
|
|
1358
|
-
|
|
1359
|
-
@param url
|
|
1400
|
+
*
|
|
1401
|
+
* ```js
|
|
1402
|
+
* I.seeInCurrentUrl('/register'); // we are on registration page
|
|
1403
|
+
* ```
|
|
1404
|
+
*
|
|
1405
|
+
* @param {string} url a fragment to check
|
|
1406
|
+
* {--end--}
|
|
1360
1407
|
* Appium: support only web testing
|
|
1361
1408
|
*/
|
|
1362
1409
|
async seeInCurrentUrl(url) {
|
|
@@ -1366,8 +1413,9 @@ I.seeInCurrentUrl('/register'); // we are on registration page
|
|
|
1366
1413
|
|
|
1367
1414
|
/**
|
|
1368
1415
|
* Checks that current url does not contain a provided fragment.
|
|
1369
|
-
|
|
1370
|
-
@param url value to check.
|
|
1416
|
+
*
|
|
1417
|
+
* @param {string} url value to check.
|
|
1418
|
+
* {--end--}
|
|
1371
1419
|
* Appium: support only web testing
|
|
1372
1420
|
*/
|
|
1373
1421
|
async dontSeeInCurrentUrl(url) {
|
|
@@ -1377,15 +1425,16 @@ I.seeInCurrentUrl('/register'); // we are on registration page
|
|
|
1377
1425
|
|
|
1378
1426
|
/**
|
|
1379
1427
|
* Checks that current url is equal to provided one.
|
|
1380
|
-
If a relative url provided, a configured url will be prepended to it.
|
|
1381
|
-
So both examples will work:
|
|
1382
|
-
|
|
1383
|
-
```js
|
|
1384
|
-
I.seeCurrentUrlEquals('/register');
|
|
1385
|
-
I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
1386
|
-
```
|
|
1387
|
-
|
|
1388
|
-
@param url value to check.
|
|
1428
|
+
* If a relative url provided, a configured url will be prepended to it.
|
|
1429
|
+
* So both examples will work:
|
|
1430
|
+
*
|
|
1431
|
+
* ```js
|
|
1432
|
+
* I.seeCurrentUrlEquals('/register');
|
|
1433
|
+
* I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
1434
|
+
* ```
|
|
1435
|
+
*
|
|
1436
|
+
* @param {string} url value to check.
|
|
1437
|
+
* {--end--}
|
|
1389
1438
|
* Appium: support only web testing
|
|
1390
1439
|
*/
|
|
1391
1440
|
async seeCurrentUrlEquals(url) {
|
|
@@ -1395,9 +1444,15 @@ I.seeCurrentUrlEquals('http://my.site.com/register');
|
|
|
1395
1444
|
|
|
1396
1445
|
/**
|
|
1397
1446
|
* Checks that current url is not equal to provided one.
|
|
1398
|
-
If a relative url provided, a configured url will be prepended to it.
|
|
1399
|
-
|
|
1400
|
-
|
|
1447
|
+
* If a relative url provided, a configured url will be prepended to it.
|
|
1448
|
+
*
|
|
1449
|
+
* ```js
|
|
1450
|
+
* I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
|
|
1451
|
+
* I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
|
|
1452
|
+
* ```
|
|
1453
|
+
*
|
|
1454
|
+
* @param {string} url value to check.
|
|
1455
|
+
* {--end--}
|
|
1401
1456
|
* Appium: support only web testing
|
|
1402
1457
|
*/
|
|
1403
1458
|
async dontSeeCurrentUrlEquals(url) {
|
|
@@ -1407,30 +1462,31 @@ If a relative url provided, a configured url will be prepended to it.
|
|
|
1407
1462
|
|
|
1408
1463
|
/**
|
|
1409
1464
|
* Executes sync script on a page.
|
|
1410
|
-
Pass arguments to function as additional parameters.
|
|
1411
|
-
Will return execution result to a test.
|
|
1412
|
-
In this case you should use async function and await to receive results.
|
|
1413
|
-
|
|
1414
|
-
Example with jQuery DatePicker:
|
|
1415
|
-
|
|
1416
|
-
```js
|
|
1417
|
-
// change date of jQuery DatePicker
|
|
1418
|
-
I.executeScript(function() {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
});
|
|
1422
|
-
```
|
|
1423
|
-
Can return values. Don't forget to use `await` to get them.
|
|
1424
|
-
|
|
1425
|
-
```js
|
|
1426
|
-
let date = await I.executeScript(function(el) {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
}, '#date'); // passing jquery selector
|
|
1430
|
-
```
|
|
1431
|
-
|
|
1432
|
-
@param fn function to be executed in browser context.
|
|
1433
|
-
@param ...args args to be passed to function.
|
|
1465
|
+
* Pass arguments to function as additional parameters.
|
|
1466
|
+
* Will return execution result to a test.
|
|
1467
|
+
* In this case you should use async function and await to receive results.
|
|
1468
|
+
*
|
|
1469
|
+
* Example with jQuery DatePicker:
|
|
1470
|
+
*
|
|
1471
|
+
* ```js
|
|
1472
|
+
* // change date of jQuery DatePicker
|
|
1473
|
+
* I.executeScript(function() {
|
|
1474
|
+
* // now we are inside browser context
|
|
1475
|
+
* $('date').datetimepicker('setDate', new Date());
|
|
1476
|
+
* });
|
|
1477
|
+
* ```
|
|
1478
|
+
* Can return values. Don't forget to use `await` to get them.
|
|
1479
|
+
*
|
|
1480
|
+
* ```js
|
|
1481
|
+
* let date = await I.executeScript(function(el) {
|
|
1482
|
+
* // only basic types can be returned
|
|
1483
|
+
* return $(el).datetimepicker('getDate').toString();
|
|
1484
|
+
* }, '#date'); // passing jquery selector
|
|
1485
|
+
* ```
|
|
1486
|
+
*
|
|
1487
|
+
* @param {string|function} fn function to be executed in browser context.
|
|
1488
|
+
* @param ...args args to be passed to function.
|
|
1489
|
+
* {--end--}
|
|
1434
1490
|
* Appium: support only web testing
|
|
1435
1491
|
*
|
|
1436
1492
|
* Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
|
|
@@ -1441,28 +1497,29 @@ let date = await I.executeScript(function(el) {
|
|
|
1441
1497
|
|
|
1442
1498
|
/**
|
|
1443
1499
|
* Executes async script on page.
|
|
1444
|
-
Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
1445
|
-
|
|
1446
|
-
Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
|
|
1447
|
-
|
|
1448
|
-
```js
|
|
1449
|
-
I.executeAsyncScript(function(done) {
|
|
1450
|
-
|
|
1451
|
-
});
|
|
1452
|
-
```
|
|
1453
|
-
|
|
1454
|
-
By passing value to `done()` function you can return values.
|
|
1455
|
-
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
|
|
1456
|
-
|
|
1457
|
-
```js
|
|
1458
|
-
let val = await I.executeAsyncScript(function(url, done) {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
}, 'http://ajax.callback.url/');
|
|
1462
|
-
```
|
|
1463
|
-
|
|
1464
|
-
@param fn function to be executed in browser context.
|
|
1465
|
-
@param ...args args to be passed to function.
|
|
1500
|
+
* Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
1501
|
+
*
|
|
1502
|
+
* Example: In Vue.js to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).
|
|
1503
|
+
*
|
|
1504
|
+
* ```js
|
|
1505
|
+
* I.executeAsyncScript(function(done) {
|
|
1506
|
+
* Vue.nextTick(done); // waiting for next tick
|
|
1507
|
+
* });
|
|
1508
|
+
* ```
|
|
1509
|
+
*
|
|
1510
|
+
* By passing value to `done()` function you can return values.
|
|
1511
|
+
* Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
|
|
1512
|
+
*
|
|
1513
|
+
* ```js
|
|
1514
|
+
* let val = await I.executeAsyncScript(function(url, done) {
|
|
1515
|
+
* // in browser context
|
|
1516
|
+
* $.ajax(url, { success: (data) => done(data); }
|
|
1517
|
+
* }, 'http://ajax.callback.url/');
|
|
1518
|
+
* ```
|
|
1519
|
+
*
|
|
1520
|
+
* @param {string|function} fn function to be executed in browser context.
|
|
1521
|
+
* @param ...args args to be passed to function.
|
|
1522
|
+
* {--end--}
|
|
1466
1523
|
* Appium: support only web testing
|
|
1467
1524
|
*/
|
|
1468
1525
|
executeAsyncScript(fn) {
|
|
@@ -1485,16 +1542,17 @@ let val = await I.executeAsyncScript(function(url, done) {
|
|
|
1485
1542
|
|
|
1486
1543
|
/**
|
|
1487
1544
|
* Scrolls to element matched by locator.
|
|
1488
|
-
Extra shift can be set with offsetX and offsetY options.
|
|
1489
|
-
|
|
1490
|
-
```js
|
|
1491
|
-
I.scrollTo('footer');
|
|
1492
|
-
I.scrollTo('#submit', 5, 5);
|
|
1493
|
-
```
|
|
1494
|
-
|
|
1495
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1496
|
-
@param offsetX (optional) X-axis offset.
|
|
1497
|
-
@param offsetY (optional) Y-axis offset.
|
|
1545
|
+
* Extra shift can be set with offsetX and offsetY options.
|
|
1546
|
+
*
|
|
1547
|
+
* ```js
|
|
1548
|
+
* I.scrollTo('footer');
|
|
1549
|
+
* I.scrollTo('#submit', 5, 5);
|
|
1550
|
+
* ```
|
|
1551
|
+
*
|
|
1552
|
+
* @param {string|object} locator located by CSS|XPath|strict locator.
|
|
1553
|
+
* @param {number} offsetX (optional, `0` by default) X-axis offset.
|
|
1554
|
+
* @param {number} offsetY (optional, `0` by default) Y-axis offset.
|
|
1555
|
+
* {--end--}
|
|
1498
1556
|
* Appium: support only web testing
|
|
1499
1557
|
*/
|
|
1500
1558
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -1526,17 +1584,7 @@ I.scrollTo('#submit', 5, 5);
|
|
|
1526
1584
|
}
|
|
1527
1585
|
|
|
1528
1586
|
/**
|
|
1529
|
-
*
|
|
1530
|
-
Extra shift can be set with offsetX and offsetY options.
|
|
1531
|
-
|
|
1532
|
-
```js
|
|
1533
|
-
I.moveCursorTo('.tooltip');
|
|
1534
|
-
I.moveCursorTo('#submit', 5,5);
|
|
1535
|
-
```
|
|
1536
|
-
|
|
1537
|
-
@param locator located by CSS|XPath|strict locator.
|
|
1538
|
-
@param offsetX (optional) X-axis offset.
|
|
1539
|
-
@param offsetY (optional) Y-axis offset.
|
|
1587
|
+
* {{> moveCursorTo}}
|
|
1540
1588
|
* Appium: support only web testing
|
|
1541
1589
|
*/
|
|
1542
1590
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -1570,17 +1618,7 @@ I.moveCursorTo('#submit', 5,5);
|
|
|
1570
1618
|
}
|
|
1571
1619
|
|
|
1572
1620
|
/**
|
|
1573
|
-
*
|
|
1574
|
-
Filename is relative to output folder.
|
|
1575
|
-
Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
|
|
1576
|
-
|
|
1577
|
-
```js
|
|
1578
|
-
I.saveScreenshot('debug.png');
|
|
1579
|
-
I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
|
|
1580
|
-
```
|
|
1581
|
-
|
|
1582
|
-
@param fileName file name to save.
|
|
1583
|
-
@param fullPage (optional) flag to enable fullscreen screenshot mode.
|
|
1621
|
+
* {{> saveScreenshot}}
|
|
1584
1622
|
* Appium: support
|
|
1585
1623
|
*/
|
|
1586
1624
|
async saveScreenshot(fileName, fullPage = false) {
|
|
@@ -1609,13 +1647,7 @@ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scro
|
|
|
1609
1647
|
|
|
1610
1648
|
|
|
1611
1649
|
/**
|
|
1612
|
-
*
|
|
1613
|
-
|
|
1614
|
-
```js
|
|
1615
|
-
I.setCookie({name: 'auth', value: true});
|
|
1616
|
-
```
|
|
1617
|
-
|
|
1618
|
-
@param cookie cookie JSON object.
|
|
1650
|
+
* {{> setCookie}}
|
|
1619
1651
|
* Appium: support only web testing
|
|
1620
1652
|
*
|
|
1621
1653
|
* Uses Selenium's JSON [cookie
|
|
@@ -1626,15 +1658,7 @@ I.setCookie({name: 'auth', value: true});
|
|
|
1626
1658
|
}
|
|
1627
1659
|
|
|
1628
1660
|
/**
|
|
1629
|
-
*
|
|
1630
|
-
if none provided clears all cookies.
|
|
1631
|
-
|
|
1632
|
-
```js
|
|
1633
|
-
I.clearCookie();
|
|
1634
|
-
I.clearCookie('test');
|
|
1635
|
-
```
|
|
1636
|
-
|
|
1637
|
-
@param cookie (optional) cookie name.
|
|
1661
|
+
* {{> clearCookie}}
|
|
1638
1662
|
* Appium: support only web testing
|
|
1639
1663
|
*/
|
|
1640
1664
|
async clearCookie(cookie) {
|
|
@@ -1642,13 +1666,7 @@ I.clearCookie('test');
|
|
|
1642
1666
|
}
|
|
1643
1667
|
|
|
1644
1668
|
/**
|
|
1645
|
-
*
|
|
1646
|
-
|
|
1647
|
-
```js
|
|
1648
|
-
I.seeCookie('Auth');
|
|
1649
|
-
```
|
|
1650
|
-
|
|
1651
|
-
@param name cookie name.
|
|
1669
|
+
* {{> seeCookie}}
|
|
1652
1670
|
* Appium: support only web testing
|
|
1653
1671
|
*/
|
|
1654
1672
|
async seeCookie(name) {
|
|
@@ -1657,9 +1675,7 @@ I.seeCookie('Auth');
|
|
|
1657
1675
|
}
|
|
1658
1676
|
|
|
1659
1677
|
/**
|
|
1660
|
-
*
|
|
1661
|
-
|
|
1662
|
-
@param name cookie name.
|
|
1678
|
+
* {{> dontSeeCookie}}
|
|
1663
1679
|
* Appium: support only web testing
|
|
1664
1680
|
*/
|
|
1665
1681
|
async dontSeeCookie(name) {
|
|
@@ -1668,16 +1684,7 @@ I.seeCookie('Auth');
|
|
|
1668
1684
|
}
|
|
1669
1685
|
|
|
1670
1686
|
/**
|
|
1671
|
-
*
|
|
1672
|
-
If none provided gets all cookies.
|
|
1673
|
-
* Resumes test execution, so **should be used inside async with `await`** operator.
|
|
1674
|
-
|
|
1675
|
-
```js
|
|
1676
|
-
let cookie = await I.grabCookie('auth');
|
|
1677
|
-
assert(cookie.value, '123456');
|
|
1678
|
-
```
|
|
1679
|
-
|
|
1680
|
-
@param name (optional) cookie name.
|
|
1687
|
+
* {{> grabCookie}}
|
|
1681
1688
|
* Appium: support only web testing
|
|
1682
1689
|
*/
|
|
1683
1690
|
async grabCookie(name) {
|
|
@@ -1738,47 +1745,18 @@ assert(cookie.value, '123456');
|
|
|
1738
1745
|
|
|
1739
1746
|
/**
|
|
1740
1747
|
* Presses a key on a focused element.
|
|
1741
|
-
Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
|
|
1742
|
-
will be replaced with corresponding unicode.
|
|
1743
|
-
If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
|
|
1744
|
-
|
|
1745
|
-
```js
|
|
1746
|
-
I.pressKey('Enter');
|
|
1747
|
-
I.pressKey(['Control','a']);
|
|
1748
|
-
```
|
|
1749
|
-
|
|
1750
|
-
@param key key or array of keys to press.
|
|
1751
|
-
*
|
|
1752
|
-
|
|
1753
|
-
- `'Add'`,
|
|
1754
|
-
- `'Alt'`,
|
|
1755
|
-
- `'ArrowDown'` or `'Down arrow'`,
|
|
1756
|
-
- `'ArrowLeft'` or `'Left arrow'`,
|
|
1757
|
-
- `'ArrowRight'` or `'Right arrow'`,
|
|
1758
|
-
- `'ArrowUp'` or `'Up arrow'`,
|
|
1759
|
-
- `'Backspace'`,
|
|
1760
|
-
- `'Command'`,
|
|
1761
|
-
- `'Control'`,
|
|
1762
|
-
- `'Del'`,
|
|
1763
|
-
- `'Divide'`,
|
|
1764
|
-
- `'End'`,
|
|
1765
|
-
- `'Enter'`,
|
|
1766
|
-
- `'Equals'`,
|
|
1767
|
-
- `'Escape'`,
|
|
1768
|
-
- `'F1 to F12'`,
|
|
1769
|
-
- `'Home'`,
|
|
1770
|
-
- `'Insert'`,
|
|
1771
|
-
- `'Meta'`,
|
|
1772
|
-
- `'Multiply'`,
|
|
1773
|
-
- `'Numpad 0'` to `'Numpad 9'`,
|
|
1774
|
-
- `'Pagedown'` or `'PageDown'`,
|
|
1775
|
-
- `'Pageup'` or `'PageUp'`,
|
|
1776
|
-
- `'Pause'`,
|
|
1777
|
-
- `'Semicolon'`,
|
|
1778
|
-
- `'Shift'`,
|
|
1779
|
-
- `'Space'`,
|
|
1780
|
-
- `'Subtract'`,
|
|
1781
|
-
- `'Tab'`.
|
|
1748
|
+
* Special keys like 'Enter', 'Control', [etc](https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value)
|
|
1749
|
+
* will be replaced with corresponding unicode.
|
|
1750
|
+
* If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
|
|
1751
|
+
*
|
|
1752
|
+
* ```js
|
|
1753
|
+
* I.pressKey('Enter');
|
|
1754
|
+
* I.pressKey(['Control','a']);
|
|
1755
|
+
* ```
|
|
1756
|
+
*
|
|
1757
|
+
* @param {string|array} key key or array of keys to press.
|
|
1758
|
+
* {--end--}
|
|
1759
|
+
* {{> _keys }}
|
|
1782
1760
|
*
|
|
1783
1761
|
* To make combinations with modifier and mouse clicks (like Ctrl+Click) press a modifier, click, then release it.
|
|
1784
1762
|
* Appium: support, but clear field before pressing in apps:
|
|
@@ -1802,10 +1780,11 @@ I.pressKey(['Control','a']);
|
|
|
1802
1780
|
|
|
1803
1781
|
/**
|
|
1804
1782
|
* Resize the current window to provided width and height.
|
|
1805
|
-
First parameter can be set to `maximize`.
|
|
1806
|
-
|
|
1807
|
-
@param width width in pixels or `maximize`.
|
|
1808
|
-
@param height height in pixels.
|
|
1783
|
+
* First parameter can be set to `maximize`.
|
|
1784
|
+
*
|
|
1785
|
+
* @param {number} width width in pixels or `maximize`.
|
|
1786
|
+
* @param {number} height height in pixels.
|
|
1787
|
+
* {--end--}
|
|
1809
1788
|
* Appium: not tested in web, in apps doesn't work
|
|
1810
1789
|
*/
|
|
1811
1790
|
async resizeWindow(width, height) {
|
|
@@ -1827,13 +1806,14 @@ First parameter can be set to `maximize`.
|
|
|
1827
1806
|
|
|
1828
1807
|
/**
|
|
1829
1808
|
* Drag an item to a destination element.
|
|
1830
|
-
|
|
1831
|
-
```js
|
|
1832
|
-
I.dragAndDrop('#dragHandle', '#container');
|
|
1833
|
-
```
|
|
1834
|
-
|
|
1835
|
-
@param srcElement located by CSS|XPath|strict locator.
|
|
1836
|
-
@param destElement located by CSS|XPath|strict locator.
|
|
1809
|
+
*
|
|
1810
|
+
* ```js
|
|
1811
|
+
* I.dragAndDrop('#dragHandle', '#container');
|
|
1812
|
+
* ```
|
|
1813
|
+
*
|
|
1814
|
+
* @param {string|object} srcElement located by CSS|XPath|strict locator.
|
|
1815
|
+
* @param {string|object} destElement located by CSS|XPath|strict locator.
|
|
1816
|
+
* {--end--}
|
|
1837
1817
|
* Appium: not tested
|
|
1838
1818
|
*/
|
|
1839
1819
|
async dragAndDrop(srcElement, destElement) {
|
|
@@ -1893,13 +1873,13 @@ I.dragAndDrop('#dragHandle', '#container');
|
|
|
1893
1873
|
|
|
1894
1874
|
/**
|
|
1895
1875
|
* Pauses execution for a number of seconds.
|
|
1896
|
-
|
|
1897
|
-
```js
|
|
1898
|
-
I.wait(2); // wait 2 secs
|
|
1899
|
-
```
|
|
1900
|
-
|
|
1901
|
-
@param sec number of second to wait.
|
|
1902
|
-
|
|
1876
|
+
*
|
|
1877
|
+
* ```js
|
|
1878
|
+
* I.wait(2); // wait 2 secs
|
|
1879
|
+
* ```
|
|
1880
|
+
*
|
|
1881
|
+
* @param {number} sec number of second to wait.
|
|
1882
|
+
* {--end--}
|
|
1903
1883
|
* Appium: support
|
|
1904
1884
|
*/
|
|
1905
1885
|
async wait(sec) {
|
|
@@ -1908,10 +1888,11 @@ I.wait(2); // wait 2 secs
|
|
|
1908
1888
|
|
|
1909
1889
|
/**
|
|
1910
1890
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
1911
|
-
Element can be located by CSS or XPath.
|
|
1912
|
-
|
|
1913
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
1914
|
-
@param sec (optional) time in seconds to wait, 1 by default.
|
|
1891
|
+
* Element can be located by CSS or XPath.
|
|
1892
|
+
*
|
|
1893
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
1894
|
+
* @param sec (optional) time in seconds to wait, 1 by default.
|
|
1895
|
+
* {--end--}
|
|
1915
1896
|
* Appium: support
|
|
1916
1897
|
*/
|
|
1917
1898
|
async waitForEnabled(locator, sec = null) {
|
|
@@ -1932,15 +1913,16 @@ Element can be located by CSS or XPath.
|
|
|
1932
1913
|
|
|
1933
1914
|
/**
|
|
1934
1915
|
* Waits for element to be present on page (by default waits for 1sec).
|
|
1935
|
-
Element can be located by CSS or XPath.
|
|
1936
|
-
|
|
1937
|
-
```js
|
|
1938
|
-
I.waitForElement('.btn.continue');
|
|
1939
|
-
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1940
|
-
```
|
|
1941
|
-
|
|
1942
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
1943
|
-
@param sec (optional) time in seconds to wait
|
|
1916
|
+
* Element can be located by CSS or XPath.
|
|
1917
|
+
*
|
|
1918
|
+
* ```js
|
|
1919
|
+
* I.waitForElement('.btn.continue');
|
|
1920
|
+
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
1921
|
+
* ```
|
|
1922
|
+
*
|
|
1923
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
1924
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1925
|
+
* {--end--}
|
|
1944
1926
|
* Appium: support
|
|
1945
1927
|
*/
|
|
1946
1928
|
async waitForElement(locator, sec = null) {
|
|
@@ -1961,13 +1943,14 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
|
1961
1943
|
|
|
1962
1944
|
/**
|
|
1963
1945
|
* Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
|
|
1964
|
-
|
|
1965
|
-
```js
|
|
1966
|
-
I.waitInUrl('/info', 2);
|
|
1967
|
-
```
|
|
1968
|
-
|
|
1969
|
-
@param urlPart value to check.
|
|
1970
|
-
@param sec (optional) time in seconds to wait
|
|
1946
|
+
*
|
|
1947
|
+
* ```js
|
|
1948
|
+
* I.waitInUrl('/info', 2);
|
|
1949
|
+
* ```
|
|
1950
|
+
*
|
|
1951
|
+
* @param {string} urlPart value to check.
|
|
1952
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1953
|
+
* {--end--}
|
|
1971
1954
|
*/
|
|
1972
1955
|
async waitInUrl(urlPart, sec = null) {
|
|
1973
1956
|
const client = this.browser;
|
|
@@ -1990,14 +1973,15 @@ I.waitInUrl('/info', 2);
|
|
|
1990
1973
|
|
|
1991
1974
|
/**
|
|
1992
1975
|
* Waits for the entire URL to match the expected
|
|
1993
|
-
|
|
1994
|
-
```js
|
|
1995
|
-
I.waitUrlEquals('/info', 2);
|
|
1996
|
-
I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
1997
|
-
```
|
|
1998
|
-
|
|
1999
|
-
@param urlPart value to check.
|
|
2000
|
-
@param sec (optional) time in seconds to wait
|
|
1976
|
+
*
|
|
1977
|
+
* ```js
|
|
1978
|
+
* I.waitUrlEquals('/info', 2);
|
|
1979
|
+
* I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
1980
|
+
* ```
|
|
1981
|
+
*
|
|
1982
|
+
* @param {string} urlPart value to check.
|
|
1983
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
1984
|
+
* {--end--}
|
|
2001
1985
|
*/
|
|
2002
1986
|
async waitUrlEquals(urlPart, sec = null) {
|
|
2003
1987
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2022,17 +2006,18 @@ I.waitUrlEquals('http://127.0.0.1:8000/info');
|
|
|
2022
2006
|
|
|
2023
2007
|
/**
|
|
2024
2008
|
* Waits for a text to appear (by default waits for 1sec).
|
|
2025
|
-
Element can be located by CSS or XPath.
|
|
2026
|
-
Narrow down search results by providing context.
|
|
2027
|
-
|
|
2028
|
-
```js
|
|
2029
|
-
I.waitForText('Thank you, form has been submitted');
|
|
2030
|
-
I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
2031
|
-
```
|
|
2032
|
-
|
|
2033
|
-
@param text to wait for.
|
|
2034
|
-
@param sec (optional) time in seconds to wait
|
|
2035
|
-
@param context (optional) element located by CSS|XPath|strict locator.
|
|
2009
|
+
* Element can be located by CSS or XPath.
|
|
2010
|
+
* Narrow down search results by providing context.
|
|
2011
|
+
*
|
|
2012
|
+
* ```js
|
|
2013
|
+
* I.waitForText('Thank you, form has been submitted');
|
|
2014
|
+
* I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
2015
|
+
* ```
|
|
2016
|
+
*
|
|
2017
|
+
* @param {string }text to wait for.
|
|
2018
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2019
|
+
* @param {string|object} context (optional) element located by CSS|XPath|strict locator.
|
|
2020
|
+
* {--end--}
|
|
2036
2021
|
* Appium: support
|
|
2037
2022
|
*/
|
|
2038
2023
|
async waitForText(text, sec = null, context = null) {
|
|
@@ -2054,14 +2039,15 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
2054
2039
|
|
|
2055
2040
|
/**
|
|
2056
2041
|
* Waits for the specified value to be in value attribute.
|
|
2057
|
-
|
|
2058
|
-
```js
|
|
2059
|
-
I.waitForValue('//input', "GoodValue");
|
|
2060
|
-
```
|
|
2061
|
-
|
|
2062
|
-
@param field input field.
|
|
2063
|
-
@param value expected value.
|
|
2064
|
-
@param sec (optional) time in seconds to wait
|
|
2042
|
+
*
|
|
2043
|
+
* ```js
|
|
2044
|
+
* I.waitForValue('//input', "GoodValue");
|
|
2045
|
+
* ```
|
|
2046
|
+
*
|
|
2047
|
+
* @param {string|object} field input field.
|
|
2048
|
+
* @param {string }value expected value.
|
|
2049
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2050
|
+
* {--end--}
|
|
2065
2051
|
*/
|
|
2066
2052
|
async waitForValue(field, value, sec = null) {
|
|
2067
2053
|
const client = this.browser;
|
|
@@ -2082,14 +2068,15 @@ I.waitForValue('//input', "GoodValue");
|
|
|
2082
2068
|
|
|
2083
2069
|
/**
|
|
2084
2070
|
* Waits for an element to become visible on a page (by default waits for 1sec).
|
|
2085
|
-
Element can be located by CSS or XPath.
|
|
2086
|
-
|
|
2087
|
-
```
|
|
2088
|
-
I.waitForVisible('#popup');
|
|
2089
|
-
```
|
|
2090
|
-
|
|
2091
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
2092
|
-
@param sec (optional) time in seconds to wait
|
|
2071
|
+
* Element can be located by CSS or XPath.
|
|
2072
|
+
*
|
|
2073
|
+
* ```js
|
|
2074
|
+
* I.waitForVisible('#popup');
|
|
2075
|
+
* ```
|
|
2076
|
+
*
|
|
2077
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
2078
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2079
|
+
* {--end--}
|
|
2093
2080
|
* Appium: support
|
|
2094
2081
|
*/
|
|
2095
2082
|
async waitForVisible(locator, sec = null) {
|
|
@@ -2107,14 +2094,15 @@ I.waitForVisible('#popup');
|
|
|
2107
2094
|
|
|
2108
2095
|
/**
|
|
2109
2096
|
* Waits for a specified number of elements on the page.
|
|
2110
|
-
|
|
2111
|
-
```js
|
|
2112
|
-
I.waitNumberOfVisibleElements('a', 3);
|
|
2113
|
-
```
|
|
2114
|
-
|
|
2115
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
2116
|
-
@param num number of elements.
|
|
2117
|
-
@param sec (optional) time in seconds to wait
|
|
2097
|
+
*
|
|
2098
|
+
* ```js
|
|
2099
|
+
* I.waitNumberOfVisibleElements('a', 3);
|
|
2100
|
+
* ```
|
|
2101
|
+
*
|
|
2102
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
2103
|
+
* @param {number} num number of elements.
|
|
2104
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2105
|
+
* {--end--}
|
|
2118
2106
|
*/
|
|
2119
2107
|
async waitNumberOfVisibleElements(locator, num, sec = null) {
|
|
2120
2108
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -2130,14 +2118,15 @@ I.waitNumberOfVisibleElements('a', 3);
|
|
|
2130
2118
|
|
|
2131
2119
|
/**
|
|
2132
2120
|
* Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
|
|
2133
|
-
Element can be located by CSS or XPath.
|
|
2134
|
-
|
|
2135
|
-
```
|
|
2136
|
-
I.waitForInvisible('#popup');
|
|
2137
|
-
```
|
|
2138
|
-
|
|
2139
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
2140
|
-
@param sec (optional) time in seconds to wait
|
|
2121
|
+
* Element can be located by CSS or XPath.
|
|
2122
|
+
*
|
|
2123
|
+
* ```js
|
|
2124
|
+
* I.waitForInvisible('#popup');
|
|
2125
|
+
* ```
|
|
2126
|
+
*
|
|
2127
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
2128
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2129
|
+
* {--end--}
|
|
2141
2130
|
* Appium: support
|
|
2142
2131
|
*/
|
|
2143
2132
|
async waitForInvisible(locator, sec = null) {
|
|
@@ -2155,14 +2144,15 @@ I.waitForInvisible('#popup');
|
|
|
2155
2144
|
|
|
2156
2145
|
/**
|
|
2157
2146
|
* Waits for an element to hide (by default waits for 1sec).
|
|
2158
|
-
Element can be located by CSS or XPath.
|
|
2159
|
-
|
|
2160
|
-
```
|
|
2161
|
-
I.waitToHide('#popup');
|
|
2162
|
-
```
|
|
2163
|
-
|
|
2164
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
2165
|
-
@param sec (optional) time in seconds to wait
|
|
2147
|
+
* Element can be located by CSS or XPath.
|
|
2148
|
+
*
|
|
2149
|
+
* ```js
|
|
2150
|
+
* I.waitToHide('#popup');
|
|
2151
|
+
* ```
|
|
2152
|
+
*
|
|
2153
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
2154
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2155
|
+
* {--end--}
|
|
2166
2156
|
* Appium: support
|
|
2167
2157
|
*/
|
|
2168
2158
|
async waitToHide(locator, sec = null) {
|
|
@@ -2176,14 +2166,15 @@ I.waitToHide('#popup');
|
|
|
2176
2166
|
|
|
2177
2167
|
/**
|
|
2178
2168
|
* Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
|
|
2179
|
-
Element can be located by CSS or XPath.
|
|
2180
|
-
|
|
2181
|
-
```
|
|
2182
|
-
I.waitForDetached('#popup');
|
|
2183
|
-
```
|
|
2184
|
-
|
|
2185
|
-
@param locator element located by CSS|XPath|strict locator.
|
|
2186
|
-
@param sec (optional) time in seconds to wait
|
|
2169
|
+
* Element can be located by CSS or XPath.
|
|
2170
|
+
*
|
|
2171
|
+
* ```js
|
|
2172
|
+
* I.waitForDetached('#popup');
|
|
2173
|
+
* ```
|
|
2174
|
+
*
|
|
2175
|
+
* @param {string|object} locator element located by CSS|XPath|strict locator.
|
|
2176
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2177
|
+
* {--end--}
|
|
2187
2178
|
* Appium: support
|
|
2188
2179
|
*/
|
|
2189
2180
|
async waitForDetached(locator, sec = null) {
|
|
@@ -2199,21 +2190,22 @@ I.waitForDetached('#popup');
|
|
|
2199
2190
|
|
|
2200
2191
|
/**
|
|
2201
2192
|
* Waits for a function to return true (waits for 1 sec by default).
|
|
2202
|
-
Running in browser context.
|
|
2203
|
-
|
|
2204
|
-
```js
|
|
2205
|
-
I.waitForFunction(fn[, [args[, timeout]])
|
|
2206
|
-
```
|
|
2207
|
-
|
|
2208
|
-
```js
|
|
2209
|
-
I.waitForFunction(() => window.requests == 0);
|
|
2210
|
-
I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
|
|
2211
|
-
I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
|
|
2212
|
-
```
|
|
2213
|
-
|
|
2214
|
-
@param fn to be executed in browser context.
|
|
2215
|
-
@param argsOrSec (optional) arguments for function or seconds.
|
|
2216
|
-
@param sec (optional) time in seconds to wait
|
|
2193
|
+
* Running in browser context.
|
|
2194
|
+
*
|
|
2195
|
+
* ```js
|
|
2196
|
+
* I.waitForFunction(fn[, [args[, timeout]])
|
|
2197
|
+
* ```
|
|
2198
|
+
*
|
|
2199
|
+
* ```js
|
|
2200
|
+
* I.waitForFunction(() => window.requests == 0);
|
|
2201
|
+
* I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
|
|
2202
|
+
* I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
|
|
2203
|
+
* ```
|
|
2204
|
+
*
|
|
2205
|
+
* @param {string|function} fn to be executed in browser context.
|
|
2206
|
+
* @param {array|number} argsOrSec (optional, `1` by default) arguments for function or seconds.
|
|
2207
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2208
|
+
* {--end--}
|
|
2217
2209
|
* Appium: support
|
|
2218
2210
|
*/
|
|
2219
2211
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
@@ -2233,15 +2225,16 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
2233
2225
|
|
|
2234
2226
|
/**
|
|
2235
2227
|
* Waits for a function to return true (waits for 1sec by default).
|
|
2236
|
-
|
|
2237
|
-
```js
|
|
2238
|
-
I.waitUntil(() => window.requests == 0);
|
|
2239
|
-
I.waitUntil(() => window.requests == 0, 5);
|
|
2240
|
-
```
|
|
2241
|
-
|
|
2242
|
-
@param fn function which is executed in browser context.
|
|
2243
|
-
@param sec (optional) time in seconds to wait
|
|
2244
|
-
@param timeoutMsg
|
|
2228
|
+
*
|
|
2229
|
+
* ```js
|
|
2230
|
+
* I.waitUntil(() => window.requests == 0);
|
|
2231
|
+
* I.waitUntil(() => window.requests == 0, 5);
|
|
2232
|
+
* ```
|
|
2233
|
+
*
|
|
2234
|
+
* @param {function|string} fn function which is executed in browser context.
|
|
2235
|
+
* @param {number} sec (optional, `1` by default) time in seconds to wait
|
|
2236
|
+
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
2237
|
+
* {--end--}
|
|
2245
2238
|
* @param interval (optional) time in seconds between condition checks.
|
|
2246
2239
|
* * *Appium*: supported
|
|
2247
2240
|
*/
|
|
@@ -2253,8 +2246,14 @@ I.waitUntil(() => window.requests == 0, 5);
|
|
|
2253
2246
|
|
|
2254
2247
|
/**
|
|
2255
2248
|
* Switches frame or in case of null locator reverts to parent.
|
|
2256
|
-
|
|
2257
|
-
|
|
2249
|
+
*
|
|
2250
|
+
* ```js
|
|
2251
|
+
* I.switchTo('iframe'); // switch to first iframe
|
|
2252
|
+
* I.switchTo(); // switch back to main page
|
|
2253
|
+
* ```
|
|
2254
|
+
*
|
|
2255
|
+
* @param {string|object} locator (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
2256
|
+
* {--end--}
|
|
2258
2257
|
* Appium: support only web testing
|
|
2259
2258
|
*/
|
|
2260
2259
|
async switchTo(locator) {
|
|
@@ -2345,10 +2344,13 @@ I.waitUntil(() => window.requests == 0, 5);
|
|
|
2345
2344
|
|
|
2346
2345
|
/**
|
|
2347
2346
|
* Grab number of open tabs.
|
|
2348
|
-
|
|
2349
|
-
```js
|
|
2350
|
-
I.grabNumberOfOpenTabs();
|
|
2351
|
-
```
|
|
2347
|
+
*
|
|
2348
|
+
* ```js
|
|
2349
|
+
* let tabs = await I.grabNumberOfOpenTabs();
|
|
2350
|
+
* ```
|
|
2351
|
+
*
|
|
2352
|
+
* @returns {Promise<number>} number of open tabs
|
|
2353
|
+
* {--end--}
|
|
2352
2354
|
*/
|
|
2353
2355
|
async grabNumberOfOpenTabs() {
|
|
2354
2356
|
const pages = await this.browser.getTabIds();
|
|
@@ -2357,11 +2359,11 @@ I.grabNumberOfOpenTabs();
|
|
|
2357
2359
|
|
|
2358
2360
|
/**
|
|
2359
2361
|
* Reload the current page.
|
|
2360
|
-
|
|
2361
|
-
```js
|
|
2362
|
-
I.refreshPage();
|
|
2363
|
-
```
|
|
2364
|
-
|
|
2362
|
+
*
|
|
2363
|
+
* ```js
|
|
2364
|
+
* I.refreshPage();
|
|
2365
|
+
* ```
|
|
2366
|
+
* {--end--}
|
|
2365
2367
|
*/
|
|
2366
2368
|
async refreshPage() {
|
|
2367
2369
|
const client = this.browser;
|
|
@@ -2370,10 +2372,11 @@ I.refreshPage();
|
|
|
2370
2372
|
|
|
2371
2373
|
/**
|
|
2372
2374
|
* Scroll page to the top.
|
|
2373
|
-
|
|
2374
|
-
```js
|
|
2375
|
-
I.scrollPageToTop();
|
|
2376
|
-
```
|
|
2375
|
+
*
|
|
2376
|
+
* ```js
|
|
2377
|
+
* I.scrollPageToTop();
|
|
2378
|
+
* ```
|
|
2379
|
+
* {--end--}
|
|
2377
2380
|
*/
|
|
2378
2381
|
scrollPageToTop() {
|
|
2379
2382
|
const client = this.browser;
|
|
@@ -2386,10 +2389,11 @@ I.scrollPageToTop();
|
|
|
2386
2389
|
|
|
2387
2390
|
/**
|
|
2388
2391
|
* Scroll page to the bottom.
|
|
2389
|
-
|
|
2390
|
-
```js
|
|
2391
|
-
I.scrollPageToBottom();
|
|
2392
|
-
```
|
|
2392
|
+
*
|
|
2393
|
+
* ```js
|
|
2394
|
+
* I.scrollPageToBottom();
|
|
2395
|
+
* ```
|
|
2396
|
+
* {--end--}
|
|
2393
2397
|
*/
|
|
2394
2398
|
scrollPageToBottom() {
|
|
2395
2399
|
const client = this.browser;
|
|
@@ -2406,12 +2410,7 @@ I.scrollPageToBottom();
|
|
|
2406
2410
|
}
|
|
2407
2411
|
|
|
2408
2412
|
/**
|
|
2409
|
-
*
|
|
2410
|
-
Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
2411
|
-
|
|
2412
|
-
```js
|
|
2413
|
-
let { x, y } = await I.grabPageScrollPosition();
|
|
2414
|
-
```
|
|
2413
|
+
* {{> grabPageScrollPosition}}
|
|
2415
2414
|
*/
|
|
2416
2415
|
async grabPageScrollPosition() {
|
|
2417
2416
|
/* eslint-disable comma-dangle */
|