codeceptjs 2.1.3 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -37
- package/README.md +15 -22
- package/bin/codecept.js +4 -1
- package/docs/acceptance.md +44 -1
- package/docs/advanced.md +1 -1
- package/docs/angular.md +6 -9
- package/docs/basics.md +388 -75
- package/docs/bdd.md +4 -3
- package/docs/best.md +1 -1
- package/docs/books.md +31 -0
- package/docs/build/Appium.js +215 -176
- package/docs/build/Nightmare.js +618 -489
- package/docs/build/Polly.js +189 -0
- package/docs/build/Protractor.js +747 -608
- package/docs/build/Puppeteer.js +914 -633
- package/docs/build/REST.js +1 -1
- package/docs/build/TestCafe.js +1835 -0
- package/docs/build/WebDriver.js +861 -805
- package/docs/build/WebDriverIO.js +616 -617
- package/docs/changelog.md +410 -316
- package/docs/commands.md +6 -6
- package/docs/community-helpers.md +2 -0
- package/docs/detox.md +235 -0
- package/docs/examples.md +23 -0
- package/docs/helpers/ApiDataFactory.md +11 -10
- package/docs/helpers/Appium.md +130 -61
- package/docs/helpers/Detox.md +579 -0
- package/docs/helpers/FileSystem.md +2 -1
- package/docs/helpers/Mochawesome.md +1 -0
- package/docs/helpers/Nightmare.md +348 -128
- package/docs/helpers/Polly.md +85 -0
- package/docs/helpers/Protractor.md +451 -184
- package/docs/helpers/Puppeteer-firefox.md +55 -0
- package/docs/helpers/Puppeteer.md +619 -183
- package/docs/helpers/REST.md +17 -16
- package/docs/helpers/SeleniumWebdriver.md +9 -8
- package/docs/helpers/TestCafe.md +1168 -0
- package/docs/helpers/WebDriver.md +600 -291
- package/docs/helpers/WebDriverIO.md +393 -278
- package/docs/helpers.md +37 -18
- package/docs/locators.md +2 -0
- package/docs/mobile-react-native-locators.md +64 -0
- package/docs/mobile.md +5 -0
- package/docs/plugins.md +54 -13
- package/docs/puppeteer.md +74 -26
- package/docs/quickstart.md +47 -12
- package/docs/react.md +67 -0
- package/docs/reports.md +1 -1
- package/docs/{webapi/_keys.mustache → shared/keys.mustache} +0 -0
- package/docs/shared/react.mustache +1 -0
- package/docs/testcafe.md +157 -0
- package/docs/videos.md +19 -0
- package/docs/webapi/amOnPage.mustache +1 -1
- package/docs/webapi/appendField.mustache +2 -2
- package/docs/webapi/attachFile.mustache +2 -2
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/clearField.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +3 -3
- package/docs/webapi/dontSee.mustache +6 -3
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +7 -1
- package/docs/webapi/dontSeeCookie.mustache +5 -1
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +6 -1
- package/docs/webapi/dontSeeElement.mustache +5 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +5 -1
- package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +7 -2
- package/docs/webapi/dontSeeInSource.mustache +5 -1
- package/docs/webapi/dontSeeInTitle.mustache +5 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +2 -2
- package/docs/webapi/dragAndDrop.mustache +2 -2
- package/docs/webapi/dragSlider.mustache +2 -2
- package/docs/webapi/executeAsyncScript.mustache +1 -1
- package/docs/webapi/executeScript.mustache +1 -1
- package/docs/webapi/fillField.mustache +2 -2
- package/docs/webapi/grabAttributeFrom.mustache +3 -2
- package/docs/webapi/grabBrowserLogs.mustache +3 -1
- package/docs/webapi/grabCookie.mustache +2 -1
- package/docs/webapi/grabCssPropertyFrom.mustache +3 -2
- package/docs/webapi/grabCurrentUrl.mustache +3 -1
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +19 -0
- package/docs/webapi/grabHTMLFrom.mustache +2 -1
- package/docs/webapi/grabNumberOfOpenTabs.mustache +4 -2
- package/docs/webapi/grabNumberOfVisibleElements.mustache +3 -2
- package/docs/webapi/grabPageScrollPosition.mustache +3 -1
- package/docs/webapi/grabSource.mustache +3 -1
- package/docs/webapi/grabTextFrom.mustache +2 -1
- package/docs/webapi/grabTitle.mustache +3 -1
- package/docs/webapi/grabValueFrom.mustache +2 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/resizeWindow.mustache +2 -2
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +3 -3
- package/docs/webapi/say.mustache +2 -2
- package/docs/webapi/scrollPageToBottom.mustache +1 -1
- package/docs/webapi/scrollPageToTop.mustache +1 -1
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +2 -2
- package/docs/webapi/seeAttributesOnElements.mustache +3 -3
- package/docs/webapi/seeCheckboxIsChecked.mustache +2 -1
- package/docs/webapi/seeCookie.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -2
- package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInCurrentUrl.mustache +1 -1
- package/docs/webapi/seeInField.mustache +2 -2
- package/docs/webapi/seeInSource.mustache +1 -1
- package/docs/webapi/seeInTitle.mustache +5 -1
- package/docs/webapi/seeNumberOfElements.mustache +10 -0
- package/docs/webapi/seeNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/setCookie.mustache +1 -1
- package/docs/webapi/switchTo.mustache +6 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/wait.mustache +1 -2
- package/docs/webapi/waitForDetached.mustache +3 -3
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +1 -1
- package/docs/webapi/waitForFunction.mustache +3 -3
- package/docs/webapi/waitForInvisible.mustache +3 -3
- package/docs/webapi/waitForText.mustache +3 -3
- package/docs/webapi/waitForValue.mustache +3 -3
- package/docs/webapi/waitForVisible.mustache +3 -3
- package/docs/webapi/waitInUrl.mustache +2 -2
- package/docs/webapi/waitNumberOfVisibleElements.mustache +3 -3
- package/docs/webapi/waitToHide.mustache +3 -3
- package/docs/webapi/waitUntil.mustache +3 -3
- package/docs/webapi/waitUrlEquals.mustache +2 -2
- package/docs/webdriver.md +453 -0
- package/lib/codecept.js +11 -9
- package/lib/command/definitions.js +183 -30
- package/lib/command/gherkin/snippets.js +29 -9
- package/lib/command/init.js +31 -9
- package/lib/command/run-multiple.js +46 -59
- package/lib/command/utils.js +1 -1
- package/lib/container.js +30 -4
- package/lib/data/dataScenarioConfig.js +18 -0
- package/lib/helper/Appium.js +24 -24
- package/lib/helper/Nightmare.js +81 -84
- package/lib/helper/Polly.js +189 -0
- package/lib/helper/Protractor.js +96 -86
- package/lib/helper/Puppeteer.js +238 -113
- package/lib/helper/REST.js +1 -1
- package/lib/helper/TestCafe.js +1257 -0
- package/lib/helper/WebDriver.js +217 -277
- package/lib/helper/WebDriverIO.js +75 -75
- package/lib/helper/clientscripts/nightmare.js +8 -0
- package/lib/helper/extras/React.js +55 -0
- package/lib/helper/testcafe/testControllerHolder.js +42 -0
- package/lib/helper/testcafe/testcafe-utils.js +63 -0
- package/lib/history.js +39 -0
- package/lib/hooks.js +25 -1
- package/lib/interfaces/gherkin.js +17 -1
- package/lib/interfaces/scenarioConfig.js +2 -2
- package/lib/listener/config.js +3 -3
- package/lib/locator.js +6 -0
- package/lib/pause.js +22 -1
- package/lib/plugin/allure.js +63 -0
- package/lib/plugin/autoLogin.js +65 -16
- package/lib/plugin/puppeteerCoverage.js +6 -1
- package/lib/plugin/stepByStepReport.js +4 -3
- package/lib/scenario.js +23 -17
- package/lib/step.js +5 -2
- package/lib/ui.js +1 -1
- package/lib/utils.js +70 -20
- package/package.json +20 -19
- package/translations/de-DE.js +69 -0
- package/translations/index.js +1 -0
- package/docs/video.md +0 -26
package/lib/helper/WebDriver.js
CHANGED
|
@@ -15,7 +15,6 @@ const {
|
|
|
15
15
|
chunkArray,
|
|
16
16
|
convertCssPropertiesToCamelCase,
|
|
17
17
|
screenshotOutputFolder,
|
|
18
|
-
fileToBase64Zip,
|
|
19
18
|
} = require('../utils');
|
|
20
19
|
const {
|
|
21
20
|
isColorProperty,
|
|
@@ -61,15 +60,15 @@ const webRoot = 'body';
|
|
|
61
60
|
*
|
|
62
61
|
* Example:
|
|
63
62
|
*
|
|
64
|
-
* ```
|
|
63
|
+
* ```js
|
|
65
64
|
* {
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
65
|
+
* helpers: {
|
|
66
|
+
* WebDriver : {
|
|
67
|
+
* smartWait: 5000,
|
|
68
|
+
* browser: "chrome",
|
|
69
|
+
* restart: false,
|
|
70
|
+
* windowSize: "maximize",
|
|
71
|
+
* timeouts: {
|
|
73
72
|
* "script": 60000,
|
|
74
73
|
* "page load": 10000
|
|
75
74
|
* }
|
|
@@ -83,15 +82,15 @@ const webRoot = 'body';
|
|
|
83
82
|
*
|
|
84
83
|
* ### Headless Chrome
|
|
85
84
|
*
|
|
86
|
-
* ```
|
|
85
|
+
* ```js
|
|
87
86
|
* {
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
87
|
+
* helpers: {
|
|
88
|
+
* WebDriver : {
|
|
89
|
+
* url: "http://localhost",
|
|
90
|
+
* browser: "chrome",
|
|
91
|
+
* desiredCapabilities: {
|
|
92
|
+
* chromeOptions: {
|
|
93
|
+
* args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
|
|
95
94
|
* }
|
|
96
95
|
* }
|
|
97
96
|
* }
|
|
@@ -103,14 +102,14 @@ const webRoot = 'body';
|
|
|
103
102
|
*
|
|
104
103
|
* Additional configuration params can be used from [IE options](https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/IE/Options.html)
|
|
105
104
|
*
|
|
106
|
-
* ```
|
|
105
|
+
* ```js
|
|
107
106
|
* {
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
107
|
+
* helpers: {
|
|
108
|
+
* WebDriver : {
|
|
109
|
+
* url: "http://localhost",
|
|
110
|
+
* browser: "internet explorer",
|
|
111
|
+
* desiredCapabilities: {
|
|
112
|
+
* ieOptions: {
|
|
114
113
|
* "ie.browserCommandLineSwitches": "-private",
|
|
115
114
|
* "ie.usePerProcessProxy": true,
|
|
116
115
|
* "ie.ensureCleanSession": true,
|
|
@@ -123,15 +122,18 @@ const webRoot = 'body';
|
|
|
123
122
|
*
|
|
124
123
|
* ### Selenoid Options
|
|
125
124
|
*
|
|
126
|
-
*
|
|
125
|
+
* [Selenoid](https://aerokube.com/selenoid/latest/) is a modern way to run Selenium inside Docker containers.
|
|
126
|
+
* Selenoid is easy to set up and provides more features than original Selenium Server. Use `selenoidOptions` to set Selenoid capabilities
|
|
127
|
+
*
|
|
128
|
+
* ```js
|
|
127
129
|
* {
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
130
|
+
* helpers: {
|
|
131
|
+
* WebDriver : {
|
|
132
|
+
* url: "http://localhost",
|
|
133
|
+
* browser: "chrome",
|
|
134
|
+
* desiredCapabilities: {
|
|
135
|
+
* selenoidOptions: {
|
|
136
|
+
* enableVNC: true,
|
|
135
137
|
* }
|
|
136
138
|
* }
|
|
137
139
|
* }
|
|
@@ -139,17 +141,17 @@ const webRoot = 'body';
|
|
|
139
141
|
* }
|
|
140
142
|
* ```
|
|
141
143
|
*
|
|
142
|
-
* ### Connect
|
|
144
|
+
* ### Connect Through proxy
|
|
143
145
|
*
|
|
144
146
|
* CodeceptJS also provides flexible options when you want to execute tests to Selenium servers through proxy. You will
|
|
145
147
|
* need to update the `helpers.WebDriver.capabilities.proxy` key.
|
|
146
148
|
*
|
|
147
149
|
* ```js
|
|
148
150
|
* {
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
151
|
+
* helpers: {
|
|
152
|
+
* WebDriver: {
|
|
153
|
+
* capabilities: {
|
|
154
|
+
* proxy: {
|
|
153
155
|
* "proxyType": "manual|pac",
|
|
154
156
|
* "proxyAutoconfigUrl": "URL TO PAC FILE",
|
|
155
157
|
* "httpProxy": "PROXY SERVER",
|
|
@@ -169,10 +171,10 @@ const webRoot = 'body';
|
|
|
169
171
|
*
|
|
170
172
|
* ```js
|
|
171
173
|
* {
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
174
|
+
* helpers: {
|
|
175
|
+
* WebDriver: {
|
|
176
|
+
* capabilities: {
|
|
177
|
+
* proxy: {
|
|
176
178
|
* "proxyType": "manual",
|
|
177
179
|
* "httpProxy": "http://corporate.proxy:8080",
|
|
178
180
|
* "socksUsername": "codeceptjs",
|
|
@@ -199,12 +201,12 @@ const webRoot = 'body';
|
|
|
199
201
|
*
|
|
200
202
|
* ```js
|
|
201
203
|
* {
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
204
|
+
* helpers:{
|
|
205
|
+
* WebDriver: {
|
|
206
|
+
* url: "YOUR_DESIRED_HOST",
|
|
207
|
+
* user: "YOUR_BROWSERSTACK_USER",
|
|
208
|
+
* key: "YOUR_BROWSERSTACK_KEY",
|
|
209
|
+
* capabilities: {
|
|
208
210
|
* "browserName": "chrome",
|
|
209
211
|
*
|
|
210
212
|
* // only set this if you're using BrowserStackLocal to test a local domain
|
|
@@ -318,8 +320,8 @@ const webRoot = 'body';
|
|
|
318
320
|
*
|
|
319
321
|
* ```js
|
|
320
322
|
* {
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
+
* helpers: {
|
|
324
|
+
* WebDriver: {
|
|
323
325
|
* "multiremote": {
|
|
324
326
|
* "MyChrome": {
|
|
325
327
|
* "desiredCapabilities": {
|
|
@@ -490,12 +492,8 @@ class WebDriver extends Helper {
|
|
|
490
492
|
await this.defineTimeout(this.options.timeouts);
|
|
491
493
|
}
|
|
492
494
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
} else if (this.isWeb && this.options.windowSize && this.options.windowSize.indexOf('x') > 0) {
|
|
496
|
-
const dimensions = this.options.windowSize.split('x');
|
|
497
|
-
await this.resizeWindow(dimensions[0], dimensions[1]);
|
|
498
|
-
}
|
|
495
|
+
await this._resizeWindowIfNeeded(this.browser, this.options.windowSize);
|
|
496
|
+
|
|
499
497
|
this.$$ = this.browser.$$.bind(this.browser);
|
|
500
498
|
return this.browser;
|
|
501
499
|
}
|
|
@@ -547,7 +545,15 @@ class WebDriver extends Helper {
|
|
|
547
545
|
// opts.disableScreenshots = true; // screenshots cant be saved as session will be already closed
|
|
548
546
|
opts = this._validateConfig(Object.assign(this.options, opts));
|
|
549
547
|
this.debugSection('New Browser', JSON.stringify(opts));
|
|
550
|
-
|
|
548
|
+
const browser = await webdriverio.remote(opts);
|
|
549
|
+
|
|
550
|
+
if (opts.timeouts && this.isWeb) {
|
|
551
|
+
await this._defineBrowserTimeout(browser, opts.timeouts);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
await this._resizeWindowIfNeeded(browser, opts.windowSize);
|
|
555
|
+
|
|
556
|
+
return browser;
|
|
551
557
|
},
|
|
552
558
|
stop: async (browser) => {
|
|
553
559
|
return browser.deleteSession();
|
|
@@ -673,8 +679,6 @@ class WebDriver extends Helper {
|
|
|
673
679
|
/**
|
|
674
680
|
* Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
|
|
675
681
|
*
|
|
676
|
-
*
|
|
677
|
-
* * *Appium*: supported only for web testing.
|
|
678
682
|
* Timeouts are expected to be passed as object:
|
|
679
683
|
*
|
|
680
684
|
* ```js
|
|
@@ -685,24 +689,25 @@ class WebDriver extends Helper {
|
|
|
685
689
|
* @param timeouts WebDriver timeouts object.
|
|
686
690
|
*/
|
|
687
691
|
defineTimeout(timeouts) {
|
|
688
|
-
return this.browser
|
|
692
|
+
return this._defineBrowserTimeout(this.browser, timeouts);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
_defineBrowserTimeout(browser, timeouts) {
|
|
696
|
+
return browser.setTimeout(timeouts);
|
|
689
697
|
}
|
|
690
698
|
|
|
691
699
|
/**
|
|
692
|
-
* {{>
|
|
700
|
+
* {{> amOnPage }}
|
|
693
701
|
*
|
|
694
|
-
*
|
|
695
|
-
* * *Appium*: supported only for web testing
|
|
696
702
|
*/
|
|
697
703
|
amOnPage(url) {
|
|
698
704
|
return this.browser.url(url);
|
|
699
705
|
}
|
|
700
706
|
|
|
701
707
|
/**
|
|
702
|
-
* {{>
|
|
703
|
-
*
|
|
708
|
+
* {{> click }}
|
|
704
709
|
*
|
|
705
|
-
*
|
|
710
|
+
* {{ react }}
|
|
706
711
|
*/
|
|
707
712
|
async click(locator, context = null) {
|
|
708
713
|
const clickMethod = this.browser.isMobile ? 'touchClick' : 'elementClick';
|
|
@@ -719,10 +724,9 @@ class WebDriver extends Helper {
|
|
|
719
724
|
}
|
|
720
725
|
|
|
721
726
|
/**
|
|
722
|
-
* {{>
|
|
727
|
+
* {{> doubleClick }}
|
|
723
728
|
*
|
|
724
|
-
*
|
|
725
|
-
* * *Appium*: supported only for web testing
|
|
729
|
+
* {{ react }}
|
|
726
730
|
*/
|
|
727
731
|
async doubleClick(locator, context = null) {
|
|
728
732
|
const locateFn = prepareLocateFn.call(this, context);
|
|
@@ -739,10 +743,9 @@ class WebDriver extends Helper {
|
|
|
739
743
|
}
|
|
740
744
|
|
|
741
745
|
/**
|
|
742
|
-
* {{>
|
|
743
|
-
*
|
|
746
|
+
* {{> rightClick }}
|
|
744
747
|
*
|
|
745
|
-
*
|
|
748
|
+
* {{ react }}
|
|
746
749
|
*/
|
|
747
750
|
async rightClick(locator, context) {
|
|
748
751
|
const locateFn = prepareLocateFn.call(this, context);
|
|
@@ -769,10 +772,9 @@ class WebDriver extends Helper {
|
|
|
769
772
|
}
|
|
770
773
|
|
|
771
774
|
/**
|
|
772
|
-
* {{>
|
|
775
|
+
* {{> fillField }}
|
|
776
|
+
* {{ react }}
|
|
773
777
|
*
|
|
774
|
-
*
|
|
775
|
-
* * *Appium*: supported
|
|
776
778
|
*/
|
|
777
779
|
async fillField(field, value) {
|
|
778
780
|
const res = await findFields.call(this, field);
|
|
@@ -782,10 +784,8 @@ class WebDriver extends Helper {
|
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
/**
|
|
785
|
-
* {{>
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* * *Appium*: supported, but it's clear a field before insert in apps
|
|
787
|
+
* {{> appendField }}
|
|
788
|
+
* {{ react }}
|
|
789
789
|
*/
|
|
790
790
|
async appendField(field, value) {
|
|
791
791
|
const res = await findFields.call(this, field);
|
|
@@ -796,10 +796,8 @@ class WebDriver extends Helper {
|
|
|
796
796
|
|
|
797
797
|
|
|
798
798
|
/**
|
|
799
|
-
* {{>
|
|
799
|
+
* {{> clearField }}
|
|
800
800
|
*
|
|
801
|
-
*
|
|
802
|
-
* * *Appium*: supported
|
|
803
801
|
*/
|
|
804
802
|
async clearField(field) {
|
|
805
803
|
const res = await findFields.call(this, field);
|
|
@@ -810,7 +808,7 @@ class WebDriver extends Helper {
|
|
|
810
808
|
|
|
811
809
|
|
|
812
810
|
/**
|
|
813
|
-
* {{>
|
|
811
|
+
* {{> selectOption }}
|
|
814
812
|
*/
|
|
815
813
|
async selectOption(select, option) {
|
|
816
814
|
const res = await findFields.call(this, select);
|
|
@@ -842,7 +840,7 @@ class WebDriver extends Helper {
|
|
|
842
840
|
}
|
|
843
841
|
|
|
844
842
|
/**
|
|
845
|
-
* {{>
|
|
843
|
+
* {{> attachFile }}
|
|
846
844
|
* Appium: not tested
|
|
847
845
|
*/
|
|
848
846
|
async attachFile(locator, pathToFile) {
|
|
@@ -856,12 +854,11 @@ class WebDriver extends Helper {
|
|
|
856
854
|
assertElementExists(res, locator, 'File field');
|
|
857
855
|
const el = usingFirstElement(res);
|
|
858
856
|
|
|
859
|
-
// Remote
|
|
857
|
+
// Remote Upload (when running Selenium Server)
|
|
860
858
|
if (this.options.remoteFileUpload) {
|
|
861
|
-
const fileCompressed = await fileToBase64Zip(file);
|
|
862
859
|
try {
|
|
863
860
|
this.debugSection('File', 'Uploading file to remote server');
|
|
864
|
-
file = await this.browser.uploadFile(
|
|
861
|
+
file = await this.browser.uploadFile(file);
|
|
865
862
|
} catch (err) {
|
|
866
863
|
throw new Error(`File can't be transferred to remote server. Set \`remoteFileUpload: false\` in config to upload file locally.\n${err.message}`);
|
|
867
864
|
}
|
|
@@ -871,7 +868,7 @@ class WebDriver extends Helper {
|
|
|
871
868
|
}
|
|
872
869
|
|
|
873
870
|
/**
|
|
874
|
-
* {{>
|
|
871
|
+
* {{> checkOption }}
|
|
875
872
|
* Appium: not tested
|
|
876
873
|
*/
|
|
877
874
|
async checkOption(field, context = null) {
|
|
@@ -885,12 +882,12 @@ class WebDriver extends Helper {
|
|
|
885
882
|
const elementId = getElementId(elem);
|
|
886
883
|
|
|
887
884
|
const isSelected = await this.browser.isElementSelected(elementId);
|
|
888
|
-
if (isSelected
|
|
885
|
+
if (isSelected) return Promise.resolve(true);
|
|
889
886
|
return this.browser[clickMethod](elementId);
|
|
890
887
|
}
|
|
891
888
|
|
|
892
889
|
/**
|
|
893
|
-
* {{>
|
|
890
|
+
* {{> uncheckOption }}
|
|
894
891
|
* Appium: not tested
|
|
895
892
|
*/
|
|
896
893
|
async uncheckOption(field, context = null) {
|
|
@@ -904,15 +901,13 @@ class WebDriver extends Helper {
|
|
|
904
901
|
const elementId = getElementId(elem);
|
|
905
902
|
|
|
906
903
|
const isSelected = await this.browser.isElementSelected(elementId);
|
|
907
|
-
if (!isSelected
|
|
904
|
+
if (!isSelected) return Promise.resolve(true);
|
|
908
905
|
return this.browser[clickMethod](elementId);
|
|
909
906
|
}
|
|
910
907
|
|
|
911
908
|
/**
|
|
912
|
-
* {{>
|
|
913
|
-
*
|
|
909
|
+
* {{> grabTextFrom }}
|
|
914
910
|
*
|
|
915
|
-
* * *Appium*: supported
|
|
916
911
|
*/
|
|
917
912
|
async grabTextFrom(locator) {
|
|
918
913
|
const res = await this._locate(locator, true);
|
|
@@ -928,10 +923,8 @@ class WebDriver extends Helper {
|
|
|
928
923
|
}
|
|
929
924
|
|
|
930
925
|
/**
|
|
931
|
-
* {{>
|
|
926
|
+
* {{> grabHTMLFrom }}
|
|
932
927
|
*
|
|
933
|
-
*
|
|
934
|
-
* * *Appium*: supported only for web testing
|
|
935
928
|
*/
|
|
936
929
|
async grabHTMLFrom(locator) {
|
|
937
930
|
const elems = await this._locate(locator, true);
|
|
@@ -945,10 +938,8 @@ class WebDriver extends Helper {
|
|
|
945
938
|
}
|
|
946
939
|
|
|
947
940
|
/**
|
|
948
|
-
* {{>
|
|
949
|
-
*
|
|
941
|
+
* {{> grabValueFrom }}
|
|
950
942
|
*
|
|
951
|
-
* * *Appium*: supported only for web testing
|
|
952
943
|
*/
|
|
953
944
|
async grabValueFrom(locator) {
|
|
954
945
|
const res = await this._locate(locator, true);
|
|
@@ -958,7 +949,7 @@ class WebDriver extends Helper {
|
|
|
958
949
|
}
|
|
959
950
|
|
|
960
951
|
/**
|
|
961
|
-
* {{>
|
|
952
|
+
* {{> grabCssPropertyFrom }}
|
|
962
953
|
*/
|
|
963
954
|
async grabCssPropertyFrom(locator, cssProperty) {
|
|
964
955
|
const res = await this._locate(locator, true);
|
|
@@ -967,7 +958,7 @@ class WebDriver extends Helper {
|
|
|
967
958
|
}
|
|
968
959
|
|
|
969
960
|
/**
|
|
970
|
-
* {{>
|
|
961
|
+
* {{> grabAttributeFrom }}
|
|
971
962
|
* Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
|
|
972
963
|
*/
|
|
973
964
|
async grabAttributeFrom(locator, attr) {
|
|
@@ -977,10 +968,8 @@ class WebDriver extends Helper {
|
|
|
977
968
|
}
|
|
978
969
|
|
|
979
970
|
/**
|
|
980
|
-
* {{>
|
|
971
|
+
* {{> seeInTitle }}
|
|
981
972
|
*
|
|
982
|
-
*
|
|
983
|
-
* * *Appium*: supported only for web testing
|
|
984
973
|
*/
|
|
985
974
|
async seeInTitle(text) {
|
|
986
975
|
const title = await this.browser.getTitle();
|
|
@@ -1002,10 +991,8 @@ class WebDriver extends Helper {
|
|
|
1002
991
|
}
|
|
1003
992
|
|
|
1004
993
|
/**
|
|
1005
|
-
* {{>
|
|
1006
|
-
*
|
|
994
|
+
* {{> dontSeeInTitle }}
|
|
1007
995
|
*
|
|
1008
|
-
* * *Appium*: supported only for web testing
|
|
1009
996
|
*/
|
|
1010
997
|
async dontSeeInTitle(text) {
|
|
1011
998
|
const title = await this.browser.getTitle();
|
|
@@ -1013,10 +1000,8 @@ class WebDriver extends Helper {
|
|
|
1013
1000
|
}
|
|
1014
1001
|
|
|
1015
1002
|
/**
|
|
1016
|
-
* {{>
|
|
1017
|
-
*
|
|
1003
|
+
* {{> grabTitle }}
|
|
1018
1004
|
*
|
|
1019
|
-
* * *Appium*: supported only for web testing
|
|
1020
1005
|
*/
|
|
1021
1006
|
async grabTitle() {
|
|
1022
1007
|
const title = await this.browser.getTitle();
|
|
@@ -1025,10 +1010,9 @@ class WebDriver extends Helper {
|
|
|
1025
1010
|
}
|
|
1026
1011
|
|
|
1027
1012
|
/**
|
|
1028
|
-
* {{>
|
|
1013
|
+
* {{> see }}
|
|
1029
1014
|
*
|
|
1030
|
-
*
|
|
1031
|
-
* * *Appium*: supported with context in apps
|
|
1015
|
+
* {{ react }}
|
|
1032
1016
|
*/
|
|
1033
1017
|
async see(text, context = null) {
|
|
1034
1018
|
return proceedSee.call(this, 'assert', text, context);
|
|
@@ -1049,37 +1033,32 @@ class WebDriver extends Helper {
|
|
|
1049
1033
|
}
|
|
1050
1034
|
|
|
1051
1035
|
/**
|
|
1052
|
-
* {{>
|
|
1053
|
-
*
|
|
1036
|
+
* {{> dontSee }}
|
|
1054
1037
|
*
|
|
1055
|
-
*
|
|
1038
|
+
* {{ react }}
|
|
1056
1039
|
*/
|
|
1057
1040
|
async dontSee(text, context = null) {
|
|
1058
1041
|
return proceedSee.call(this, 'negate', text, context);
|
|
1059
1042
|
}
|
|
1060
1043
|
|
|
1061
1044
|
/**
|
|
1062
|
-
* {{>
|
|
1045
|
+
* {{> seeInField }}
|
|
1063
1046
|
*
|
|
1064
|
-
*
|
|
1065
|
-
* * *Appium*: supported only for web testing
|
|
1066
1047
|
*/
|
|
1067
1048
|
async seeInField(field, value) {
|
|
1068
1049
|
return proceedSeeField.call(this, 'assert', field, value);
|
|
1069
1050
|
}
|
|
1070
1051
|
|
|
1071
1052
|
/**
|
|
1072
|
-
* {{>
|
|
1073
|
-
*
|
|
1053
|
+
* {{> dontSeeInField }}
|
|
1074
1054
|
*
|
|
1075
|
-
* * *Appium*: supported only for web testing
|
|
1076
1055
|
*/
|
|
1077
1056
|
async dontSeeInField(field, value) {
|
|
1078
1057
|
return proceedSeeField.call(this, 'negate', field, value);
|
|
1079
1058
|
}
|
|
1080
1059
|
|
|
1081
1060
|
/**
|
|
1082
|
-
* {{>
|
|
1061
|
+
* {{> seeCheckboxIsChecked }}
|
|
1083
1062
|
* Appium: not tested
|
|
1084
1063
|
*/
|
|
1085
1064
|
async seeCheckboxIsChecked(field) {
|
|
@@ -1087,7 +1066,7 @@ class WebDriver extends Helper {
|
|
|
1087
1066
|
}
|
|
1088
1067
|
|
|
1089
1068
|
/**
|
|
1090
|
-
* {{>
|
|
1069
|
+
* {{> dontSeeCheckboxIsChecked }}
|
|
1091
1070
|
* Appium: not tested
|
|
1092
1071
|
*/
|
|
1093
1072
|
async dontSeeCheckboxIsChecked(field) {
|
|
@@ -1095,10 +1074,9 @@ class WebDriver extends Helper {
|
|
|
1095
1074
|
}
|
|
1096
1075
|
|
|
1097
1076
|
/**
|
|
1098
|
-
* {{>
|
|
1077
|
+
* {{> seeElement }}
|
|
1078
|
+
* {{ react }}
|
|
1099
1079
|
*
|
|
1100
|
-
*
|
|
1101
|
-
* * *Appium*: supported
|
|
1102
1080
|
*/
|
|
1103
1081
|
async seeElement(locator) {
|
|
1104
1082
|
const res = await this._locate(locator, true);
|
|
@@ -1108,10 +1086,8 @@ class WebDriver extends Helper {
|
|
|
1108
1086
|
}
|
|
1109
1087
|
|
|
1110
1088
|
/**
|
|
1111
|
-
* {{>
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
* * *Appium*: supported
|
|
1089
|
+
* {{> dontSeeElement }}
|
|
1090
|
+
* {{ react }}
|
|
1115
1091
|
*/
|
|
1116
1092
|
async dontSeeElement(locator) {
|
|
1117
1093
|
const res = await this._locate(locator, false);
|
|
@@ -1123,10 +1099,8 @@ class WebDriver extends Helper {
|
|
|
1123
1099
|
}
|
|
1124
1100
|
|
|
1125
1101
|
/**
|
|
1126
|
-
* {{>
|
|
1102
|
+
* {{> seeElementInDOM }}
|
|
1127
1103
|
*
|
|
1128
|
-
*
|
|
1129
|
-
* * *Appium*: supported
|
|
1130
1104
|
*/
|
|
1131
1105
|
async seeElementInDOM(locator) {
|
|
1132
1106
|
const res = await this.$$(withStrictLocator(locator));
|
|
@@ -1134,10 +1108,8 @@ class WebDriver extends Helper {
|
|
|
1134
1108
|
}
|
|
1135
1109
|
|
|
1136
1110
|
/**
|
|
1137
|
-
* {{>
|
|
1138
|
-
*
|
|
1111
|
+
* {{> dontSeeElementInDOM }}
|
|
1139
1112
|
*
|
|
1140
|
-
* * *Appium*: supported
|
|
1141
1113
|
*/
|
|
1142
1114
|
async dontSeeElementInDOM(locator) {
|
|
1143
1115
|
const res = await this.$$(withStrictLocator(locator));
|
|
@@ -1145,10 +1117,8 @@ class WebDriver extends Helper {
|
|
|
1145
1117
|
}
|
|
1146
1118
|
|
|
1147
1119
|
/**
|
|
1148
|
-
* {{>
|
|
1120
|
+
* {{> seeInSource }}
|
|
1149
1121
|
*
|
|
1150
|
-
*
|
|
1151
|
-
* * *Appium*: supported
|
|
1152
1122
|
*/
|
|
1153
1123
|
async seeInSource(text) {
|
|
1154
1124
|
const source = await this.browser.getPageSource();
|
|
@@ -1156,10 +1126,8 @@ class WebDriver extends Helper {
|
|
|
1156
1126
|
}
|
|
1157
1127
|
|
|
1158
1128
|
/**
|
|
1159
|
-
* {{>
|
|
1160
|
-
*
|
|
1129
|
+
* {{> grabSource }}
|
|
1161
1130
|
*
|
|
1162
|
-
* * *Appium*: supported
|
|
1163
1131
|
*/
|
|
1164
1132
|
async grabSource() {
|
|
1165
1133
|
return this.browser.getPageSource();
|
|
@@ -1182,7 +1150,7 @@ class WebDriver extends Helper {
|
|
|
1182
1150
|
}
|
|
1183
1151
|
|
|
1184
1152
|
/**
|
|
1185
|
-
* {{>
|
|
1153
|
+
* {{> grabCurrentUrl }}
|
|
1186
1154
|
*/
|
|
1187
1155
|
async grabCurrentUrl() {
|
|
1188
1156
|
const res = await this.browser.getUrl();
|
|
@@ -1191,10 +1159,7 @@ class WebDriver extends Helper {
|
|
|
1191
1159
|
}
|
|
1192
1160
|
|
|
1193
1161
|
/**
|
|
1194
|
-
* {{>
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
* * *Appium*: supported
|
|
1162
|
+
* {{> dontSeeInSource }}
|
|
1198
1163
|
*/
|
|
1199
1164
|
async dontSeeInSource(text) {
|
|
1200
1165
|
const source = await this.browser.getPageSource();
|
|
@@ -1202,18 +1167,8 @@ class WebDriver extends Helper {
|
|
|
1202
1167
|
}
|
|
1203
1168
|
|
|
1204
1169
|
/**
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* * *Appium*: supported
|
|
1210
|
-
*
|
|
1211
|
-
* ```js
|
|
1212
|
-
* I.seeNumberOfElements('#submitBtn', 1);
|
|
1213
|
-
* ```
|
|
1214
|
-
*
|
|
1215
|
-
* @param locator element located by CSS|XPath|strict locator.
|
|
1216
|
-
* @param num number of elements.
|
|
1170
|
+
* {{> seeNumberOfElements }}
|
|
1171
|
+
* {{ react }}
|
|
1217
1172
|
*/
|
|
1218
1173
|
async seeNumberOfElements(locator, num) {
|
|
1219
1174
|
const res = await this._locate(locator);
|
|
@@ -1221,7 +1176,8 @@ class WebDriver extends Helper {
|
|
|
1221
1176
|
}
|
|
1222
1177
|
|
|
1223
1178
|
/**
|
|
1224
|
-
* {{>
|
|
1179
|
+
* {{> seeNumberOfVisibleElements }}
|
|
1180
|
+
* {{ react }}
|
|
1225
1181
|
*/
|
|
1226
1182
|
async seeNumberOfVisibleElements(locator, num) {
|
|
1227
1183
|
const res = await this.grabNumberOfVisibleElements(locator);
|
|
@@ -1229,7 +1185,7 @@ class WebDriver extends Helper {
|
|
|
1229
1185
|
}
|
|
1230
1186
|
|
|
1231
1187
|
/**
|
|
1232
|
-
* {{>
|
|
1188
|
+
* {{> seeCssPropertiesOnElements }}
|
|
1233
1189
|
*/
|
|
1234
1190
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
1235
1191
|
const res = await this._locate(locator);
|
|
@@ -1264,7 +1220,7 @@ class WebDriver extends Helper {
|
|
|
1264
1220
|
}
|
|
1265
1221
|
|
|
1266
1222
|
/**
|
|
1267
|
-
* {{>
|
|
1223
|
+
* {{> seeAttributesOnElements }}
|
|
1268
1224
|
*/
|
|
1269
1225
|
async seeAttributesOnElements(locator, attributes) {
|
|
1270
1226
|
const res = await this._locate(locator);
|
|
@@ -1291,7 +1247,7 @@ class WebDriver extends Helper {
|
|
|
1291
1247
|
}
|
|
1292
1248
|
|
|
1293
1249
|
/**
|
|
1294
|
-
* {{>
|
|
1250
|
+
* {{> grabNumberOfVisibleElements }}
|
|
1295
1251
|
*/
|
|
1296
1252
|
async grabNumberOfVisibleElements(locator) {
|
|
1297
1253
|
const res = await this._locate(locator);
|
|
@@ -1303,10 +1259,8 @@ class WebDriver extends Helper {
|
|
|
1303
1259
|
}
|
|
1304
1260
|
|
|
1305
1261
|
/**
|
|
1306
|
-
* {{>
|
|
1307
|
-
*
|
|
1262
|
+
* {{> seeInCurrentUrl }}
|
|
1308
1263
|
*
|
|
1309
|
-
* * *Appium*: supported only for web testing
|
|
1310
1264
|
*/
|
|
1311
1265
|
async seeInCurrentUrl(url) {
|
|
1312
1266
|
const res = await this.browser.getUrl();
|
|
@@ -1314,10 +1268,8 @@ class WebDriver extends Helper {
|
|
|
1314
1268
|
}
|
|
1315
1269
|
|
|
1316
1270
|
/**
|
|
1317
|
-
* {{>
|
|
1271
|
+
* {{> dontSeeInCurrentUrl }}
|
|
1318
1272
|
*
|
|
1319
|
-
*
|
|
1320
|
-
* * *Appium*: supported only for web testing
|
|
1321
1273
|
*/
|
|
1322
1274
|
async dontSeeInCurrentUrl(url) {
|
|
1323
1275
|
const res = await this.browser.getUrl();
|
|
@@ -1325,10 +1277,8 @@ class WebDriver extends Helper {
|
|
|
1325
1277
|
}
|
|
1326
1278
|
|
|
1327
1279
|
/**
|
|
1328
|
-
* {{>
|
|
1329
|
-
*
|
|
1280
|
+
* {{> seeCurrentUrlEquals }}
|
|
1330
1281
|
*
|
|
1331
|
-
* * *Appium*: supported only for web testing
|
|
1332
1282
|
*/
|
|
1333
1283
|
async seeCurrentUrlEquals(url) {
|
|
1334
1284
|
const res = await this.browser.getUrl();
|
|
@@ -1336,10 +1286,8 @@ class WebDriver extends Helper {
|
|
|
1336
1286
|
}
|
|
1337
1287
|
|
|
1338
1288
|
/**
|
|
1339
|
-
* {{>
|
|
1289
|
+
* {{> dontSeeCurrentUrlEquals }}
|
|
1340
1290
|
*
|
|
1341
|
-
*
|
|
1342
|
-
* * *Appium*: supported only for web testing
|
|
1343
1291
|
*/
|
|
1344
1292
|
async dontSeeCurrentUrlEquals(url) {
|
|
1345
1293
|
const res = await this.browser.getUrl();
|
|
@@ -1347,10 +1295,8 @@ class WebDriver extends Helper {
|
|
|
1347
1295
|
}
|
|
1348
1296
|
|
|
1349
1297
|
/**
|
|
1350
|
-
* {{>
|
|
1351
|
-
*
|
|
1298
|
+
* {{> executeScript }}
|
|
1352
1299
|
*
|
|
1353
|
-
* * *Appium*: supported only for web testing
|
|
1354
1300
|
*
|
|
1355
1301
|
* Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
|
|
1356
1302
|
*/
|
|
@@ -1359,34 +1305,16 @@ class WebDriver extends Helper {
|
|
|
1359
1305
|
}
|
|
1360
1306
|
|
|
1361
1307
|
/**
|
|
1362
|
-
* {{>
|
|
1308
|
+
* {{> executeAsyncScript }}
|
|
1363
1309
|
*
|
|
1364
|
-
*
|
|
1365
|
-
* * *Appium*: supported only for web testing
|
|
1366
1310
|
*/
|
|
1367
1311
|
executeAsyncScript(fn) {
|
|
1368
1312
|
return this.browser.executeAsync.apply(this.browser, arguments);
|
|
1369
1313
|
}
|
|
1370
1314
|
|
|
1371
1315
|
/**
|
|
1372
|
-
*
|
|
1373
|
-
* Extra shift can be set with offsetX and offsetY options.
|
|
1316
|
+
* {{> scrollTo }}
|
|
1374
1317
|
*
|
|
1375
|
-
* ```js
|
|
1376
|
-
* I.scrollTo('footer');
|
|
1377
|
-
* I.scrollTo('#submit', 5, 5);
|
|
1378
|
-
* ```
|
|
1379
|
-
*
|
|
1380
|
-
* @param locator located by CSS|XPath|strict locator.
|
|
1381
|
-
* @param offsetX (optional) X-axis offset.
|
|
1382
|
-
* @param offsetY (optional) Y-axis offset.
|
|
1383
|
-
*/
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* {{> ../webapi/scrollTo }}
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
* * *Appium*: supported only for web testing
|
|
1390
1318
|
*/
|
|
1391
1319
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
1392
1320
|
if (typeof locator === 'number' && typeof offsetX === 'number') {
|
|
@@ -1416,10 +1344,8 @@ class WebDriver extends Helper {
|
|
|
1416
1344
|
}
|
|
1417
1345
|
|
|
1418
1346
|
/**
|
|
1419
|
-
* {{>
|
|
1420
|
-
*
|
|
1347
|
+
* {{> moveCursorTo }}
|
|
1421
1348
|
*
|
|
1422
|
-
* * *Appium*: supported only for web testing
|
|
1423
1349
|
*/
|
|
1424
1350
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
1425
1351
|
const res = await this._locate(withStrictLocator(locator), true);
|
|
@@ -1429,10 +1355,8 @@ class WebDriver extends Helper {
|
|
|
1429
1355
|
}
|
|
1430
1356
|
|
|
1431
1357
|
/**
|
|
1432
|
-
* {{>
|
|
1358
|
+
* {{> saveScreenshot }}
|
|
1433
1359
|
*
|
|
1434
|
-
*
|
|
1435
|
-
* * *Appium*: supported
|
|
1436
1360
|
*/
|
|
1437
1361
|
async saveScreenshot(fileName, fullPage = false) {
|
|
1438
1362
|
const outputFile = screenshotOutputFolder(fileName);
|
|
@@ -1464,10 +1388,8 @@ class WebDriver extends Helper {
|
|
|
1464
1388
|
|
|
1465
1389
|
|
|
1466
1390
|
/**
|
|
1467
|
-
* {{>
|
|
1468
|
-
*
|
|
1391
|
+
* {{> setCookie }}
|
|
1469
1392
|
*
|
|
1470
|
-
* * *Appium*: supported only for web testing
|
|
1471
1393
|
*
|
|
1472
1394
|
* Uses Selenium's JSON [cookie
|
|
1473
1395
|
* format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
|
|
@@ -1477,20 +1399,16 @@ class WebDriver extends Helper {
|
|
|
1477
1399
|
}
|
|
1478
1400
|
|
|
1479
1401
|
/**
|
|
1480
|
-
* {{>
|
|
1402
|
+
* {{> clearCookie }}
|
|
1481
1403
|
*
|
|
1482
|
-
*
|
|
1483
|
-
* * *Appium*: supported only for web testing
|
|
1484
1404
|
*/
|
|
1485
1405
|
async clearCookie(cookie) {
|
|
1486
1406
|
return this.browser.deleteCookies(cookie);
|
|
1487
1407
|
}
|
|
1488
1408
|
|
|
1489
1409
|
/**
|
|
1490
|
-
* {{>
|
|
1491
|
-
*
|
|
1410
|
+
* {{> seeCookie }}
|
|
1492
1411
|
*
|
|
1493
|
-
* * *Appium*: supported only for web testing
|
|
1494
1412
|
*/
|
|
1495
1413
|
async seeCookie(name) {
|
|
1496
1414
|
const cookie = await this.browser.getCookies([name]);
|
|
@@ -1498,10 +1416,8 @@ class WebDriver extends Helper {
|
|
|
1498
1416
|
}
|
|
1499
1417
|
|
|
1500
1418
|
/**
|
|
1501
|
-
* {{>
|
|
1419
|
+
* {{> dontSeeCookie }}
|
|
1502
1420
|
*
|
|
1503
|
-
*
|
|
1504
|
-
* * *Appium*: supported only for web testing
|
|
1505
1421
|
*/
|
|
1506
1422
|
async dontSeeCookie(name) {
|
|
1507
1423
|
const cookie = await this.browser.getCookies([name]);
|
|
@@ -1509,10 +1425,8 @@ class WebDriver extends Helper {
|
|
|
1509
1425
|
}
|
|
1510
1426
|
|
|
1511
1427
|
/**
|
|
1512
|
-
* {{>
|
|
1513
|
-
*
|
|
1428
|
+
* {{> grabCookie }}
|
|
1514
1429
|
*
|
|
1515
|
-
* * *Appium*: supported only for web testing
|
|
1516
1430
|
*/
|
|
1517
1431
|
async grabCookie(name) {
|
|
1518
1432
|
if (!name) return this.browser.getCookies();
|
|
@@ -1525,8 +1439,6 @@ class WebDriver extends Helper {
|
|
|
1525
1439
|
* Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
|
|
1526
1440
|
* Don't confuse popups with modal windows, as created by [various
|
|
1527
1441
|
* libraries](http://jster.net/category/windows-modals-popups).
|
|
1528
|
-
*
|
|
1529
|
-
* * *Appium*: supported only for web testing
|
|
1530
1442
|
*/
|
|
1531
1443
|
async acceptPopup() {
|
|
1532
1444
|
return this.browser.getAlertText().then((res) => {
|
|
@@ -1539,8 +1451,6 @@ class WebDriver extends Helper {
|
|
|
1539
1451
|
/**
|
|
1540
1452
|
* Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
|
|
1541
1453
|
*
|
|
1542
|
-
*
|
|
1543
|
-
* * *Appium*: supported only for web testing
|
|
1544
1454
|
*/
|
|
1545
1455
|
async cancelPopup() {
|
|
1546
1456
|
return this.browser.getAlertText().then((res) => {
|
|
@@ -1554,8 +1464,6 @@ class WebDriver extends Helper {
|
|
|
1554
1464
|
* Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
|
|
1555
1465
|
* given string.
|
|
1556
1466
|
*
|
|
1557
|
-
* * *Appium*: supported only for web testing
|
|
1558
|
-
*
|
|
1559
1467
|
* @param text value to check.
|
|
1560
1468
|
*/
|
|
1561
1469
|
async seeInPopup(text) {
|
|
@@ -1583,14 +1491,12 @@ class WebDriver extends Helper {
|
|
|
1583
1491
|
}
|
|
1584
1492
|
|
|
1585
1493
|
/**
|
|
1586
|
-
* {{>
|
|
1587
|
-
* {{
|
|
1494
|
+
* {{> pressKey }}
|
|
1495
|
+
* {{ keys }}
|
|
1588
1496
|
*
|
|
1589
1497
|
* To make combinations with modifier and mouse clicks (like Ctrl+Click) press a modifier, click, then release it.
|
|
1590
1498
|
*
|
|
1591
1499
|
*
|
|
1592
|
-
* * *Appium*: supported, but clear field before pressing in apps:
|
|
1593
|
-
*
|
|
1594
1500
|
* ```js
|
|
1595
1501
|
* I.pressKey('Control');
|
|
1596
1502
|
* I.click('#someelement');
|
|
@@ -1609,23 +1515,36 @@ class WebDriver extends Helper {
|
|
|
1609
1515
|
}
|
|
1610
1516
|
|
|
1611
1517
|
/**
|
|
1612
|
-
* {{>
|
|
1518
|
+
* {{> resizeWindow }}
|
|
1613
1519
|
* Appium: not tested in web, in apps doesn't work
|
|
1614
1520
|
*/
|
|
1615
1521
|
async resizeWindow(width, height) {
|
|
1522
|
+
return this._resizeBrowserWindow(this.browser, width, height);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
async _resizeBrowserWindow(browser, width, height) {
|
|
1616
1526
|
if (width === 'maximize') {
|
|
1617
|
-
const size = await
|
|
1527
|
+
const size = await browser.maximizeWindow();
|
|
1618
1528
|
this.debugSection('Window Size', size);
|
|
1619
1529
|
return;
|
|
1620
1530
|
}
|
|
1621
|
-
if (
|
|
1622
|
-
return
|
|
1531
|
+
if (browser.isW3C) {
|
|
1532
|
+
return browser.setWindowRect(null, null, parseInt(width, 10), parseInt(height, 10));
|
|
1533
|
+
}
|
|
1534
|
+
return browser.setWindowSize(parseInt(width, 10), parseInt(height, 10));
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
async _resizeWindowIfNeeded(browser, windowSize) {
|
|
1538
|
+
if (this.isWeb && windowSize === 'maximize') {
|
|
1539
|
+
await this._resizeBrowserWindow(browser, 'maximize');
|
|
1540
|
+
} else if (this.isWeb && windowSize && windowSize.indexOf('x') > 0) {
|
|
1541
|
+
const dimensions = windowSize.split('x');
|
|
1542
|
+
await this._resizeBrowserWindow(browser, dimensions[0], dimensions[1]);
|
|
1623
1543
|
}
|
|
1624
|
-
return this.browser.setWindowSize(parseInt(width, 10), parseInt(height, 10));
|
|
1625
1544
|
}
|
|
1626
1545
|
|
|
1627
1546
|
/**
|
|
1628
|
-
* {{>
|
|
1547
|
+
* {{> dragAndDrop }}
|
|
1629
1548
|
* Appium: not tested
|
|
1630
1549
|
*/
|
|
1631
1550
|
async dragAndDrop(srcElement, destElement) {
|
|
@@ -1641,7 +1560,7 @@ class WebDriver extends Helper {
|
|
|
1641
1560
|
}
|
|
1642
1561
|
|
|
1643
1562
|
/**
|
|
1644
|
-
* {{>
|
|
1563
|
+
* {{> dragSlider }}
|
|
1645
1564
|
*/
|
|
1646
1565
|
async dragSlider(locator, offsetX = 0) {
|
|
1647
1566
|
const browser = this.browser;
|
|
@@ -1663,12 +1582,51 @@ class WebDriver extends Helper {
|
|
|
1663
1582
|
await browser.buttonUp(0);
|
|
1664
1583
|
}
|
|
1665
1584
|
|
|
1585
|
+
/**
|
|
1586
|
+
* Get all Window Handles.
|
|
1587
|
+
* Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
|
|
1588
|
+
*
|
|
1589
|
+
* ```js
|
|
1590
|
+
* const windows = await I.grabAllWindowHandles();
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
async grabAllWindowHandles() {
|
|
1594
|
+
return this.browser.getWindowHandles();
|
|
1595
|
+
}
|
|
1666
1596
|
|
|
1667
1597
|
/**
|
|
1668
|
-
*
|
|
1598
|
+
* Get the current Window Handle.
|
|
1599
|
+
* Useful for referencing it when calling `I.switchToWindow(handle)`
|
|
1669
1600
|
*
|
|
1601
|
+
* ```js
|
|
1602
|
+
* const window = await I.grabCurrentWindowHandle();
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
async grabCurrentWindowHandle() {
|
|
1606
|
+
return this.browser.getWindowHandle();
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
/**
|
|
1610
|
+
* Switch to the window with a specified handle.
|
|
1611
|
+
*
|
|
1612
|
+
* ```js
|
|
1613
|
+
* const windows = await I.grabAllWindowHandles();
|
|
1614
|
+
* // ... do something
|
|
1615
|
+
* await I.switchToWindow( windows[0] );
|
|
1616
|
+
*
|
|
1617
|
+
* const window = await.grabCurrentWindowHandle();
|
|
1618
|
+
* // ... do something
|
|
1619
|
+
* await I.switchToWindow( window );
|
|
1620
|
+
* ```
|
|
1621
|
+
*/
|
|
1622
|
+
async switchToWindow(window) {
|
|
1623
|
+
await this.browser.switchToWindow(window);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* Close all tabs except for the current one.
|
|
1670
1629
|
*
|
|
1671
|
-
* * *Appium*: supported web test
|
|
1672
1630
|
*
|
|
1673
1631
|
* ```js
|
|
1674
1632
|
* I.closeOtherTabs();
|
|
@@ -1687,20 +1645,16 @@ class WebDriver extends Helper {
|
|
|
1687
1645
|
}
|
|
1688
1646
|
|
|
1689
1647
|
/**
|
|
1690
|
-
* {{>
|
|
1691
|
-
*
|
|
1648
|
+
* {{> wait }}
|
|
1692
1649
|
*
|
|
1693
|
-
* * *Appium*: supported
|
|
1694
1650
|
*/
|
|
1695
1651
|
async wait(sec) {
|
|
1696
1652
|
return new Promise(resolve => setTimeout(resolve, sec * 1000));
|
|
1697
1653
|
}
|
|
1698
1654
|
|
|
1699
1655
|
/**
|
|
1700
|
-
* {{>
|
|
1701
|
-
*
|
|
1656
|
+
* {{> waitForEnabled }}
|
|
1702
1657
|
*
|
|
1703
|
-
* * *Appium*: supported
|
|
1704
1658
|
*/
|
|
1705
1659
|
async waitForEnabled(locator, sec = null) {
|
|
1706
1660
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1718,7 +1672,7 @@ class WebDriver extends Helper {
|
|
|
1718
1672
|
}
|
|
1719
1673
|
|
|
1720
1674
|
/**
|
|
1721
|
-
* {{>
|
|
1675
|
+
* {{> waitForElement }}
|
|
1722
1676
|
*/
|
|
1723
1677
|
async waitForElement(locator, sec = null) {
|
|
1724
1678
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1737,7 +1691,7 @@ class WebDriver extends Helper {
|
|
|
1737
1691
|
|
|
1738
1692
|
|
|
1739
1693
|
/**
|
|
1740
|
-
* {{>
|
|
1694
|
+
* {{> waitInUrl }}
|
|
1741
1695
|
*/
|
|
1742
1696
|
async waitInUrl(urlPart, sec = null) {
|
|
1743
1697
|
const client = this.browser;
|
|
@@ -1758,7 +1712,7 @@ class WebDriver extends Helper {
|
|
|
1758
1712
|
}
|
|
1759
1713
|
|
|
1760
1714
|
/**
|
|
1761
|
-
* {{>
|
|
1715
|
+
* {{> waitUrlEquals }}
|
|
1762
1716
|
*/
|
|
1763
1717
|
async waitUrlEquals(urlPart, sec = null) {
|
|
1764
1718
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1781,7 +1735,7 @@ class WebDriver extends Helper {
|
|
|
1781
1735
|
}
|
|
1782
1736
|
|
|
1783
1737
|
/**
|
|
1784
|
-
* {{>
|
|
1738
|
+
* {{> waitForText }}
|
|
1785
1739
|
*
|
|
1786
1740
|
*/
|
|
1787
1741
|
async waitForText(text, sec = null, context = null) {
|
|
@@ -1802,7 +1756,7 @@ class WebDriver extends Helper {
|
|
|
1802
1756
|
}
|
|
1803
1757
|
|
|
1804
1758
|
/**
|
|
1805
|
-
* {{>
|
|
1759
|
+
* {{> waitForValue }}
|
|
1806
1760
|
*/
|
|
1807
1761
|
async waitForValue(field, value, sec = null) {
|
|
1808
1762
|
const client = this.browser;
|
|
@@ -1822,10 +1776,8 @@ class WebDriver extends Helper {
|
|
|
1822
1776
|
}
|
|
1823
1777
|
|
|
1824
1778
|
/**
|
|
1825
|
-
* {{>
|
|
1779
|
+
* {{> waitForVisible }}
|
|
1826
1780
|
*
|
|
1827
|
-
*
|
|
1828
|
-
* * *Appium*: supported
|
|
1829
1781
|
*/
|
|
1830
1782
|
async waitForVisible(locator, sec = null) {
|
|
1831
1783
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1841,7 +1793,7 @@ class WebDriver extends Helper {
|
|
|
1841
1793
|
}
|
|
1842
1794
|
|
|
1843
1795
|
/**
|
|
1844
|
-
* {{>
|
|
1796
|
+
* {{> waitNumberOfVisibleElements }}
|
|
1845
1797
|
*/
|
|
1846
1798
|
async waitNumberOfVisibleElements(locator, num, sec = null) {
|
|
1847
1799
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1856,10 +1808,8 @@ class WebDriver extends Helper {
|
|
|
1856
1808
|
}
|
|
1857
1809
|
|
|
1858
1810
|
/**
|
|
1859
|
-
* {{>
|
|
1860
|
-
*
|
|
1811
|
+
* {{> waitForInvisible }}
|
|
1861
1812
|
*
|
|
1862
|
-
* * *Appium*: supported
|
|
1863
1813
|
*/
|
|
1864
1814
|
async waitForInvisible(locator, sec = null) {
|
|
1865
1815
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1872,10 +1822,8 @@ class WebDriver extends Helper {
|
|
|
1872
1822
|
}
|
|
1873
1823
|
|
|
1874
1824
|
/**
|
|
1875
|
-
* {{>
|
|
1876
|
-
*
|
|
1825
|
+
* {{> waitToHide }}
|
|
1877
1826
|
*
|
|
1878
|
-
* * *Appium*: supported
|
|
1879
1827
|
*/
|
|
1880
1828
|
async waitToHide(locator, sec = null) {
|
|
1881
1829
|
return this.waitForInvisible(locator, sec);
|
|
@@ -1887,10 +1835,8 @@ class WebDriver extends Helper {
|
|
|
1887
1835
|
}
|
|
1888
1836
|
|
|
1889
1837
|
/**
|
|
1890
|
-
* {{>
|
|
1838
|
+
* {{> waitForDetached }}
|
|
1891
1839
|
*
|
|
1892
|
-
*
|
|
1893
|
-
* * *Appium*: supported
|
|
1894
1840
|
*/
|
|
1895
1841
|
async waitForDetached(locator, sec = null) {
|
|
1896
1842
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1904,10 +1850,8 @@ class WebDriver extends Helper {
|
|
|
1904
1850
|
}
|
|
1905
1851
|
|
|
1906
1852
|
/**
|
|
1907
|
-
* {{>
|
|
1908
|
-
*
|
|
1853
|
+
* {{> waitForFunction }}
|
|
1909
1854
|
*
|
|
1910
|
-
* * *Appium*: supported
|
|
1911
1855
|
*/
|
|
1912
1856
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
1913
1857
|
let args = [];
|
|
@@ -1924,10 +1868,8 @@ class WebDriver extends Helper {
|
|
|
1924
1868
|
}
|
|
1925
1869
|
|
|
1926
1870
|
/**
|
|
1927
|
-
* {{>
|
|
1871
|
+
* {{> waitUntil }}
|
|
1928
1872
|
*
|
|
1929
|
-
* @param interval (optional) time in seconds between condition checks.
|
|
1930
|
-
* * *Appium*: supported
|
|
1931
1873
|
*/
|
|
1932
1874
|
async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) {
|
|
1933
1875
|
const aSec = sec || this.options.waitForTimeout;
|
|
@@ -1936,10 +1878,8 @@ class WebDriver extends Helper {
|
|
|
1936
1878
|
}
|
|
1937
1879
|
|
|
1938
1880
|
/**
|
|
1939
|
-
* {{>
|
|
1940
|
-
*
|
|
1881
|
+
* {{> switchTo }}
|
|
1941
1882
|
*
|
|
1942
|
-
* * *Appium*: supported only for web testing
|
|
1943
1883
|
*/
|
|
1944
1884
|
async switchTo(locator) {
|
|
1945
1885
|
this.browser.isInsideFrame = true;
|
|
@@ -2032,7 +1972,7 @@ class WebDriver extends Helper {
|
|
|
2032
1972
|
}
|
|
2033
1973
|
|
|
2034
1974
|
/**
|
|
2035
|
-
* {{>
|
|
1975
|
+
* {{> grabNumberOfOpenTabs }}
|
|
2036
1976
|
*/
|
|
2037
1977
|
async grabNumberOfOpenTabs() {
|
|
2038
1978
|
const pages = await this.browser.getWindowHandles();
|
|
@@ -2041,7 +1981,7 @@ class WebDriver extends Helper {
|
|
|
2041
1981
|
}
|
|
2042
1982
|
|
|
2043
1983
|
/**
|
|
2044
|
-
* {{>
|
|
1984
|
+
* {{> refreshPage }}
|
|
2045
1985
|
*/
|
|
2046
1986
|
async refreshPage() {
|
|
2047
1987
|
const client = this.browser;
|
|
@@ -2049,7 +1989,7 @@ class WebDriver extends Helper {
|
|
|
2049
1989
|
}
|
|
2050
1990
|
|
|
2051
1991
|
/**
|
|
2052
|
-
* {{>
|
|
1992
|
+
* {{> scrollPageToTop }}
|
|
2053
1993
|
*/
|
|
2054
1994
|
scrollPageToTop() {
|
|
2055
1995
|
const client = this.browser;
|
|
@@ -2061,7 +2001,7 @@ class WebDriver extends Helper {
|
|
|
2061
2001
|
}
|
|
2062
2002
|
|
|
2063
2003
|
/**
|
|
2064
|
-
* {{>
|
|
2004
|
+
* {{> scrollPageToBottom }}
|
|
2065
2005
|
*/
|
|
2066
2006
|
scrollPageToBottom() {
|
|
2067
2007
|
const client = this.browser;
|
|
@@ -2078,7 +2018,7 @@ class WebDriver extends Helper {
|
|
|
2078
2018
|
}
|
|
2079
2019
|
|
|
2080
2020
|
/**
|
|
2081
|
-
* {{>
|
|
2021
|
+
* {{> grabPageScrollPosition }}
|
|
2082
2022
|
*/
|
|
2083
2023
|
async grabPageScrollPosition() {
|
|
2084
2024
|
/* eslint-disable comma-dangle */
|