codeceptjs 2.3.4 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +28 -6
- package/bin/codecept.js +42 -0
- package/docs/advanced.md +45 -1
- package/docs/angular.md +3 -3
- package/docs/basics.md +162 -118
- package/docs/bdd.md +30 -5
- package/docs/best.md +8 -6
- package/docs/books.md +6 -1
- package/docs/build/Appium.js +95 -85
- package/docs/build/FileSystem.js +48 -3
- package/docs/build/GraphQL.js +3 -2
- package/docs/build/GraphQLDataFactory.js +1 -0
- package/docs/build/Mochawesome.js +3 -2
- package/docs/build/MockRequest.js +23 -5
- package/docs/build/Nightmare.js +87 -128
- package/docs/build/Protractor.js +107 -155
- package/docs/build/Puppeteer.js +190 -174
- package/docs/build/REST.js +13 -9
- package/docs/build/SeleniumWebdriver.js +0 -17
- package/docs/build/TestCafe.js +164 -158
- package/docs/build/WebDriver.js +236 -211
- package/docs/build/WebDriverIO.js +218 -187
- package/docs/changelog.md +57 -1
- package/docs/commands.md +41 -2
- package/docs/community-helpers.md +12 -1
- package/docs/configuration.md +5 -2
- package/docs/continuous-integration.md +22 -0
- package/docs/{helpers.md → custom-helpers.md} +16 -10
- package/docs/data.md +7 -6
- package/docs/detox.md +6 -6
- package/docs/email.md +4 -2
- package/docs/examples.md +22 -3
- package/docs/helpers/ApiDataFactory.md +15 -13
- package/docs/helpers/Appium.md +1011 -468
- package/docs/helpers/Detox.md +33 -26
- package/docs/helpers/FileSystem.md +43 -13
- package/docs/helpers/GraphQL.md +17 -15
- package/docs/helpers/GraphQLDataFactory.md +15 -13
- package/docs/helpers/Mochawesome.md +3 -1
- package/docs/helpers/MockRequest.md +37 -19
- package/docs/helpers/Nightmare.md +129 -240
- package/docs/helpers/Polly.md +1 -1
- package/docs/helpers/Protractor.md +157 -298
- package/docs/helpers/Puppeteer.md +216 -335
- package/docs/helpers/REST.md +29 -24
- package/docs/helpers/TestCafe.md +137 -235
- package/docs/helpers/WebDriver.md +250 -347
- package/docs/hooks.md +14 -10
- package/docs/index.md +112 -0
- package/docs/installation.md +3 -1
- package/docs/locators.md +19 -8
- package/docs/mobile-react-native-locators.md +2 -2
- package/docs/mobile.md +5 -3
- package/docs/nightmare.md +2 -1
- package/docs/pageobjects.md +4 -2
- package/docs/parallel.md +4 -2
- package/docs/plugins.md +41 -15
- package/docs/puppeteer.md +8 -6
- package/docs/quickstart.md +130 -0
- package/docs/react.md +4 -2
- package/docs/reports.md +6 -4
- package/docs/testcafe.md +10 -8
- package/docs/translation.md +4 -2
- package/docs/ui.md +56 -0
- package/docs/videos.md +11 -2
- package/docs/visual.md +7 -5
- package/docs/vue.md +121 -0
- package/docs/webapi/appendField.mustache +1 -1
- package/docs/webapi/attachFile.mustache +1 -1
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +2 -2
- package/docs/webapi/dontSee.mustache +1 -2
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/dontSeeElement.mustache +1 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +1 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +1 -1
- package/docs/webapi/dragSlider.mustache +1 -1
- package/docs/webapi/executeAsyncScript.mustache +2 -1
- package/docs/webapi/executeScript.mustache +2 -1
- package/docs/webapi/fillField.mustache +1 -1
- package/docs/webapi/grabAttributeFrom.mustache +1 -1
- package/docs/webapi/grabBrowserLogs.mustache +1 -1
- package/docs/webapi/grabCookie.mustache +2 -2
- package/docs/webapi/grabCssPropertyFrom.mustache +1 -1
- package/docs/webapi/grabHTMLFrom.mustache +1 -1
- package/docs/webapi/grabNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/grabPageScrollPosition.mustache +1 -1
- package/docs/webapi/grabTextFrom.mustache +2 -2
- package/docs/webapi/grabValueFrom.mustache +1 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -1
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +1 -1
- package/docs/webapi/scrollIntoView.mustache +10 -0
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +1 -1
- package/docs/webapi/seeAttributesOnElements.mustache +1 -1
- package/docs/webapi/seeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInField.mustache +1 -1
- package/docs/webapi/seeNumberOfElements.mustache +1 -1
- package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/seeTextEquals.mustache +8 -0
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/switchTo.mustache +1 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/waitForClickable.mustache +10 -0
- package/docs/webapi/waitForDetached.mustache +2 -2
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +2 -2
- package/docs/webapi/waitForFunction.mustache +2 -2
- package/docs/webapi/waitForInvisible.mustache +2 -2
- package/docs/webapi/waitForText.mustache +2 -2
- package/docs/webapi/waitForValue.mustache +1 -1
- package/docs/webapi/waitForVisible.mustache +2 -2
- package/docs/webapi/waitInUrl.mustache +1 -1
- package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/waitToHide.mustache +2 -2
- package/docs/webapi/waitUntil.mustache +3 -2
- package/docs/webapi/waitUrlEquals.mustache +1 -1
- package/docs/webdriver.md +20 -18
- package/docs/wiki/.git/FETCH_HEAD +1 -0
- package/docs/wiki/.git/HEAD +1 -0
- package/docs/wiki/.git/ORIG_HEAD +1 -0
- package/docs/wiki/.git/config +11 -0
- package/docs/wiki/.git/description +1 -0
- package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
- package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
- package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +114 -0
- package/docs/wiki/.git/hooks/post-update.sample +8 -0
- package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
- package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
- package/docs/wiki/.git/hooks/pre-push.sample +53 -0
- package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
- package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
- package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
- package/docs/wiki/.git/hooks/update.sample +128 -0
- package/docs/wiki/.git/index +0 -0
- package/docs/wiki/.git/info/exclude +6 -0
- package/docs/wiki/.git/logs/HEAD +4 -0
- package/docs/wiki/.git/logs/refs/heads/master +4 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/master +3 -0
- package/docs/wiki/.git/objects/00/d216b0774d15db2d0a2a0d4ce249b5251acc55 +3 -0
- package/docs/wiki/.git/objects/09/01d87c5241905fdfe3493cfe8f04df4a2685ea +0 -0
- package/docs/wiki/.git/objects/0d/bdd0c20c4deb6a8cc81dbbf32ecf8c09238983 +2 -0
- package/docs/wiki/.git/objects/1a/c29e4fa82422c52392f22f0f2b8d1a759535bf +0 -0
- package/docs/wiki/.git/objects/27/12f92898d3e8f68e229b6cda76570d6c66d781 +0 -0
- package/docs/wiki/.git/objects/2d/dbe22c257166b648928eeb9460ecfb71ba702d +0 -0
- package/docs/wiki/.git/objects/2f/c942ec3773efd2678d9ff98035c61fcded81a1 +0 -0
- package/docs/wiki/.git/objects/40/a2856342c67796b48911a256b764fb06888b94 +5 -0
- package/docs/wiki/.git/objects/47/53181844fc4dc563cf3aa5e80462243cb58d38 +0 -0
- package/docs/wiki/.git/objects/4e/24a95fb2e4f8ffef51f19b694451a205c06f10 +3 -0
- package/docs/wiki/.git/objects/73/31ebd96f3c7e08a9f63f05a25f939afa0d4de1 +0 -0
- package/docs/wiki/.git/objects/86/19cbb2289caa502e33fccf0ed14eecf6ba2ba0 +0 -0
- package/docs/wiki/.git/objects/a4/72f797d9d74b87c9f71a2b1539d75bb07d1e35 +0 -0
- package/docs/wiki/.git/objects/c9/9f3e4bd227d6b050b2e416f9876df49583dbf6 +0 -0
- package/docs/wiki/.git/objects/ca/e609b4ef3e0ef85fcbe0d68d1a58246584b915 +0 -0
- package/docs/wiki/.git/objects/d5/8386ca72f6d550548f3d71d74e3ac73d5ad488 +0 -0
- package/docs/wiki/.git/objects/d9/c6874a6de524bdafeb563a20d847f4fdd59a86 +0 -0
- package/docs/wiki/.git/objects/f1/c944675bb38b40ae553b0be36c14674c79af54 +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.idx +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.pack +0 -0
- package/docs/wiki/.git/packed-refs +2 -0
- package/docs/wiki/.git/refs/heads/master +1 -0
- package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/refs/remotes/origin/master +1 -0
- package/docs/wiki/Books-&-Posts.md +27 -0
- package/docs/wiki/Community-Helpers.md +41 -0
- package/docs/wiki/Examples.md +138 -0
- package/docs/wiki/Home.md +11 -0
- package/docs/wiki/Release-process.md +25 -0
- package/docs/wiki/Roadmap.md +23 -0
- package/docs/wiki/Videos.md +19 -0
- package/lib/actor.js +18 -1
- package/lib/assert/error.js +3 -3
- package/lib/codecept.js +9 -6
- package/lib/command/configMigrate.js +7 -6
- package/lib/command/definitions.js +98 -350
- package/lib/command/generate.js +22 -17
- package/lib/command/gherkin/init.js +2 -1
- package/lib/command/gherkin/snippets.js +6 -6
- package/lib/command/gherkin/steps.js +0 -1
- package/lib/command/info.js +40 -0
- package/lib/command/init.js +54 -41
- package/lib/command/run-multiple.js +5 -4
- package/lib/command/run-rerun.js +39 -0
- package/lib/command/run-workers.js +4 -6
- package/lib/command/run.js +8 -18
- package/lib/command/utils.js +23 -2
- package/lib/command/workers/runTests.js +1 -2
- package/lib/config.js +10 -4
- package/lib/container.js +31 -6
- package/lib/data/dataTableArgument.js +31 -0
- package/lib/data/table.js +4 -0
- package/lib/event.js +65 -1
- package/lib/helper/Appium.js +52 -38
- package/lib/helper/FileSystem.js +48 -3
- package/lib/helper/GraphQL.js +3 -2
- package/lib/helper/GraphQLDataFactory.js +1 -0
- package/lib/helper/Mochawesome.js +3 -2
- package/lib/helper/MockRequest.js +23 -5
- package/lib/helper/Nightmare.js +5 -6
- package/lib/helper/Protractor.js +7 -8
- package/lib/helper/Puppeteer.js +76 -20
- package/lib/helper/REST.js +13 -9
- package/lib/helper/SeleniumWebdriver.js +0 -17
- package/lib/helper/TestCafe.js +84 -36
- package/lib/helper/WebDriver.js +113 -59
- package/lib/helper/WebDriverIO.js +43 -59
- package/lib/helper/clientscripts/nightmare.js +66 -4
- package/lib/helper/scripts/isElementClickable.js +24 -0
- package/lib/helper.js +34 -10
- package/lib/history.js +1 -1
- package/lib/hooks.js +2 -1
- package/lib/index.js +19 -0
- package/lib/interfaces/bdd.js +4 -0
- package/lib/interfaces/featureConfig.js +10 -3
- package/lib/interfaces/gherkin.js +6 -2
- package/lib/interfaces/scenarioConfig.js +17 -6
- package/lib/listener/config.js +1 -1
- package/lib/listener/exit.js +6 -0
- package/lib/listener/steps.js +0 -1
- package/lib/listener/trace.js +0 -1
- package/lib/locator.js +67 -2
- package/lib/output.js +53 -0
- package/lib/parser.js +2 -71
- package/lib/pause.js +3 -2
- package/lib/plugin/allure.js +41 -22
- package/lib/plugin/autoLogin.js +4 -1
- package/lib/plugin/pauseOnFail.js +38 -0
- package/lib/plugin/puppeteerCoverage.js +8 -7
- package/lib/plugin/screenshotOnFail.js +13 -8
- package/lib/plugin/stepByStepReport.js +7 -6
- package/lib/plugin/wdio.js +2 -1
- package/lib/recorder.js +85 -7
- package/lib/rerun.js +81 -0
- package/lib/secret.js +6 -0
- package/lib/session.js +9 -2
- package/lib/step.js +37 -2
- package/lib/store.js +5 -1
- package/lib/ui.js +34 -8
- package/lib/utils.js +6 -13
- package/lib/within.js +5 -0
- package/package.json +49 -29
- package/typings/Mocha.d.ts +21 -0
- package/typings/Protractor.d.ts +16 -0
- package/typings/index.d.ts +169 -0
- package/typings/jsdoc.conf.js +34 -0
- package/typings/jsdoc.namespace.js +29 -0
- package/typings/types.d.ts +9827 -0
- package/typings/utils.d.ts +7 -0
- package/docs/acceptance.md +0 -409
- package/docs/api/codecept.md +0 -75
- package/docs/api/config.md +0 -49
- package/docs/api/container.md +0 -66
- package/docs/api/helper.md +0 -116
- package/docs/api/output.md +0 -67
- package/docs/api/recorder.md +0 -63
- package/docs/helpers/SeleniumWebdriver.md +0 -92
- package/docs/helpers/WebDriverIO.md +0 -1671
|
@@ -6,6 +6,6 @@ I.scrollTo('footer');
|
|
|
6
6
|
I.scrollTo('#submit', 5, 5);
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
@param {
|
|
10
|
-
@param {number} offsetX (optional, `0` by default) X-axis offset.
|
|
11
|
-
@param {number} offsetY (optional, `0` by default) Y-axis offset.
|
|
9
|
+
@param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
10
|
+
@param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
11
|
+
@param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
package/docs/webapi/see.mustache
CHANGED
|
@@ -7,4 +7,4 @@ I.see('Welcome', '.content'); // text inside .content div
|
|
|
7
7
|
I.see('Register', {css: 'form.register'}); // use strict locator
|
|
8
8
|
```
|
|
9
9
|
@param {string} text expected on page.
|
|
10
|
-
@param {
|
|
10
|
+
@param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
@@ -4,5 +4,5 @@ Checks that all elements with given locator have given attributes.
|
|
|
4
4
|
I.seeAttributesOnElements('//form', { method: "post"});
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
@param {
|
|
7
|
+
@param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
8
8
|
@param {object} attributes attributes and their values to check.
|
|
@@ -6,4 +6,4 @@ I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
|
|
|
6
6
|
I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
@param {
|
|
9
|
+
@param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
@@ -4,5 +4,5 @@ Checks that all elements with given locator have given CSS properties.
|
|
|
4
4
|
I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
@param {
|
|
7
|
+
@param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
8
8
|
@param {object} cssProperties object with CSS properties and their values to check.
|
|
@@ -7,5 +7,5 @@ I.seeInField({css: 'form textarea'},'Type your comment here');
|
|
|
7
7
|
I.seeInField('form input[type=hidden]','hidden_value');
|
|
8
8
|
I.seeInField('#searchform input','Search');
|
|
9
9
|
```
|
|
10
|
-
@param {
|
|
10
|
+
@param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
11
11
|
@param {string} value value to check.
|
|
@@ -6,5 +6,5 @@ Element is located by label or name or CSS or XPath.
|
|
|
6
6
|
I.seeNumberOfElements('#submitBtn', 1);
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
@param {
|
|
9
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
10
10
|
@param {number} num number of elements.
|
|
@@ -5,5 +5,5 @@ Element is located by CSS or XPath.
|
|
|
5
5
|
I.seeNumberOfVisibleElements('.buttons', 3);
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
8
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
9
9
|
@param {number} num number of elements.
|
|
@@ -16,5 +16,5 @@ Provide an array for the second argument to select multiple options.
|
|
|
16
16
|
```js
|
|
17
17
|
I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
18
18
|
```
|
|
19
|
-
@param {
|
|
20
|
-
@param {string|
|
|
19
|
+
@param {CodeceptJS.LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
|
|
20
|
+
@param {string|Array<*>} option visible text or value of option.
|
|
@@ -5,4 +5,4 @@ I.switchTo('iframe'); // switch to first iframe
|
|
|
5
5
|
I.switchTo(); // switch back to main page
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
8
|
+
@param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
@@ -8,5 +8,5 @@ I.uncheckOption('#agree');
|
|
|
8
8
|
I.uncheckOption('I Agree to Terms and Conditions');
|
|
9
9
|
I.uncheckOption('agree', '//form');
|
|
10
10
|
```
|
|
11
|
-
@param {
|
|
12
|
-
@param {
|
|
11
|
+
@param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
12
|
+
@param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Waits for element to be clickable (by default waits for 1sec).
|
|
2
|
+
Element can be located by CSS or XPath.
|
|
3
|
+
|
|
4
|
+
```js
|
|
5
|
+
I.waitForClickable('.btn.continue');
|
|
6
|
+
I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
10
|
+
@param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
@@ -5,5 +5,5 @@ Element can be located by CSS or XPath.
|
|
|
5
5
|
I.waitForDetached('#popup');
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
8
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -6,5 +6,5 @@ I.waitForElement('.btn.continue');
|
|
|
6
6
|
I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
@param {
|
|
10
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
9
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
10
|
+
@param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Waits for element to become enabled (by default waits for 1sec).
|
|
2
2
|
Element can be located by CSS or XPath.
|
|
3
3
|
|
|
4
|
-
@param {
|
|
5
|
-
@param sec (optional) time in seconds to wait, 1 by default.
|
|
4
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
5
|
+
@param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
@@ -12,5 +12,5 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
@param {string|function} fn to be executed in browser context.
|
|
15
|
-
@param {
|
|
16
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
15
|
+
@param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
|
|
16
|
+
@param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
@@ -5,5 +5,5 @@ Element can be located by CSS or XPath.
|
|
|
5
5
|
I.waitForInvisible('#popup');
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
8
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -8,5 +8,5 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');
|
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
@param {string }text to wait for.
|
|
11
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
12
|
-
@param {
|
|
11
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
12
|
+
@param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
@@ -6,4 +6,4 @@ I.waitForValue('//input', "GoodValue");
|
|
|
6
6
|
|
|
7
7
|
@param {string|object} field input field.
|
|
8
8
|
@param {string }value expected value.
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -5,5 +5,5 @@ Element can be located by CSS or XPath.
|
|
|
5
5
|
I.waitForVisible('#popup');
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
8
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -4,6 +4,6 @@ Waits for a specified number of elements on the page.
|
|
|
4
4
|
I.waitNumberOfVisibleElements('a', 3);
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
@param {
|
|
7
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
8
8
|
@param {number} num number of elements.
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -5,5 +5,5 @@ Element can be located by CSS or XPath.
|
|
|
5
5
|
I.waitToHide('#popup');
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
@param {
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
8
|
+
@param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
@@ -6,5 +6,6 @@ I.waitUntil(() => window.requests == 0, 5);
|
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
@param {function|string} fn function which is executed in browser context.
|
|
9
|
-
@param {number} sec (optional, `1` by default) time in seconds to wait
|
|
10
|
-
@param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
9
|
+
@param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
10
|
+
@param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
11
|
+
@param {?number} [interval=null]
|
package/docs/webdriver.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
permalink: /webdriver
|
|
3
3
|
title: Testing with WebDriver
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
# Testing with WebDriver
|
|
7
|
+
|
|
6
8
|
How does your client, manager, or tester, or any other non-technical person, know your web application is working? By opening the browser, accessing a site, clicking on links, filling in the forms, and actually seeing the content on a web page.
|
|
7
9
|
|
|
8
10
|
End to End tests can cover standard but complex scenarios from a user's perspective. With e2e tests you can be confident that users, following all defined scenarios, won't get errors. We check **functionality of application and a user interface** (UI) as well.
|
|
9
11
|
|
|
10
12
|
## What is Selenium WebDriver
|
|
11
13
|
|
|
12
|
-
The standard and proved way to run browser test automation over years is Selenium WebDriver. Over years this technology was standartized and works over all popular browsers and operating systems. There are cloud services like SauceLabs or BrowserStack which allow executing such browsers in the
|
|
14
|
+
The standard and proved way to run browser test automation over years is Selenium WebDriver. Over years this technology was standartized and works over all popular browsers and operating systems. There are cloud services like SauceLabs or BrowserStack which allow executing such browsers in the cloud. The superset of WebDriver protocol is also used to test [native and hybrid mobile applications](/mobile).
|
|
13
15
|
|
|
14
16
|
Let's clarify the terms:
|
|
15
17
|
|
|
@@ -19,9 +21,9 @@ Let's clarify the terms:
|
|
|
19
21
|
|
|
20
22
|
We use [webdriverio](https://webdriver.io) library to run tests over WebDriver.
|
|
21
23
|
|
|
22
|
-
> Popular tool [Protractor](
|
|
24
|
+
> Popular tool [Protractor](/angular) also uses WebDriver for running end 2 end tests.
|
|
23
25
|
|
|
24
|
-
To proceed you need to have [CodeceptJS installed](
|
|
26
|
+
To proceed you need to have [CodeceptJS installed](/quickstart#using-selenium-webdriver) and `WebDriver` helper selected.
|
|
25
27
|
|
|
26
28
|
Selenium WebDriver may be complicated from start, as it requires following tools to be installed and started.
|
|
27
29
|
|
|
@@ -79,7 +81,7 @@ Configuration for WebDriver should be provided inside `codecept.conf.js` file un
|
|
|
79
81
|
|
|
80
82
|
WebDriver protocol works over HTTP, so you need to have a Selenium Server to be running or other service that will launch a browser for you. That's why you may need to specify `host`, `port`, `protocol`, and `path` parameters.
|
|
81
83
|
|
|
82
|
-
By default, those parameters are set to connect to local Selenium Server but they should be changed if you want to run tests via [Cloud Services](
|
|
84
|
+
By default, those parameters are set to connect to local Selenium Server but they should be changed if you want to run tests via [Cloud Services](/helpers/WebDriver#cloud-providers). You may also need `user` and `key` parameters to authenticate on cloud service.
|
|
83
85
|
|
|
84
86
|
If you want to run tests using raw ChromeDriver (which also supports WebDriver protocol) avoiding Selenium Server, you should provide following configuration:
|
|
85
87
|
|
|
@@ -147,7 +149,7 @@ keepBrowserState: true,
|
|
|
147
149
|
keepCookies: true,
|
|
148
150
|
```
|
|
149
151
|
|
|
150
|
-
> ▶ More config options available on [WebDriver helper reference](
|
|
152
|
+
> ▶ More config options available on [WebDriver helper reference](/helpers/WebDriver#configuration)
|
|
151
153
|
|
|
152
154
|
## Writing Tests
|
|
153
155
|
|
|
@@ -168,7 +170,7 @@ Scenario('login test', (I) => {
|
|
|
168
170
|
I.see('Welcome, John');
|
|
169
171
|
});
|
|
170
172
|
```
|
|
171
|
-
> ▶ Actions like `amOnPage`, `click`, `fillField` are not limited to WebDriver only. They work similarly for all available helpers. [Go to Basics guide to learn them](
|
|
173
|
+
> ▶ Actions like `amOnPage`, `click`, `fillField` are not limited to WebDriver only. They work similarly for all available helpers. [Go to Basics guide to learn them](/basics#writing-tests).
|
|
172
174
|
|
|
173
175
|
|
|
174
176
|
An empty test case can be created with `codeceptjs gt` command.
|
|
@@ -177,7 +179,7 @@ An empty test case can be created with `codeceptjs gt` command.
|
|
|
177
179
|
npx codeceptjs gt
|
|
178
180
|
```
|
|
179
181
|
|
|
180
|
-
It's easy to start writing a test if you use [interactive pause](
|
|
182
|
+
It's easy to start writing a test if you use [interactive pause](/basics#debug). Just open a web page and pause execution.
|
|
181
183
|
|
|
182
184
|
```js
|
|
183
185
|
Feature('Sample Test');
|
|
@@ -198,7 +200,7 @@ npx codeceptjs run --steps
|
|
|
198
200
|
|
|
199
201
|
After a page is opened a full control of a browser is given to a terminal. Type in different commands such as `click`, `see`, `fillField` to write the test. A successful commands will be saved to `./output/cli-history` file and can be copied into a test.
|
|
200
202
|
|
|
201
|
-
> ℹ All actions are listed in [WebDriver helper reference](
|
|
203
|
+
> ℹ All actions are listed in [WebDriver helper reference](/helpers/WebDriver).
|
|
202
204
|
|
|
203
205
|
An interactive shell output may look like this:
|
|
204
206
|
|
|
@@ -301,7 +303,7 @@ Usage example:
|
|
|
301
303
|
I.click('#click-me');
|
|
302
304
|
```
|
|
303
305
|
|
|
304
|
-
If it's hard to define what to wait, it is recommended to use [retries](
|
|
306
|
+
If it's hard to define what to wait, it is recommended to use [retries](/basics/#retries) to rerun flaky steps.
|
|
305
307
|
|
|
306
308
|
## Configuring CI
|
|
307
309
|
|
|
@@ -310,8 +312,8 @@ To develop tests it's fine to use local Selenium Server and window mode. Setting
|
|
|
310
312
|
There are following options available:
|
|
311
313
|
|
|
312
314
|
* Use headless Chrome or Firefox.
|
|
313
|
-
* Use [Selenoid](
|
|
314
|
-
* Use paid [cloud services (SauceLabs, BrowserStack, TestingBot)](
|
|
315
|
+
* Use [Selenoid](/helpers/WebDriver#selenoid-options) to run browsers inside Docker containers.
|
|
316
|
+
* Use paid [cloud services (SauceLabs, BrowserStack, TestingBot)](/helpers/WebDriver#cloud-providers).
|
|
315
317
|
|
|
316
318
|
### Aerokube Cloud Browsers
|
|
317
319
|
|
|
@@ -360,7 +362,7 @@ npx codeceptjs run --plugins aerokube
|
|
|
360
362
|
|
|
361
363
|
## Auto Login
|
|
362
364
|
|
|
363
|
-
To share the same user session across different tests CodeceptJS provides [autoLogin plugin](
|
|
365
|
+
To share the same user session across different tests CodeceptJS provides [autoLogin plugin](/plugins#autologin). It simplifies login management and reduces time consuming login operations. Instead of filling in login form before each test it saves the cookies of a valid user session and reuses it for next tests. If a session expires or doesn't exist, logs in a user again.
|
|
364
366
|
|
|
365
367
|
This plugin requires some configuration but is very simple in use:
|
|
366
368
|
|
|
@@ -373,7 +375,7 @@ Scenario('do something with logged in user', (I, login)) => {
|
|
|
373
375
|
|
|
374
376
|
With `autoLogin` plugin you can save cookies into a file and reuse same session on different runs.
|
|
375
377
|
|
|
376
|
-
> [▶ How to set up autoLogin plugin](
|
|
378
|
+
> [▶ How to set up autoLogin plugin](/plugins#autologin)
|
|
377
379
|
|
|
378
380
|
|
|
379
381
|
## Multiple Windows
|
|
@@ -426,7 +428,7 @@ This is useful when you want to isolate application testing from a backend. For
|
|
|
426
428
|
|
|
427
429
|
> **WebDriver has limited ability to mock requests**, so you can only mock only requests performed after page is loaded. This means that you can't block Google Analytics, or CDN calls, but you can mock API requests performed on user action.
|
|
428
430
|
|
|
429
|
-
To mock requests enable additional helper [MockRequest](
|
|
431
|
+
To mock requests enable additional helper [MockRequest](/helpers/MockRequest) (which is based on Polly.js).
|
|
430
432
|
|
|
431
433
|
```js
|
|
432
434
|
helpers: {
|
|
@@ -461,7 +463,7 @@ I.click('Go to Next Page');
|
|
|
461
463
|
// in WebDriver as we can't detect that the page was reloaded, so no mocking :(
|
|
462
464
|
```
|
|
463
465
|
|
|
464
|
-
> See [`mockRequest` API](
|
|
466
|
+
> See [`mockRequest` API](/helpers/MockRequest#mockrequest)
|
|
465
467
|
|
|
466
468
|
To see `mockRequest` method in intellisense auto completion don't forget to run `codeceptjs def` command:
|
|
467
469
|
|
|
@@ -495,7 +497,7 @@ exports.config = {
|
|
|
495
497
|
}
|
|
496
498
|
```
|
|
497
499
|
|
|
498
|
-
> ℹ See [Custom Helper](
|
|
500
|
+
> ℹ See [Custom Helper](/helpers) guide to see more examples.
|
|
499
501
|
|
|
500
502
|
While implementing custom actions using WebDriver API please note that, there is two versions of protocol: WebDriver and JSON Wire. Depending on a browser version one of those protocols can be used. We can't know for sure which protocol is going to used, so we will need to implement an action using both APIs.
|
|
501
503
|
|
|
@@ -540,7 +542,7 @@ class Web extends Helper {
|
|
|
540
542
|
}
|
|
541
543
|
```
|
|
542
544
|
|
|
543
|
-
When a helper is created, regenerate your step definitions, so you could see those actions when using [intellisense](
|
|
545
|
+
When a helper is created, regenerate your step definitions, so you could see those actions when using [intellisense](/basics#intellisense):
|
|
544
546
|
|
|
545
547
|
```
|
|
546
548
|
npx codeceptjs def
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4753181844fc4dc563cf3aa5e80462243cb58d38 branch 'master' of github.com:Codeception/CodeceptJS.wiki
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ref: refs/heads/master
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c99f3e4bd227d6b050b2e416f9876df49583dbf6
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[core]
|
|
2
|
+
repositoryformatversion = 0
|
|
3
|
+
filemode = true
|
|
4
|
+
bare = false
|
|
5
|
+
logallrefupdates = true
|
|
6
|
+
[remote "origin"]
|
|
7
|
+
url = git@github.com:Codeception/CodeceptJS.wiki.git
|
|
8
|
+
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
9
|
+
[branch "master"]
|
|
10
|
+
remote = origin
|
|
11
|
+
merge = refs/heads/master
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Unnamed repository; edit this file 'description' to name the repository.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# An example hook script to check the commit log message taken by
|
|
4
|
+
# applypatch from an e-mail message.
|
|
5
|
+
#
|
|
6
|
+
# The hook should exit with non-zero status after issuing an
|
|
7
|
+
# appropriate message if it wants to stop the commit. The hook is
|
|
8
|
+
# allowed to edit the commit message file.
|
|
9
|
+
#
|
|
10
|
+
# To enable this hook, rename this file to "applypatch-msg".
|
|
11
|
+
|
|
12
|
+
. git-sh-setup
|
|
13
|
+
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
|
14
|
+
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
|
15
|
+
:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# An example hook script to check the commit log message.
|
|
4
|
+
# Called by "git commit" with one argument, the name of the file
|
|
5
|
+
# that has the commit message. The hook should exit with non-zero
|
|
6
|
+
# status after issuing an appropriate message if it wants to stop the
|
|
7
|
+
# commit. The hook is allowed to edit the commit message file.
|
|
8
|
+
#
|
|
9
|
+
# To enable this hook, rename this file to "commit-msg".
|
|
10
|
+
|
|
11
|
+
# Uncomment the below to add a Signed-off-by line to the message.
|
|
12
|
+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
|
13
|
+
# hook is more suited to it.
|
|
14
|
+
#
|
|
15
|
+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
|
16
|
+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
|
17
|
+
|
|
18
|
+
# This example catches duplicate Signed-off-by lines.
|
|
19
|
+
|
|
20
|
+
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
|
21
|
+
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
|
22
|
+
echo >&2 Duplicate Signed-off-by lines.
|
|
23
|
+
exit 1
|
|
24
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/perl
|
|
2
|
+
|
|
3
|
+
use strict;
|
|
4
|
+
use warnings;
|
|
5
|
+
use IPC::Open2;
|
|
6
|
+
|
|
7
|
+
# An example hook script to integrate Watchman
|
|
8
|
+
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
|
9
|
+
# new and modified files.
|
|
10
|
+
#
|
|
11
|
+
# The hook is passed a version (currently 1) and a time in nanoseconds
|
|
12
|
+
# formatted as a string and outputs to stdout all files that have been
|
|
13
|
+
# modified since the given time. Paths must be relative to the root of
|
|
14
|
+
# the working tree and separated by a single NUL.
|
|
15
|
+
#
|
|
16
|
+
# To enable this hook, rename this file to "query-watchman" and set
|
|
17
|
+
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
|
18
|
+
#
|
|
19
|
+
my ($version, $time) = @ARGV;
|
|
20
|
+
|
|
21
|
+
# Check the hook interface version
|
|
22
|
+
|
|
23
|
+
if ($version == 1) {
|
|
24
|
+
# convert nanoseconds to seconds
|
|
25
|
+
$time = int $time / 1000000000;
|
|
26
|
+
} else {
|
|
27
|
+
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
|
28
|
+
"Falling back to scanning...\n";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
my $git_work_tree;
|
|
32
|
+
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
|
33
|
+
$git_work_tree = Win32::GetCwd();
|
|
34
|
+
$git_work_tree =~ tr/\\/\//;
|
|
35
|
+
} else {
|
|
36
|
+
require Cwd;
|
|
37
|
+
$git_work_tree = Cwd::cwd();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
my $retry = 1;
|
|
41
|
+
|
|
42
|
+
launch_watchman();
|
|
43
|
+
|
|
44
|
+
sub launch_watchman {
|
|
45
|
+
|
|
46
|
+
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
|
47
|
+
or die "open2() failed: $!\n" .
|
|
48
|
+
"Falling back to scanning...\n";
|
|
49
|
+
|
|
50
|
+
# In the query expression below we're asking for names of files that
|
|
51
|
+
# changed since $time but were not transient (ie created after
|
|
52
|
+
# $time but no longer exist).
|
|
53
|
+
#
|
|
54
|
+
# To accomplish this, we're using the "since" generator to use the
|
|
55
|
+
# recency index to select candidate nodes and "fields" to limit the
|
|
56
|
+
# output to file names only. Then we're using the "expression" term to
|
|
57
|
+
# further constrain the results.
|
|
58
|
+
#
|
|
59
|
+
# The category of transient files that we want to ignore will have a
|
|
60
|
+
# creation clock (cclock) newer than $time_t value and will also not
|
|
61
|
+
# currently exist.
|
|
62
|
+
|
|
63
|
+
my $query = <<" END";
|
|
64
|
+
["query", "$git_work_tree", {
|
|
65
|
+
"since": $time,
|
|
66
|
+
"fields": ["name"],
|
|
67
|
+
"expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]]
|
|
68
|
+
}]
|
|
69
|
+
END
|
|
70
|
+
|
|
71
|
+
print CHLD_IN $query;
|
|
72
|
+
close CHLD_IN;
|
|
73
|
+
my $response = do {local $/; <CHLD_OUT>};
|
|
74
|
+
|
|
75
|
+
die "Watchman: command returned no output.\n" .
|
|
76
|
+
"Falling back to scanning...\n" if $response eq "";
|
|
77
|
+
die "Watchman: command returned invalid output: $response\n" .
|
|
78
|
+
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
|
79
|
+
|
|
80
|
+
my $json_pkg;
|
|
81
|
+
eval {
|
|
82
|
+
require JSON::XS;
|
|
83
|
+
$json_pkg = "JSON::XS";
|
|
84
|
+
1;
|
|
85
|
+
} or do {
|
|
86
|
+
require JSON::PP;
|
|
87
|
+
$json_pkg = "JSON::PP";
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
my $o = $json_pkg->new->utf8->decode($response);
|
|
91
|
+
|
|
92
|
+
if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
|
93
|
+
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
|
|
94
|
+
$retry--;
|
|
95
|
+
qx/watchman watch "$git_work_tree"/;
|
|
96
|
+
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
|
97
|
+
"Falling back to scanning...\n" if $? != 0;
|
|
98
|
+
|
|
99
|
+
# Watchman will always return all files on the first query so
|
|
100
|
+
# return the fast "everything is dirty" flag to git and do the
|
|
101
|
+
# Watchman query just to get it over with now so we won't pay
|
|
102
|
+
# the cost in git to look up each individual file.
|
|
103
|
+
print "/\0";
|
|
104
|
+
eval { launch_watchman() };
|
|
105
|
+
exit 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
die "Watchman: $o->{error}.\n" .
|
|
109
|
+
"Falling back to scanning...\n" if $o->{error};
|
|
110
|
+
|
|
111
|
+
binmode STDOUT, ":utf8";
|
|
112
|
+
local $, = "\0";
|
|
113
|
+
print @{$o->{files}};
|
|
114
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# An example hook script to verify what is about to be committed
|
|
4
|
+
# by applypatch from an e-mail message.
|
|
5
|
+
#
|
|
6
|
+
# The hook should exit with non-zero status after issuing an
|
|
7
|
+
# appropriate message if it wants to stop the commit.
|
|
8
|
+
#
|
|
9
|
+
# To enable this hook, rename this file to "pre-applypatch".
|
|
10
|
+
|
|
11
|
+
. git-sh-setup
|
|
12
|
+
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
|
13
|
+
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
|
14
|
+
:
|