webdriverio 7.17.0 → 7.17.3
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/build/commands/browser/$$.d.ts +50 -0
- package/build/commands/browser/$$.d.ts.map +1 -0
- package/build/commands/browser/$$.js +57 -0
- package/build/commands/browser/$.d.ts +77 -0
- package/build/commands/browser/$.d.ts.map +1 -0
- package/build/commands/browser/$.js +91 -0
- package/build/commands/browser/addCommand.d.ts +37 -0
- package/build/commands/browser/addCommand.d.ts.map +1 -0
- package/build/commands/browser/addCommand.js +37 -0
- package/build/commands/browser/call.d.ts +42 -0
- package/build/commands/browser/call.d.ts.map +1 -0
- package/build/commands/browser/call.js +49 -0
- package/build/commands/browser/custom$$.d.ts +26 -0
- package/build/commands/browser/custom$$.d.ts.map +1 -0
- package/build/commands/browser/custom$$.js +47 -0
- package/build/commands/browser/custom$.d.ts +25 -0
- package/build/commands/browser/custom$.d.ts.map +1 -0
- package/build/commands/browser/custom$.js +47 -0
- package/build/commands/browser/debug.d.ts +32 -0
- package/build/commands/browser/debug.d.ts.map +1 -0
- package/build/commands/browser/debug.js +108 -0
- package/build/commands/browser/deleteCookies.d.ts +45 -0
- package/build/commands/browser/deleteCookies.d.ts.map +1 -0
- package/build/commands/browser/deleteCookies.js +56 -0
- package/build/commands/browser/execute.d.ts +37 -0
- package/build/commands/browser/execute.d.ts.map +1 -0
- package/build/commands/browser/execute.js +55 -0
- package/build/commands/browser/executeAsync.d.ts +45 -0
- package/build/commands/browser/executeAsync.d.ts.map +1 -0
- package/build/commands/browser/executeAsync.js +63 -0
- package/build/commands/browser/getCookies.d.ts +34 -0
- package/build/commands/browser/getCookies.d.ts.map +1 -0
- package/build/commands/browser/getCookies.js +46 -0
- package/build/commands/browser/getPuppeteer.d.ts +38 -0
- package/build/commands/browser/getPuppeteer.d.ts.map +1 -0
- package/build/commands/browser/getPuppeteer.js +119 -0
- package/build/commands/browser/getWindowSize.d.ts +25 -0
- package/build/commands/browser/getWindowSize.d.ts.map +1 -0
- package/build/commands/browser/getWindowSize.js +30 -0
- package/build/commands/browser/keys.d.ts +28 -0
- package/build/commands/browser/keys.d.ts.map +1 -0
- package/build/commands/browser/keys.js +64 -0
- package/build/commands/browser/mock.d.ts +111 -0
- package/build/commands/browser/mock.d.ts.map +1 -0
- package/build/commands/browser/mock.js +164 -0
- package/build/commands/browser/mockClearAll.d.ts +28 -0
- package/build/commands/browser/mockClearAll.d.ts.map +1 -0
- package/build/commands/browser/mockClearAll.js +43 -0
- package/build/commands/browser/mockRestoreAll.d.ts +26 -0
- package/build/commands/browser/mockRestoreAll.d.ts.map +1 -0
- package/build/commands/browser/mockRestoreAll.js +41 -0
- package/build/commands/browser/newWindow.d.ts +41 -0
- package/build/commands/browser/newWindow.d.ts.map +1 -0
- package/build/commands/browser/newWindow.js +83 -0
- package/build/commands/browser/overwriteCommand.d.ts +32 -0
- package/build/commands/browser/overwriteCommand.d.ts.map +1 -0
- package/build/commands/browser/overwriteCommand.js +32 -0
- package/build/commands/browser/pause.d.ts +23 -0
- package/build/commands/browser/pause.d.ts.map +1 -0
- package/build/commands/browser/pause.js +27 -0
- package/build/commands/browser/react$$.d.ts +36 -0
- package/build/commands/browser/react$$.d.ts.map +1 -0
- package/build/commands/browser/react$$.js +51 -0
- package/build/commands/browser/react$.d.ts +46 -0
- package/build/commands/browser/react$.d.ts.map +1 -0
- package/build/commands/browser/react$.js +59 -0
- package/build/commands/browser/reloadSession.d.ts +23 -0
- package/build/commands/browser/reloadSession.d.ts.map +1 -0
- package/build/commands/browser/reloadSession.js +58 -0
- package/build/commands/browser/savePDF.d.ts +46 -0
- package/build/commands/browser/savePDF.d.ts.map +1 -0
- package/build/commands/browser/savePDF.js +51 -0
- package/build/commands/browser/saveRecordingScreen.d.ts +28 -0
- package/build/commands/browser/saveRecordingScreen.d.ts.map +1 -0
- package/build/commands/browser/saveRecordingScreen.js +47 -0
- package/build/commands/browser/saveScreenshot.d.ts +22 -0
- package/build/commands/browser/saveScreenshot.d.ts.map +1 -0
- package/build/commands/browser/saveScreenshot.js +41 -0
- package/build/commands/browser/setCookies.d.ts +57 -0
- package/build/commands/browser/setCookies.d.ts.map +1 -0
- package/build/commands/browser/setCookies.js +66 -0
- package/build/commands/browser/setTimeout.d.ts +31 -0
- package/build/commands/browser/setTimeout.d.ts.map +1 -0
- package/build/commands/browser/setTimeout.js +61 -0
- package/build/commands/browser/setWindowSize.d.ts +20 -0
- package/build/commands/browser/setWindowSize.d.ts.map +1 -0
- package/build/commands/browser/setWindowSize.js +43 -0
- package/build/commands/browser/switchWindow.d.ts +30 -0
- package/build/commands/browser/switchWindow.d.ts.map +1 -0
- package/build/commands/browser/switchWindow.js +73 -0
- package/build/commands/browser/throttle.d.ts +3 -0
- package/build/commands/browser/throttle.d.ts.map +1 -0
- package/build/commands/browser/throttle.js +144 -0
- package/build/commands/browser/touchAction.d.ts +61 -0
- package/build/commands/browser/touchAction.d.ts.map +1 -0
- package/build/commands/browser/touchAction.js +65 -0
- package/build/commands/browser/uploadFile.d.ts +32 -0
- package/build/commands/browser/uploadFile.d.ts.map +1 -0
- package/build/commands/browser/uploadFile.js +63 -0
- package/build/commands/browser/url.d.ts +38 -0
- package/build/commands/browser/url.d.ts.map +1 -0
- package/build/commands/browser/url.js +49 -0
- package/build/commands/browser/waitUntil.d.ts +44 -0
- package/build/commands/browser/waitUntil.d.ts.map +1 -0
- package/build/commands/browser/waitUntil.js +73 -0
- package/build/commands/browser.d.ts +70 -0
- package/build/commands/browser.d.ts.map +1 -0
- package/build/commands/browser.js +44 -0
- package/build/commands/constant.d.ts +19 -0
- package/build/commands/constant.d.ts.map +1 -0
- package/build/commands/constant.js +91 -0
- package/build/commands/element/$$.d.ts +46 -0
- package/build/commands/element/$$.d.ts.map +1 -0
- package/build/commands/element/$$.js +50 -0
- package/build/commands/element/$.d.ts +72 -0
- package/build/commands/element/$.d.ts.map +1 -0
- package/build/commands/element/$.js +76 -0
- package/build/commands/element/addValue.d.ts +33 -0
- package/build/commands/element/addValue.d.ts.map +1 -0
- package/build/commands/element/addValue.js +48 -0
- package/build/commands/element/clearValue.d.ts +28 -0
- package/build/commands/element/clearValue.d.ts.map +1 -0
- package/build/commands/element/clearValue.js +32 -0
- package/build/commands/element/click.d.ts +73 -0
- package/build/commands/element/click.d.ts.map +1 -0
- package/build/commands/element/click.js +134 -0
- package/build/commands/element/custom$$.d.ts +28 -0
- package/build/commands/element/custom$$.d.ts.map +1 -0
- package/build/commands/element/custom$$.js +57 -0
- package/build/commands/element/custom$.d.ts +27 -0
- package/build/commands/element/custom$.d.ts.map +1 -0
- package/build/commands/element/custom$.js +57 -0
- package/build/commands/element/doubleClick.d.ts +25 -0
- package/build/commands/element/doubleClick.d.ts.map +1 -0
- package/build/commands/element/doubleClick.js +51 -0
- package/build/commands/element/dragAndDrop.d.ts +41 -0
- package/build/commands/element/dragAndDrop.d.ts.map +1 -0
- package/build/commands/element/dragAndDrop.js +98 -0
- package/build/commands/element/getAttribute.d.ts +28 -0
- package/build/commands/element/getAttribute.d.ts.map +1 -0
- package/build/commands/element/getAttribute.js +32 -0
- package/build/commands/element/getCSSProperty.d.ts +71 -0
- package/build/commands/element/getCSSProperty.d.ts.map +1 -0
- package/build/commands/element/getCSSProperty.js +108 -0
- package/build/commands/element/getComputedLabel.d.ts +20 -0
- package/build/commands/element/getComputedLabel.d.ts.map +1 -0
- package/build/commands/element/getComputedLabel.js +24 -0
- package/build/commands/element/getComputedRole.d.ts +20 -0
- package/build/commands/element/getComputedRole.d.ts.map +1 -0
- package/build/commands/element/getComputedRole.js +24 -0
- package/build/commands/element/getHTML.d.ts +32 -0
- package/build/commands/element/getHTML.d.ts.map +1 -0
- package/build/commands/element/getHTML.js +46 -0
- package/build/commands/element/getLocation.d.ts +6 -0
- package/build/commands/element/getLocation.d.ts.map +1 -0
- package/build/commands/element/getLocation.js +46 -0
- package/build/commands/element/getProperty.d.ts +53 -0
- package/build/commands/element/getProperty.d.ts.map +1 -0
- package/build/commands/element/getProperty.js +31 -0
- package/build/commands/element/getSize.d.ts +6 -0
- package/build/commands/element/getSize.d.ts.map +1 -0
- package/build/commands/element/getSize.js +47 -0
- package/build/commands/element/getTagName.d.ts +25 -0
- package/build/commands/element/getTagName.d.ts.map +1 -0
- package/build/commands/element/getTagName.js +29 -0
- package/build/commands/element/getText.d.ts +42 -0
- package/build/commands/element/getText.d.ts.map +1 -0
- package/build/commands/element/getText.js +46 -0
- package/build/commands/element/getValue.d.ts +25 -0
- package/build/commands/element/getValue.d.ts.map +1 -0
- package/build/commands/element/getValue.js +33 -0
- package/build/commands/element/isClickable.d.ts +40 -0
- package/build/commands/element/isClickable.d.ts.map +1 -0
- package/build/commands/element/isClickable.js +57 -0
- package/build/commands/element/isDisplayed.d.ts +50 -0
- package/build/commands/element/isDisplayed.d.ts.map +1 -0
- package/build/commands/element/isDisplayed.js +85 -0
- package/build/commands/element/isDisplayedInViewport.d.ts +38 -0
- package/build/commands/element/isDisplayedInViewport.d.ts.map +1 -0
- package/build/commands/element/isDisplayedInViewport.js +55 -0
- package/build/commands/element/isEnabled.d.ts +34 -0
- package/build/commands/element/isEnabled.d.ts.map +1 -0
- package/build/commands/element/isEnabled.js +38 -0
- package/build/commands/element/isEqual.d.ts +24 -0
- package/build/commands/element/isEqual.d.ts.map +1 -0
- package/build/commands/element/isEqual.js +52 -0
- package/build/commands/element/isExisting.d.ts +49 -0
- package/build/commands/element/isExisting.d.ts.map +1 -0
- package/build/commands/element/isExisting.js +65 -0
- package/build/commands/element/isFocused.d.ts +28 -0
- package/build/commands/element/isFocused.d.ts.map +1 -0
- package/build/commands/element/isFocused.js +42 -0
- package/build/commands/element/isSelected.d.ts +31 -0
- package/build/commands/element/isSelected.d.ts.map +1 -0
- package/build/commands/element/isSelected.js +35 -0
- package/build/commands/element/moveTo.d.ts +21 -0
- package/build/commands/element/moveTo.d.ts.map +1 -0
- package/build/commands/element/moveTo.js +39 -0
- package/build/commands/element/nextElement.d.ts +25 -0
- package/build/commands/element/nextElement.d.ts.map +1 -0
- package/build/commands/element/nextElement.js +31 -0
- package/build/commands/element/parentElement.d.ts +25 -0
- package/build/commands/element/parentElement.d.ts.map +1 -0
- package/build/commands/element/parentElement.js +31 -0
- package/build/commands/element/previousElement.d.ts +25 -0
- package/build/commands/element/previousElement.d.ts.map +1 -0
- package/build/commands/element/previousElement.js +31 -0
- package/build/commands/element/react$$.d.ts +36 -0
- package/build/commands/element/react$$.d.ts.map +1 -0
- package/build/commands/element/react$$.js +51 -0
- package/build/commands/element/react$.d.ts +46 -0
- package/build/commands/element/react$.d.ts.map +1 -0
- package/build/commands/element/react$.js +59 -0
- package/build/commands/element/saveScreenshot.d.ts +21 -0
- package/build/commands/element/saveScreenshot.d.ts.map +1 -0
- package/build/commands/element/saveScreenshot.js +40 -0
- package/build/commands/element/scrollIntoView.d.ts +21 -0
- package/build/commands/element/scrollIntoView.d.ts.map +1 -0
- package/build/commands/element/scrollIntoView.js +31 -0
- package/build/commands/element/selectByAttribute.d.ts +37 -0
- package/build/commands/element/selectByAttribute.d.ts.map +1 -0
- package/build/commands/element/selectByAttribute.js +59 -0
- package/build/commands/element/selectByIndex.d.ts +31 -0
- package/build/commands/element/selectByIndex.d.ts.map +1 -0
- package/build/commands/element/selectByIndex.js +55 -0
- package/build/commands/element/selectByVisibleText.d.ts +31 -0
- package/build/commands/element/selectByVisibleText.d.ts.map +1 -0
- package/build/commands/element/selectByVisibleText.js +66 -0
- package/build/commands/element/setValue.d.ts +29 -0
- package/build/commands/element/setValue.d.ts.map +1 -0
- package/build/commands/element/setValue.js +33 -0
- package/build/commands/element/shadow$$.d.ts +22 -0
- package/build/commands/element/shadow$$.d.ts.map +1 -0
- package/build/commands/element/shadow$$.js +27 -0
- package/build/commands/element/shadow$.d.ts +22 -0
- package/build/commands/element/shadow$.d.ts.map +1 -0
- package/build/commands/element/shadow$.js +27 -0
- package/build/commands/element/touchAction.d.ts +54 -0
- package/build/commands/element/touchAction.d.ts.map +1 -0
- package/build/commands/element/touchAction.js +58 -0
- package/build/commands/element/waitForClickable.d.ts +34 -0
- package/build/commands/element/waitForClickable.d.ts.map +1 -0
- package/build/commands/element/waitForClickable.js +37 -0
- package/build/commands/element/waitForDisplayed.d.ts +44 -0
- package/build/commands/element/waitForDisplayed.d.ts.map +1 -0
- package/build/commands/element/waitForDisplayed.js +47 -0
- package/build/commands/element/waitForEnabled.d.ts +46 -0
- package/build/commands/element/waitForEnabled.d.ts.map +1 -0
- package/build/commands/element/waitForEnabled.js +55 -0
- package/build/commands/element/waitForExist.d.ts +46 -0
- package/build/commands/element/waitForExist.d.ts.map +1 -0
- package/build/commands/element/waitForExist.js +49 -0
- package/build/commands/element/waitUntil.d.ts +49 -0
- package/build/commands/element/waitUntil.d.ts.map +1 -0
- package/build/commands/element/waitUntil.js +53 -0
- package/build/commands/element.d.ts +100 -0
- package/build/commands/element.d.ts.map +1 -0
- package/build/commands/element.js +63 -0
- package/build/commands/mock/abort.d.ts +19 -0
- package/build/commands/mock/abort.d.ts.map +1 -0
- package/build/commands/mock/abort.js +20 -0
- package/build/commands/mock/abortOnce.d.ts +27 -0
- package/build/commands/mock/abortOnce.d.ts.map +1 -0
- package/build/commands/mock/abortOnce.js +28 -0
- package/build/commands/mock/clear.d.ts +18 -0
- package/build/commands/mock/clear.d.ts.map +1 -0
- package/build/commands/mock/clear.js +19 -0
- package/build/commands/mock/respond.d.ts +54 -0
- package/build/commands/mock/respond.d.ts.map +1 -0
- package/build/commands/mock/respond.js +55 -0
- package/build/commands/mock/respondOnce.d.ts +55 -0
- package/build/commands/mock/respondOnce.d.ts.map +1 -0
- package/build/commands/mock/respondOnce.js +56 -0
- package/build/commands/mock/restore.d.ts +18 -0
- package/build/commands/mock/restore.d.ts.map +1 -0
- package/build/commands/mock/restore.js +19 -0
- package/build/constants.d.ts +14 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +286 -0
- package/build/index.d.ts +45 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +175 -0
- package/build/middlewares.d.ts +12 -0
- package/build/middlewares.d.ts.map +1 -0
- package/build/middlewares.js +65 -0
- package/build/multiremote.d.ts +71 -0
- package/build/multiremote.d.ts.map +1 -0
- package/build/multiremote.js +160 -0
- package/build/protocol-stub.d.ts +16 -0
- package/build/protocol-stub.d.ts.map +1 -0
- package/build/protocol-stub.js +77 -0
- package/build/scripts/getHTML.d.ts +9 -0
- package/build/scripts/getHTML.d.ts.map +1 -0
- package/build/scripts/getHTML.js +13 -0
- package/build/scripts/getProperty.d.ts +43 -0
- package/build/scripts/getProperty.d.ts.map +1 -0
- package/build/scripts/getProperty.js +12 -0
- package/build/scripts/isElementClickable.d.ts +7 -0
- package/build/scripts/isElementClickable.d.ts.map +1 -0
- package/build/scripts/isElementClickable.js +121 -0
- package/build/scripts/isElementDisplayed.d.ts +7 -0
- package/build/scripts/isElementDisplayed.d.ts.map +1 -0
- package/build/scripts/isElementDisplayed.js +216 -0
- package/build/scripts/isElementInViewport.d.ts +10 -0
- package/build/scripts/isElementInViewport.d.ts.map +1 -0
- package/build/scripts/isElementInViewport.js +22 -0
- package/build/scripts/isFocused.d.ts +7 -0
- package/build/scripts/isFocused.d.ts.map +1 -0
- package/build/scripts/isFocused.js +11 -0
- package/build/scripts/newWindow.d.ts +10 -0
- package/build/scripts/newWindow.d.ts.map +1 -0
- package/build/scripts/newWindow.js +14 -0
- package/build/scripts/resq.d.ts +6 -0
- package/build/scripts/resq.d.ts.map +1 -0
- package/build/scripts/resq.js +58 -0
- package/build/scripts/shadowFnFactory.d.ts +2 -0
- package/build/scripts/shadowFnFactory.d.ts.map +1 -0
- package/build/scripts/shadowFnFactory.js +17 -0
- package/build/types.d.ts +402 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/utils/SevereServiceError.d.ts +7 -0
- package/build/utils/SevereServiceError.d.ts.map +1 -0
- package/build/utils/SevereServiceError.js +12 -0
- package/build/utils/Timer.d.ts +33 -0
- package/build/utils/Timer.d.ts.map +1 -0
- package/build/utils/Timer.js +126 -0
- package/build/utils/detectBackend.d.ts +23 -0
- package/build/utils/detectBackend.d.ts.map +1 -0
- package/build/utils/detectBackend.js +119 -0
- package/build/utils/findStrategy.d.ts +10 -0
- package/build/utils/findStrategy.d.ts.map +1 -0
- package/build/utils/findStrategy.js +267 -0
- package/build/utils/getElementObject.d.ts +17 -0
- package/build/utils/getElementObject.d.ts.map +1 -0
- package/build/utils/getElementObject.js +107 -0
- package/build/utils/implicitWait.d.ts +7 -0
- package/build/utils/implicitWait.d.ts.map +1 -0
- package/build/utils/implicitWait.js +39 -0
- package/build/utils/index.d.ts +102 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +543 -0
- package/build/utils/interception/devtools.d.ts +61 -0
- package/build/utils/interception/devtools.d.ts.map +1 -0
- package/build/utils/interception/devtools.js +247 -0
- package/build/utils/interception/index.d.ts +26 -0
- package/build/utils/interception/index.d.ts.map +1 -0
- package/build/utils/interception/index.js +49 -0
- package/build/utils/interception/types.d.ts +94 -0
- package/build/utils/interception/types.d.ts.map +1 -0
- package/build/utils/interception/types.js +2 -0
- package/build/utils/interception/webdriver.d.ts +48 -0
- package/build/utils/interception/webdriver.d.ts.map +1 -0
- package/build/utils/interception/webdriver.js +75 -0
- package/build/utils/refetchElement.d.ts +6 -0
- package/build/utils/refetchElement.d.ts.map +1 -0
- package/build/utils/refetchElement.js +32 -0
- package/package.json +10 -10
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Throttle the network capabilities of the browser. This can help to
|
|
5
|
+
* emulate certain scenarios where a user loses their internet connection
|
|
6
|
+
* and your app needs to address that.
|
|
7
|
+
*
|
|
8
|
+
* There are many presets available with default configurations for ease of use.
|
|
9
|
+
* They are `offline`, `GPRS`, `Regular2G`, `Good2G`, `Regular3G`, `Good3G`,
|
|
10
|
+
* `Regular4G`, `DSL`, `WiFi`, `online`.
|
|
11
|
+
*
|
|
12
|
+
* You can see the values for these presets [in the source code](https://github.com/webdriverio/webdriverio/blob/6824e4eb118a8d20685f12f4bc42f13fd56f8a25/packages/webdriverio/src/commands/browser/throttle.js#L29).
|
|
13
|
+
*
|
|
14
|
+
* :::info
|
|
15
|
+
*
|
|
16
|
+
* Note that using the `throttle` command requires support for Chrome DevTools protocol and e.g.
|
|
17
|
+
* can not be used when running automated tests in the cloud. Find out more in the
|
|
18
|
+
* [Automation Protocols](/docs/automationProtocols) section.
|
|
19
|
+
*
|
|
20
|
+
* :::
|
|
21
|
+
*
|
|
22
|
+
* <example>
|
|
23
|
+
:throttle.js
|
|
24
|
+
it('should throttle the network', async () => {
|
|
25
|
+
// via static string preset
|
|
26
|
+
await browser.throttle('Regular3G')
|
|
27
|
+
|
|
28
|
+
// via custom values
|
|
29
|
+
await browser.throttle({
|
|
30
|
+
offline: false,
|
|
31
|
+
downloadThroughput: 200 * 1024 / 8,
|
|
32
|
+
uploadThroughput: 200 * 1024 / 8,
|
|
33
|
+
latency: 20
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
* </example>
|
|
37
|
+
*
|
|
38
|
+
* @alias browser.throttle
|
|
39
|
+
* @param {ThrottleOptions} params parameters for throttling
|
|
40
|
+
* @param {Boolean} params.offline True to emulate internet disconnection.
|
|
41
|
+
* @param {Number} params.latency Minimum latency from request sent to response headers received (ms).
|
|
42
|
+
* @param {Number} params.downloadThroughput Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
|
|
43
|
+
* @param {Number} params.uploadThroughput Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.
|
|
44
|
+
* @type utility
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
const utils_1 = require("../../utils");
|
|
48
|
+
const NETWORK_PRESETS = {
|
|
49
|
+
'offline': {
|
|
50
|
+
offline: true,
|
|
51
|
+
downloadThroughput: 0,
|
|
52
|
+
uploadThroughput: 0,
|
|
53
|
+
latency: 1
|
|
54
|
+
},
|
|
55
|
+
'GPRS': {
|
|
56
|
+
offline: false,
|
|
57
|
+
downloadThroughput: 50 * 1024 / 8,
|
|
58
|
+
uploadThroughput: 20 * 1024 / 8,
|
|
59
|
+
latency: 500
|
|
60
|
+
},
|
|
61
|
+
'Regular2G': {
|
|
62
|
+
offline: false,
|
|
63
|
+
downloadThroughput: 250 * 1024 / 8,
|
|
64
|
+
uploadThroughput: 50 * 1024 / 8,
|
|
65
|
+
latency: 300
|
|
66
|
+
},
|
|
67
|
+
'Good2G': {
|
|
68
|
+
offline: false,
|
|
69
|
+
downloadThroughput: 450 * 1024 / 8,
|
|
70
|
+
uploadThroughput: 150 * 1024 / 8,
|
|
71
|
+
latency: 150
|
|
72
|
+
},
|
|
73
|
+
'Regular3G': {
|
|
74
|
+
offline: false,
|
|
75
|
+
downloadThroughput: 750 * 1024 / 8,
|
|
76
|
+
uploadThroughput: 250 * 1024 / 8,
|
|
77
|
+
latency: 100
|
|
78
|
+
},
|
|
79
|
+
'Good3G': {
|
|
80
|
+
offline: false,
|
|
81
|
+
downloadThroughput: 1.5 * 1024 * 1024 / 8,
|
|
82
|
+
uploadThroughput: 750 * 1024 / 8,
|
|
83
|
+
latency: 40
|
|
84
|
+
},
|
|
85
|
+
'Regular4G': {
|
|
86
|
+
offline: false,
|
|
87
|
+
downloadThroughput: 4 * 1024 * 1024 / 8,
|
|
88
|
+
uploadThroughput: 3 * 1024 * 1024 / 8,
|
|
89
|
+
latency: 20
|
|
90
|
+
},
|
|
91
|
+
'DSL': {
|
|
92
|
+
offline: false,
|
|
93
|
+
downloadThroughput: 2 * 1024 * 1024 / 8,
|
|
94
|
+
uploadThroughput: 1 * 1024 * 1024 / 8,
|
|
95
|
+
latency: 5
|
|
96
|
+
},
|
|
97
|
+
'WiFi': {
|
|
98
|
+
offline: false,
|
|
99
|
+
downloadThroughput: 30 * 1024 * 1024 / 8,
|
|
100
|
+
uploadThroughput: 15 * 1024 * 1024 / 8,
|
|
101
|
+
latency: 2
|
|
102
|
+
},
|
|
103
|
+
'online': {
|
|
104
|
+
offline: false,
|
|
105
|
+
latency: 0,
|
|
106
|
+
downloadThroughput: -1,
|
|
107
|
+
uploadThroughput: -1
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const NETWORK_PRESET_TYPES = Object.keys(NETWORK_PRESETS);
|
|
111
|
+
async function throttle(params) {
|
|
112
|
+
if (
|
|
113
|
+
/**
|
|
114
|
+
* check string parameter
|
|
115
|
+
*/
|
|
116
|
+
(typeof params !== 'string' || !NETWORK_PRESET_TYPES.includes(params)) &&
|
|
117
|
+
/**
|
|
118
|
+
* check object parameter
|
|
119
|
+
*/
|
|
120
|
+
(typeof params !== 'object')) {
|
|
121
|
+
throw new Error(`Invalid parameter for "throttle". Expected it to be typeof object or one of the following values: ${NETWORK_PRESET_TYPES.join(', ')} but found "${params}"`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* use WebDriver extension if connected with cloud service
|
|
125
|
+
*/
|
|
126
|
+
if (this.isSauce) {
|
|
127
|
+
const browser = (0, utils_1.getBrowserObject)(this);
|
|
128
|
+
await browser.throttleNetwork(params);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
// Connect to Chrome DevTools
|
|
132
|
+
await this.getPuppeteer();
|
|
133
|
+
if (!this.puppeteer) {
|
|
134
|
+
throw new Error('No Puppeteer connection could be established which is required to use this command');
|
|
135
|
+
}
|
|
136
|
+
const pages = await this.puppeteer.pages();
|
|
137
|
+
const client = await pages[0].target().createCDPSession();
|
|
138
|
+
// Set throttling property
|
|
139
|
+
await client.send('Network.emulateNetworkConditions', typeof params === 'string'
|
|
140
|
+
? NETWORK_PRESETS[params]
|
|
141
|
+
: params);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
exports.default = throttle;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TouchActions } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* The Touch Action API provides the basis of all gestures that can be automated in Appium.
|
|
5
|
+
* It is currently only available to native apps and can not be used to interact with webapps.
|
|
6
|
+
* At its core is the ability to chain together _ad hoc_ individual actions, which will then be
|
|
7
|
+
* applied to an element in the application on the device. The basic actions that can be used are:
|
|
8
|
+
*
|
|
9
|
+
* - press (pass element or (`x`, `y`) or both)
|
|
10
|
+
* - longPress (pass element or (`x`, `y`) or both)
|
|
11
|
+
* - tap (pass element or (`x`, `y`) or both)
|
|
12
|
+
* - moveTo (pass absolute `x`, `y` coordinates)
|
|
13
|
+
* - wait (pass `ms` (as milliseconds))
|
|
14
|
+
* - release (no arguments)
|
|
15
|
+
*
|
|
16
|
+
* <example>
|
|
17
|
+
:touchAction.js
|
|
18
|
+
it('should do a touch gesture', async () => {
|
|
19
|
+
const screen = await $('//UITextbox');
|
|
20
|
+
|
|
21
|
+
// simple touch action on element
|
|
22
|
+
await browser.touchAction({
|
|
23
|
+
action: 'tap',
|
|
24
|
+
element: screen
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// simple touch action x y variables
|
|
28
|
+
// tap location is 30px right and 20px down relative from the viewport
|
|
29
|
+
await browser.touchAction({
|
|
30
|
+
action: 'tap',
|
|
31
|
+
x: 30,
|
|
32
|
+
y:20
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// simple touch action x y variables
|
|
36
|
+
// tap location is 30px right and 20px down relative from the center of the element
|
|
37
|
+
await browser.touchAction({
|
|
38
|
+
action: 'tap',
|
|
39
|
+
x: 30,
|
|
40
|
+
y:20,
|
|
41
|
+
element: screen
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// multi action on an element
|
|
45
|
+
// drag&drop from position 200x200 down 100px on the screen
|
|
46
|
+
await browser.touchAction([
|
|
47
|
+
{ action: 'press', x: 200, y: 200 },
|
|
48
|
+
{ action: 'moveTo', x: 200, y: 300 },
|
|
49
|
+
'release'
|
|
50
|
+
])
|
|
51
|
+
});
|
|
52
|
+
* </example>
|
|
53
|
+
*
|
|
54
|
+
* @param {TouchActions} action action to execute
|
|
55
|
+
*
|
|
56
|
+
* @see https://saucelabs.com/blog/appium-sauce-labs-bootcamp-chapter-2-touch-actions
|
|
57
|
+
* @for android, ios
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export default function touchAction(this: WebdriverIO.Browser, actions: TouchActions): Promise<void>;
|
|
61
|
+
//# sourceMappingURL=touchAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touchAction.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/touchAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAC/B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,YAAY,iBAGxB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constant_1 = require("../constant");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* The Touch Action API provides the basis of all gestures that can be automated in Appium.
|
|
7
|
+
* It is currently only available to native apps and can not be used to interact with webapps.
|
|
8
|
+
* At its core is the ability to chain together _ad hoc_ individual actions, which will then be
|
|
9
|
+
* applied to an element in the application on the device. The basic actions that can be used are:
|
|
10
|
+
*
|
|
11
|
+
* - press (pass element or (`x`, `y`) or both)
|
|
12
|
+
* - longPress (pass element or (`x`, `y`) or both)
|
|
13
|
+
* - tap (pass element or (`x`, `y`) or both)
|
|
14
|
+
* - moveTo (pass absolute `x`, `y` coordinates)
|
|
15
|
+
* - wait (pass `ms` (as milliseconds))
|
|
16
|
+
* - release (no arguments)
|
|
17
|
+
*
|
|
18
|
+
* <example>
|
|
19
|
+
:touchAction.js
|
|
20
|
+
it('should do a touch gesture', async () => {
|
|
21
|
+
const screen = await $('//UITextbox');
|
|
22
|
+
|
|
23
|
+
// simple touch action on element
|
|
24
|
+
await browser.touchAction({
|
|
25
|
+
action: 'tap',
|
|
26
|
+
element: screen
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// simple touch action x y variables
|
|
30
|
+
// tap location is 30px right and 20px down relative from the viewport
|
|
31
|
+
await browser.touchAction({
|
|
32
|
+
action: 'tap',
|
|
33
|
+
x: 30,
|
|
34
|
+
y:20
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// simple touch action x y variables
|
|
38
|
+
// tap location is 30px right and 20px down relative from the center of the element
|
|
39
|
+
await browser.touchAction({
|
|
40
|
+
action: 'tap',
|
|
41
|
+
x: 30,
|
|
42
|
+
y:20,
|
|
43
|
+
element: screen
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// multi action on an element
|
|
47
|
+
// drag&drop from position 200x200 down 100px on the screen
|
|
48
|
+
await browser.touchAction([
|
|
49
|
+
{ action: 'press', x: 200, y: 200 },
|
|
50
|
+
{ action: 'moveTo', x: 200, y: 300 },
|
|
51
|
+
'release'
|
|
52
|
+
])
|
|
53
|
+
});
|
|
54
|
+
* </example>
|
|
55
|
+
*
|
|
56
|
+
* @param {TouchActions} action action to execute
|
|
57
|
+
*
|
|
58
|
+
* @see https://saucelabs.com/blog/appium-sauce-labs-bootcamp-chapter-2-touch-actions
|
|
59
|
+
* @for android, ios
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
function touchAction(actions) {
|
|
63
|
+
return constant_1.touchAction.call(this, actions);
|
|
64
|
+
}
|
|
65
|
+
exports.default = touchAction;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads a file to the Selenium Standalone server or other browser driver
|
|
3
|
+
* (e.g. Chromedriver) by using the [`file`](https://webdriver.io/docs/api/selenium#file) command.
|
|
4
|
+
* _Note:_ that this command is only supported if you use a Selenium Hub or
|
|
5
|
+
* Chromedriver directly.
|
|
6
|
+
*
|
|
7
|
+
* __Note:__ this command uses an un-offical protocol feature that is currently
|
|
8
|
+
* only supported in Chrome and when running a [Selenium Grid](https://www.selenium.dev/documentation/en/grid/).
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:uploadFile.js
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
it('should upload a file', async () => {
|
|
15
|
+
await browser.url('https://the-internet.herokuapp.com/upload')
|
|
16
|
+
|
|
17
|
+
const filePath = '/path/to/some/file.png'
|
|
18
|
+
const remoteFilePath = await browser.uploadFile(filePath)
|
|
19
|
+
|
|
20
|
+
await $('#file-upload').setValue(remoteFilePath)
|
|
21
|
+
await $('#file-submit').click()
|
|
22
|
+
});
|
|
23
|
+
* </example>
|
|
24
|
+
*
|
|
25
|
+
* @alias browser.uploadFile
|
|
26
|
+
* @param {String} localPath local path to file
|
|
27
|
+
* @type utility
|
|
28
|
+
* @uses protocol/file
|
|
29
|
+
* @return {String} remote URL
|
|
30
|
+
*/
|
|
31
|
+
export default function uploadFile(this: WebdriverIO.Browser, localPath: string): Promise<string>;
|
|
32
|
+
//# sourceMappingURL=uploadFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadFile.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/uploadFile.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAA8B,UAAU,CACpC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
9
|
+
/**
|
|
10
|
+
* Uploads a file to the Selenium Standalone server or other browser driver
|
|
11
|
+
* (e.g. Chromedriver) by using the [`file`](https://webdriver.io/docs/api/selenium#file) command.
|
|
12
|
+
* _Note:_ that this command is only supported if you use a Selenium Hub or
|
|
13
|
+
* Chromedriver directly.
|
|
14
|
+
*
|
|
15
|
+
* __Note:__ this command uses an un-offical protocol feature that is currently
|
|
16
|
+
* only supported in Chrome and when running a [Selenium Grid](https://www.selenium.dev/documentation/en/grid/).
|
|
17
|
+
*
|
|
18
|
+
* <example>
|
|
19
|
+
:uploadFile.js
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
it('should upload a file', async () => {
|
|
23
|
+
await browser.url('https://the-internet.herokuapp.com/upload')
|
|
24
|
+
|
|
25
|
+
const filePath = '/path/to/some/file.png'
|
|
26
|
+
const remoteFilePath = await browser.uploadFile(filePath)
|
|
27
|
+
|
|
28
|
+
await $('#file-upload').setValue(remoteFilePath)
|
|
29
|
+
await $('#file-submit').click()
|
|
30
|
+
});
|
|
31
|
+
* </example>
|
|
32
|
+
*
|
|
33
|
+
* @alias browser.uploadFile
|
|
34
|
+
* @param {String} localPath local path to file
|
|
35
|
+
* @type utility
|
|
36
|
+
* @uses protocol/file
|
|
37
|
+
* @return {String} remote URL
|
|
38
|
+
*/
|
|
39
|
+
async function uploadFile(localPath) {
|
|
40
|
+
/**
|
|
41
|
+
* parameter check
|
|
42
|
+
*/
|
|
43
|
+
if (typeof localPath !== 'string') {
|
|
44
|
+
throw new Error('number or type of arguments don\'t agree with uploadFile command');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* check if command is available
|
|
48
|
+
*/
|
|
49
|
+
if (typeof this.file !== 'function') {
|
|
50
|
+
throw new Error(`The uploadFile command is not available in ${this.capabilities.browserName}`);
|
|
51
|
+
}
|
|
52
|
+
let zipData = [];
|
|
53
|
+
let source = fs_1.default.createReadStream(localPath);
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
(0, archiver_1.default)('zip')
|
|
56
|
+
.on('error', (err) => reject(err))
|
|
57
|
+
.on('data', (data) => zipData.push(data))
|
|
58
|
+
.on('end', () => this.file(Buffer.concat(zipData).toString('base64')).then((localPath) => resolve(localPath), reject))
|
|
59
|
+
.append(source, { name: path_1.default.basename(localPath) })
|
|
60
|
+
.finalize();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.default = uploadFile;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Protocol binding to load the URL of the browser. If a baseUrl is
|
|
4
|
+
* specified in the config, it will be prepended to the url parameter using
|
|
5
|
+
* node's url.resolve() method. Calling `browser.url('...')` with the same url as last
|
|
6
|
+
* time will trigger a page reload.
|
|
7
|
+
*
|
|
8
|
+
* <example>
|
|
9
|
+
:url.js
|
|
10
|
+
// navigate to a new URL
|
|
11
|
+
await browser.url('https://webdriver.io');
|
|
12
|
+
// receive url
|
|
13
|
+
console.log(await browser.getUrl()); // outputs: "https://webdriver.io"
|
|
14
|
+
|
|
15
|
+
:baseUrlResolutions.js
|
|
16
|
+
// With a base URL of http://example.com/site, the following url parameters resolve as such:
|
|
17
|
+
// When providing a scheme:
|
|
18
|
+
// https://webdriver.io
|
|
19
|
+
await browser.url('https://webdriver.io');
|
|
20
|
+
|
|
21
|
+
// When not starting with a slash, the URL resolves relative to the baseUrl
|
|
22
|
+
// http://example.com/site/relative
|
|
23
|
+
await browser.url('relative');
|
|
24
|
+
|
|
25
|
+
// When starting with a slash, the URL resolves relative to the root path of the baseUrl
|
|
26
|
+
// http://example.com/rootRelative
|
|
27
|
+
await browser.url('/rootRelative');
|
|
28
|
+
* </example>
|
|
29
|
+
*
|
|
30
|
+
* @param {String=} url the URL to navigate to
|
|
31
|
+
*
|
|
32
|
+
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get
|
|
33
|
+
* @see https://nodejs.org/api/url.html#url_url_resolve_from_to
|
|
34
|
+
* @type protocol
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
export default function url(this: WebdriverIO.Browser, path: string): Promise<string>;
|
|
38
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/url.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CACvB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,IAAI,EAAE,MAAM,mBAWf"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../utils");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Protocol binding to load the URL of the browser. If a baseUrl is
|
|
7
|
+
* specified in the config, it will be prepended to the url parameter using
|
|
8
|
+
* node's url.resolve() method. Calling `browser.url('...')` with the same url as last
|
|
9
|
+
* time will trigger a page reload.
|
|
10
|
+
*
|
|
11
|
+
* <example>
|
|
12
|
+
:url.js
|
|
13
|
+
// navigate to a new URL
|
|
14
|
+
await browser.url('https://webdriver.io');
|
|
15
|
+
// receive url
|
|
16
|
+
console.log(await browser.getUrl()); // outputs: "https://webdriver.io"
|
|
17
|
+
|
|
18
|
+
:baseUrlResolutions.js
|
|
19
|
+
// With a base URL of http://example.com/site, the following url parameters resolve as such:
|
|
20
|
+
// When providing a scheme:
|
|
21
|
+
// https://webdriver.io
|
|
22
|
+
await browser.url('https://webdriver.io');
|
|
23
|
+
|
|
24
|
+
// When not starting with a slash, the URL resolves relative to the baseUrl
|
|
25
|
+
// http://example.com/site/relative
|
|
26
|
+
await browser.url('relative');
|
|
27
|
+
|
|
28
|
+
// When starting with a slash, the URL resolves relative to the root path of the baseUrl
|
|
29
|
+
// http://example.com/rootRelative
|
|
30
|
+
await browser.url('/rootRelative');
|
|
31
|
+
* </example>
|
|
32
|
+
*
|
|
33
|
+
* @param {String=} url the URL to navigate to
|
|
34
|
+
*
|
|
35
|
+
* @see https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get
|
|
36
|
+
* @see https://nodejs.org/api/url.html#url_url_resolve_from_to
|
|
37
|
+
* @type protocol
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
function url(path) {
|
|
41
|
+
if (typeof path !== 'string') {
|
|
42
|
+
throw new Error('Parameter for "url" command needs to be type of string');
|
|
43
|
+
}
|
|
44
|
+
if (typeof this.options.baseUrl === 'string' && this.options.baseUrl) {
|
|
45
|
+
path = (new URL(path, this.options.baseUrl)).href;
|
|
46
|
+
}
|
|
47
|
+
return this.navigateTo((0, utils_1.validateUrl)(path));
|
|
48
|
+
}
|
|
49
|
+
exports.default = url;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { WaitUntilOptions } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* This wait command is your universal weapon if you want to wait on something. It expects a condition
|
|
5
|
+
* and waits until that condition is fulfilled with a truthy value. If you use the WDIO testrunner the
|
|
6
|
+
* commands within the condition are getting executed synchronously like in your test.
|
|
7
|
+
*
|
|
8
|
+
* A common example is to wait until a certain element contains a certain text (see example).
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:example.html
|
|
12
|
+
<div id="someText">I am some text</div>
|
|
13
|
+
<script>
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
await $('#someText').html('I am now different');
|
|
16
|
+
}, 1000);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
:waitUntil.js
|
|
20
|
+
it('should wait until text has changed', async () => {
|
|
21
|
+
await browser.waitUntil(
|
|
22
|
+
async () => (await $('#someText').getText()) === 'I am now different',
|
|
23
|
+
{
|
|
24
|
+
timeout: 5000,
|
|
25
|
+
timeoutMsg: 'expected text to be different after 5s'
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
* </example>
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* @alias browser.waitUntil
|
|
33
|
+
* @param {Function#Boolean} condition condition to wait on
|
|
34
|
+
* @param {WaitUntilOptions=} options command options
|
|
35
|
+
* @param {Number=} options.timeout timeout in ms (default: 5000)
|
|
36
|
+
* @param {String=} options.timeoutMsg error message to throw when waitUntil times out
|
|
37
|
+
* @param {Number=} options.interval interval between condition checks (default: 500)
|
|
38
|
+
* @return {Boolean} true if condition is fulfilled
|
|
39
|
+
* @uses utility/pause
|
|
40
|
+
* @type utility
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export default function waitUntil(this: WebdriverIO.Browser | WebdriverIO.Element, condition: () => boolean | Promise<boolean>, { timeout, interval, timeoutMsg }?: Partial<WaitUntilOptions>): Promise<true | void>;
|
|
44
|
+
//# sourceMappingURL=waitUntil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitUntil.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/waitUntil.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC3C,EACI,OAAqC,EACrC,QAAuC,EACvC,UAAU,EACb,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAClC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CA4BtB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Timer_1 = __importDefault(require("../../utils/Timer"));
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* This wait command is your universal weapon if you want to wait on something. It expects a condition
|
|
10
|
+
* and waits until that condition is fulfilled with a truthy value. If you use the WDIO testrunner the
|
|
11
|
+
* commands within the condition are getting executed synchronously like in your test.
|
|
12
|
+
*
|
|
13
|
+
* A common example is to wait until a certain element contains a certain text (see example).
|
|
14
|
+
*
|
|
15
|
+
* <example>
|
|
16
|
+
:example.html
|
|
17
|
+
<div id="someText">I am some text</div>
|
|
18
|
+
<script>
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
await $('#someText').html('I am now different');
|
|
21
|
+
}, 1000);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
:waitUntil.js
|
|
25
|
+
it('should wait until text has changed', async () => {
|
|
26
|
+
await browser.waitUntil(
|
|
27
|
+
async () => (await $('#someText').getText()) === 'I am now different',
|
|
28
|
+
{
|
|
29
|
+
timeout: 5000,
|
|
30
|
+
timeoutMsg: 'expected text to be different after 5s'
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
* </example>
|
|
35
|
+
*
|
|
36
|
+
*
|
|
37
|
+
* @alias browser.waitUntil
|
|
38
|
+
* @param {Function#Boolean} condition condition to wait on
|
|
39
|
+
* @param {WaitUntilOptions=} options command options
|
|
40
|
+
* @param {Number=} options.timeout timeout in ms (default: 5000)
|
|
41
|
+
* @param {String=} options.timeoutMsg error message to throw when waitUntil times out
|
|
42
|
+
* @param {Number=} options.interval interval between condition checks (default: 500)
|
|
43
|
+
* @return {Boolean} true if condition is fulfilled
|
|
44
|
+
* @uses utility/pause
|
|
45
|
+
* @type utility
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
function waitUntil(condition, { timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, timeoutMsg } = {}) {
|
|
49
|
+
if (typeof condition !== 'function') {
|
|
50
|
+
throw new Error('Condition is not a function');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ensure that timeout and interval are set properly
|
|
54
|
+
*/
|
|
55
|
+
if (typeof timeout !== 'number') {
|
|
56
|
+
timeout = this.options.waitforTimeout;
|
|
57
|
+
}
|
|
58
|
+
if (typeof interval !== 'number') {
|
|
59
|
+
interval = this.options.waitforInterval;
|
|
60
|
+
}
|
|
61
|
+
const fn = condition.bind(this);
|
|
62
|
+
let timer = new Timer_1.default(interval, timeout, fn, true);
|
|
63
|
+
return timer.catch((e) => {
|
|
64
|
+
if (e.message === 'timeout') {
|
|
65
|
+
if (typeof timeoutMsg === 'string') {
|
|
66
|
+
throw new Error(timeoutMsg);
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`waitUntil condition timed out after ${timeout}ms`);
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`waitUntil condition failed with the following reason: ${(e && e.message) || e}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.default = waitUntil;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import $$ from './browser/$$';
|
|
2
|
+
import $ from './browser/$';
|
|
3
|
+
import call from './browser/call';
|
|
4
|
+
import custom$$ from './browser/custom$$';
|
|
5
|
+
import custom$ from './browser/custom$';
|
|
6
|
+
import debug from './browser/debug';
|
|
7
|
+
import deleteCookies from './browser/deleteCookies';
|
|
8
|
+
import execute from './browser/execute';
|
|
9
|
+
import executeAsync from './browser/executeAsync';
|
|
10
|
+
import getCookies from './browser/getCookies';
|
|
11
|
+
import getPuppeteer from './browser/getPuppeteer';
|
|
12
|
+
import getWindowSize from './browser/getWindowSize';
|
|
13
|
+
import keys from './browser/keys';
|
|
14
|
+
import mock from './browser/mock';
|
|
15
|
+
import mockClearAll from './browser/mockClearAll';
|
|
16
|
+
import mockRestoreAll from './browser/mockRestoreAll';
|
|
17
|
+
import newWindow from './browser/newWindow';
|
|
18
|
+
import pause from './browser/pause';
|
|
19
|
+
import react$$ from './browser/react$$';
|
|
20
|
+
import react$ from './browser/react$';
|
|
21
|
+
import reloadSession from './browser/reloadSession';
|
|
22
|
+
import savePDF from './browser/savePDF';
|
|
23
|
+
import saveRecordingScreen from './browser/saveRecordingScreen';
|
|
24
|
+
import saveScreenshot from './browser/saveScreenshot';
|
|
25
|
+
import setCookies from './browser/setCookies';
|
|
26
|
+
import setTimeout from './browser/setTimeout';
|
|
27
|
+
import setWindowSize from './browser/setWindowSize';
|
|
28
|
+
import switchWindow from './browser/switchWindow';
|
|
29
|
+
import throttle from './browser/throttle';
|
|
30
|
+
import touchAction from './browser/touchAction';
|
|
31
|
+
import uploadFile from './browser/uploadFile';
|
|
32
|
+
import url from './browser/url';
|
|
33
|
+
import waitUntil from './browser/waitUntil';
|
|
34
|
+
declare const _default: {
|
|
35
|
+
$$: typeof $$;
|
|
36
|
+
$: typeof $;
|
|
37
|
+
call: typeof call;
|
|
38
|
+
custom$$: typeof custom$$;
|
|
39
|
+
custom$: typeof custom$;
|
|
40
|
+
debug: typeof debug;
|
|
41
|
+
deleteCookies: typeof deleteCookies;
|
|
42
|
+
execute: typeof execute;
|
|
43
|
+
executeAsync: typeof executeAsync;
|
|
44
|
+
getCookies: typeof getCookies;
|
|
45
|
+
getPuppeteer: typeof getPuppeteer;
|
|
46
|
+
getWindowSize: typeof getWindowSize;
|
|
47
|
+
keys: typeof keys;
|
|
48
|
+
mock: typeof mock;
|
|
49
|
+
mockClearAll: typeof mockClearAll;
|
|
50
|
+
mockRestoreAll: typeof mockRestoreAll;
|
|
51
|
+
newWindow: typeof newWindow;
|
|
52
|
+
pause: typeof pause;
|
|
53
|
+
react$$: typeof react$$;
|
|
54
|
+
react$: typeof react$;
|
|
55
|
+
reloadSession: typeof reloadSession;
|
|
56
|
+
savePDF: typeof savePDF;
|
|
57
|
+
saveRecordingScreen: typeof saveRecordingScreen;
|
|
58
|
+
saveScreenshot: typeof saveScreenshot;
|
|
59
|
+
setCookies: typeof setCookies;
|
|
60
|
+
setTimeout: typeof setTimeout;
|
|
61
|
+
setWindowSize: typeof setWindowSize;
|
|
62
|
+
switchWindow: typeof switchWindow;
|
|
63
|
+
throttle: typeof throttle;
|
|
64
|
+
touchAction: typeof touchAction;
|
|
65
|
+
uploadFile: typeof uploadFile;
|
|
66
|
+
url: typeof url;
|
|
67
|
+
waitUntil: typeof waitUntil;
|
|
68
|
+
};
|
|
69
|
+
export default _default;
|
|
70
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7B,OAAO,CAAC,MAAM,aAAa,CAAA;AAC3B,OAAO,IAAI,MAAM,gBAAgB,CAAA;AACjC,OAAO,QAAQ,MAAM,oBAAoB,CAAA;AACzC,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,UAAU,MAAM,sBAAsB,CAAA;AAC7C,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,IAAI,MAAM,gBAAgB,CAAA;AACjC,OAAO,IAAI,MAAM,gBAAgB,CAAA;AACjC,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,cAAc,MAAM,0BAA0B,CAAA;AACrD,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,MAAM,MAAM,kBAAkB,CAAA;AACrC,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,mBAAmB,MAAM,+BAA+B,CAAA;AAC/D,OAAO,cAAc,MAAM,0BAA0B,CAAA;AACrD,OAAO,UAAU,MAAM,sBAAsB,CAAA;AAC7C,OAAO,UAAU,MAAM,sBAAsB,CAAA;AAC7C,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,YAAY,MAAM,wBAAwB,CAAA;AACjD,OAAO,QAAQ,MAAM,oBAAoB,CAAA;AACzC,OAAO,WAAW,MAAM,uBAAuB,CAAA;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAA;AAC7C,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,SAAS,MAAM,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,wBAKC"}
|