webdriverio 7.17.0 → 7.18.0
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 +287 -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 +11 -11
|
@@ -0,0 +1,134 @@
|
|
|
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 logger_1 = __importDefault(require("@wdio/logger"));
|
|
7
|
+
const log = (0, logger_1.default)('webdriverio/click');
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Click on an element.
|
|
11
|
+
*
|
|
12
|
+
* Note: This issues a WebDriver `click` command for the selected element, which generally scrolls to and then clicks the
|
|
13
|
+
* selected element. However, if you have fixed-position elements (such as a fixed header or footer) that cover up the
|
|
14
|
+
* selected element after it is scrolled within the viewport, the click will be issued at the given coordinates, but will
|
|
15
|
+
* be received by your fixed (overlaying) element. In these cased the following error is thrown:
|
|
16
|
+
*
|
|
17
|
+
* ```
|
|
18
|
+
* Element is not clickable at point (x, x). Other element would receive the click: ..."
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* To work around this, try to find the overlaying element and remove it via `execute` command so it doesn't interfere
|
|
22
|
+
* the click. You also can try to scroll to the element yourself using `scroll` with an offset appropriate for your
|
|
23
|
+
* scenario.
|
|
24
|
+
*
|
|
25
|
+
* <example>
|
|
26
|
+
:example.html
|
|
27
|
+
<button id="myButton" onclick="document.getElementById('someText').innerHTML='I was clicked'">Click me</button>
|
|
28
|
+
<div id="someText">I was not clicked</div>
|
|
29
|
+
:click.js
|
|
30
|
+
it('should demonstrate the click command', async () => {
|
|
31
|
+
const myButton = await $('#myButton')
|
|
32
|
+
await myButton.click()
|
|
33
|
+
const myText = await $('#someText')
|
|
34
|
+
const text = await myText.getText()
|
|
35
|
+
assert(text === 'I was clicked') // true
|
|
36
|
+
})
|
|
37
|
+
:example.js
|
|
38
|
+
it('should fetch menu links and visit each page', async () => {
|
|
39
|
+
const links = await $$('#menu a')
|
|
40
|
+
await links.forEach(async (link) => {
|
|
41
|
+
await link.click()
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
* </example>
|
|
45
|
+
*
|
|
46
|
+
* <example>
|
|
47
|
+
:example.html
|
|
48
|
+
<button id="myButton">Click me</button>
|
|
49
|
+
:example.js
|
|
50
|
+
it('should demonstrate a click using an offset', async () => {
|
|
51
|
+
const myButton = await $('#myButton')
|
|
52
|
+
await myButton.click({ x: 30 }) // clicks 30 horizontal pixels away from location of the button (from center point of element)
|
|
53
|
+
})
|
|
54
|
+
* </example>
|
|
55
|
+
*
|
|
56
|
+
* <example>
|
|
57
|
+
:example.html
|
|
58
|
+
<button id="myButton">Click me</button>
|
|
59
|
+
:example.js
|
|
60
|
+
it('should demonstrate a right click passed as string', async () => {
|
|
61
|
+
const myButton = await $('#myButton')
|
|
62
|
+
await myButton.click({ button: 'right' }) // opens the contextmenu at the location of the button
|
|
63
|
+
})
|
|
64
|
+
it('should demonstrate a right click passed as number while adding an offset', async () => {
|
|
65
|
+
const myButton = await $('#myButton')
|
|
66
|
+
await myButton.click({ button: 2, x: 30, y: 40 }) // opens the contextmenu 30 horizontal and 40 vertical pixels away from location of the button (from the center of element)
|
|
67
|
+
})
|
|
68
|
+
* </example>
|
|
69
|
+
*
|
|
70
|
+
* @alias element.click
|
|
71
|
+
* @uses protocol/element, protocol/elementIdClick, protocol/performActions, protocol/positionClick
|
|
72
|
+
* @type action
|
|
73
|
+
* @param {ClickOptions=} options click options (optional)
|
|
74
|
+
* @param {string= | number=} options.button can be one of [0, "left", 1, "middle", 2, "right"] (optional)
|
|
75
|
+
* @param {number=} options.x Number (optional)
|
|
76
|
+
* @param {number=} options.y Number (optional)
|
|
77
|
+
*/
|
|
78
|
+
async function click(options) {
|
|
79
|
+
if (typeof options === 'undefined') {
|
|
80
|
+
return this.elementClick(this.elementId);
|
|
81
|
+
}
|
|
82
|
+
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
83
|
+
throw new TypeError('Options must be an object');
|
|
84
|
+
}
|
|
85
|
+
let { button = 0, x: xoffset = 0, y: yoffset = 0 } = options || {};
|
|
86
|
+
if (typeof xoffset !== 'number'
|
|
87
|
+
|| typeof yoffset !== 'number'
|
|
88
|
+
|| !Number.isInteger(xoffset)
|
|
89
|
+
|| !Number.isInteger(yoffset)) {
|
|
90
|
+
throw new TypeError('Coordinates must be integers');
|
|
91
|
+
}
|
|
92
|
+
if (button === 'left') {
|
|
93
|
+
button = 0;
|
|
94
|
+
}
|
|
95
|
+
if (button === 'middle') {
|
|
96
|
+
button = 1;
|
|
97
|
+
}
|
|
98
|
+
if (button === 'right') {
|
|
99
|
+
button = 2;
|
|
100
|
+
}
|
|
101
|
+
if (![0, 1, 2].includes(button)) {
|
|
102
|
+
throw new Error('Button type not supported.');
|
|
103
|
+
}
|
|
104
|
+
if (this.isW3C) {
|
|
105
|
+
await this.performActions([{
|
|
106
|
+
type: 'pointer',
|
|
107
|
+
id: 'pointer1',
|
|
108
|
+
parameters: {
|
|
109
|
+
pointerType: 'mouse'
|
|
110
|
+
},
|
|
111
|
+
actions: [{
|
|
112
|
+
type: 'pointerMove',
|
|
113
|
+
origin: this,
|
|
114
|
+
x: xoffset,
|
|
115
|
+
y: yoffset
|
|
116
|
+
}, {
|
|
117
|
+
type: 'pointerDown',
|
|
118
|
+
button
|
|
119
|
+
}, {
|
|
120
|
+
type: 'pointerUp',
|
|
121
|
+
button
|
|
122
|
+
}]
|
|
123
|
+
}]);
|
|
124
|
+
const err = await this.releaseActions().then(() => null, (err) => err);
|
|
125
|
+
if (err) {
|
|
126
|
+
log.warn(`Failed to call "releaseAction" command due to: ${err.message}, ignoring!`);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const { width, height } = await this.getElementSize(this.elementId);
|
|
131
|
+
await this.moveToElement(this.elementId, xoffset + (width / 2), yoffset + (height / 2));
|
|
132
|
+
return this.positionClick(button);
|
|
133
|
+
}
|
|
134
|
+
exports.default = click;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ElementArray } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* The `customs$$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
|
|
5
|
+
*
|
|
6
|
+
* <example>
|
|
7
|
+
:example.js
|
|
8
|
+
it('should get all the plugin wrapper buttons', async () => {
|
|
9
|
+
await browser.url('https://webdriver.io')
|
|
10
|
+
await browser.addLocatorStrategy('myStrat', (selector) => {
|
|
11
|
+
return document.querySelectorAll(selector)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const pluginRowBlock = await browser.custom$('myStrat', '.pluginRowBlock')
|
|
15
|
+
const pluginWrapper = await pluginRowBlock.custom$$('myStrat', '.pluginWrapper')
|
|
16
|
+
|
|
17
|
+
console.log(pluginWrapper.length) // 4
|
|
18
|
+
})
|
|
19
|
+
* </example>
|
|
20
|
+
*
|
|
21
|
+
* @alias custom$$
|
|
22
|
+
* @param {String} strategyName
|
|
23
|
+
* @param {Any} strategyArguments
|
|
24
|
+
* @return {ElementArray}
|
|
25
|
+
*/
|
|
26
|
+
declare function custom$$(this: WebdriverIO.Element, strategyName: string, strategyArguments: string): Promise<ElementArray>;
|
|
27
|
+
export default custom$$;
|
|
28
|
+
//# sourceMappingURL=custom$$.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/custom$$.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAe,QAAQ,CACnB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,GAC1B,OAAO,CAAC,YAAY,CAAC,CAgCvB;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getElementObject_1 = require("../../utils/getElementObject");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* The `customs$$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:example.js
|
|
12
|
+
it('should get all the plugin wrapper buttons', async () => {
|
|
13
|
+
await browser.url('https://webdriver.io')
|
|
14
|
+
await browser.addLocatorStrategy('myStrat', (selector) => {
|
|
15
|
+
return document.querySelectorAll(selector)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const pluginRowBlock = await browser.custom$('myStrat', '.pluginRowBlock')
|
|
19
|
+
const pluginWrapper = await pluginRowBlock.custom$$('myStrat', '.pluginWrapper')
|
|
20
|
+
|
|
21
|
+
console.log(pluginWrapper.length) // 4
|
|
22
|
+
})
|
|
23
|
+
* </example>
|
|
24
|
+
*
|
|
25
|
+
* @alias custom$$
|
|
26
|
+
* @param {String} strategyName
|
|
27
|
+
* @param {Any} strategyArguments
|
|
28
|
+
* @return {ElementArray}
|
|
29
|
+
*/
|
|
30
|
+
async function custom$$(strategyName, strategyArguments) {
|
|
31
|
+
const browserObject = (0, utils_1.getBrowserObject)(this);
|
|
32
|
+
const strategy = browserObject.strategies.get(strategyName);
|
|
33
|
+
if (!strategy) {
|
|
34
|
+
/* istanbul ignore next */
|
|
35
|
+
throw Error('No strategy found for ' + strategyName);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* fail if root element is not found, similar to:
|
|
39
|
+
* $('.notExisting').$('.someElem')
|
|
40
|
+
*/
|
|
41
|
+
if (!this.elementId) {
|
|
42
|
+
throw Error(`Can't call custom$ on element with selector "${this.selector}" because element wasn't found`);
|
|
43
|
+
}
|
|
44
|
+
let res = await this.execute(strategy, strategyArguments, this);
|
|
45
|
+
/**
|
|
46
|
+
* if the user's script return just one element
|
|
47
|
+
* then we convert it to an array as this method
|
|
48
|
+
* should return multiple elements
|
|
49
|
+
*/
|
|
50
|
+
if (!Array.isArray(res)) {
|
|
51
|
+
res = [res];
|
|
52
|
+
}
|
|
53
|
+
res = res.filter((el) => !!el && typeof el[constants_1.ELEMENT_KEY] === 'string');
|
|
54
|
+
const elements = res.length ? await getElementObject_1.getElements.call(this, strategy, res) : [];
|
|
55
|
+
return (0, utils_1.enhanceElementsArray)(elements, this, strategy, 'custom$$', [strategyArguments]);
|
|
56
|
+
}
|
|
57
|
+
exports.default = custom$$;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
|
|
4
|
+
*
|
|
5
|
+
* <example>
|
|
6
|
+
:example.js
|
|
7
|
+
it('should fetch the project title', async () => {
|
|
8
|
+
await browser.url('https://webdriver.io')
|
|
9
|
+
await browser.addLocatorStrategy('myStrat', (selector) => {
|
|
10
|
+
return document.querySelectorAll(selector)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const header = await browser.custom$('myStrat', 'header')
|
|
14
|
+
const projectTitle = await header.custom$('myStrat', '.projectTitle')
|
|
15
|
+
|
|
16
|
+
console.log(projectTitle.getText()) // WEBDRIVER I/O
|
|
17
|
+
})
|
|
18
|
+
* </example>
|
|
19
|
+
*
|
|
20
|
+
* @alias custom$
|
|
21
|
+
* @param {String} strategyName
|
|
22
|
+
* @param {Any} strategyArguments
|
|
23
|
+
* @return {Element}
|
|
24
|
+
*/
|
|
25
|
+
declare function custom$(this: WebdriverIO.Element, strategyName: string, strategyArguments: string): Promise<WebdriverIO.Element>;
|
|
26
|
+
export default custom$;
|
|
27
|
+
//# sourceMappingURL=custom$.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/custom$.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAe,OAAO,CAClB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,gCAiC5B;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getElementObject_1 = require("../../utils/getElementObject");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
|
|
9
|
+
*
|
|
10
|
+
* <example>
|
|
11
|
+
:example.js
|
|
12
|
+
it('should fetch the project title', async () => {
|
|
13
|
+
await browser.url('https://webdriver.io')
|
|
14
|
+
await browser.addLocatorStrategy('myStrat', (selector) => {
|
|
15
|
+
return document.querySelectorAll(selector)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const header = await browser.custom$('myStrat', 'header')
|
|
19
|
+
const projectTitle = await header.custom$('myStrat', '.projectTitle')
|
|
20
|
+
|
|
21
|
+
console.log(projectTitle.getText()) // WEBDRIVER I/O
|
|
22
|
+
})
|
|
23
|
+
* </example>
|
|
24
|
+
*
|
|
25
|
+
* @alias custom$
|
|
26
|
+
* @param {String} strategyName
|
|
27
|
+
* @param {Any} strategyArguments
|
|
28
|
+
* @return {Element}
|
|
29
|
+
*/
|
|
30
|
+
async function custom$(strategyName, strategyArguments) {
|
|
31
|
+
const browserObject = (0, utils_1.getBrowserObject)(this);
|
|
32
|
+
const strategy = browserObject.strategies.get(strategyName);
|
|
33
|
+
if (!strategy) {
|
|
34
|
+
throw Error('No strategy found for ' + strategyName);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* fail if root element is not found, similar to:
|
|
38
|
+
* $('.notExisting').$('.someElem')
|
|
39
|
+
*/
|
|
40
|
+
if (!this.elementId) {
|
|
41
|
+
throw Error(`Can't call custom$ on element with selector "${this.selector}" because element wasn't found`);
|
|
42
|
+
}
|
|
43
|
+
let res = await this.execute(strategy, strategyArguments, this);
|
|
44
|
+
/**
|
|
45
|
+
* if the user's script returns multiple elements
|
|
46
|
+
* then we just return the first one as this method
|
|
47
|
+
* is intended to return just one element
|
|
48
|
+
*/
|
|
49
|
+
if (Array.isArray(res)) {
|
|
50
|
+
res = res[0];
|
|
51
|
+
}
|
|
52
|
+
if (res && typeof res[constants_1.ELEMENT_KEY] === 'string') {
|
|
53
|
+
return await getElementObject_1.getElement.call(this, strategy, res);
|
|
54
|
+
}
|
|
55
|
+
throw Error('Your locator strategy script must return an element');
|
|
56
|
+
}
|
|
57
|
+
exports.default = custom$;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Double-click on an element.
|
|
4
|
+
*
|
|
5
|
+
* <example>
|
|
6
|
+
:example.html
|
|
7
|
+
<button id="myButton" ondblclick="document.getElementById('someText').innerHTML='I was dblclicked'">Click me</button>
|
|
8
|
+
<div id="someText">I was not clicked</div>
|
|
9
|
+
:doubleClick.js
|
|
10
|
+
it('should demonstrate the doubleClick command', async () => {
|
|
11
|
+
const myButton = await $('#myButton')
|
|
12
|
+
await myButton.doubleClick()
|
|
13
|
+
|
|
14
|
+
const value = await myButton.getText()
|
|
15
|
+
assert(value === 'I was dblclicked') // true
|
|
16
|
+
})
|
|
17
|
+
* </example>
|
|
18
|
+
*
|
|
19
|
+
* @alias element.doubleClick
|
|
20
|
+
* @uses protocol/element, protocol/moveTo, protocol/doDoubleClick, protocol/touchDoubleClick
|
|
21
|
+
* @type action
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export default function doubleClick(this: WebdriverIO.Element): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=doubleClick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doubleClick.d.ts","sourceRoot":"","sources":["../../../src/commands/element/doubleClick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAA8B,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,iBAyBnE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Double-click on an element.
|
|
6
|
+
*
|
|
7
|
+
* <example>
|
|
8
|
+
:example.html
|
|
9
|
+
<button id="myButton" ondblclick="document.getElementById('someText').innerHTML='I was dblclicked'">Click me</button>
|
|
10
|
+
<div id="someText">I was not clicked</div>
|
|
11
|
+
:doubleClick.js
|
|
12
|
+
it('should demonstrate the doubleClick command', async () => {
|
|
13
|
+
const myButton = await $('#myButton')
|
|
14
|
+
await myButton.doubleClick()
|
|
15
|
+
|
|
16
|
+
const value = await myButton.getText()
|
|
17
|
+
assert(value === 'I was dblclicked') // true
|
|
18
|
+
})
|
|
19
|
+
* </example>
|
|
20
|
+
*
|
|
21
|
+
* @alias element.doubleClick
|
|
22
|
+
* @uses protocol/element, protocol/moveTo, protocol/doDoubleClick, protocol/touchDoubleClick
|
|
23
|
+
* @type action
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
async function doubleClick() {
|
|
27
|
+
/**
|
|
28
|
+
* move to element
|
|
29
|
+
*/
|
|
30
|
+
if (!this.isW3C) {
|
|
31
|
+
await this.moveTo();
|
|
32
|
+
return this.positionDoubleClick();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* W3C way of handle the double click actions
|
|
36
|
+
*/
|
|
37
|
+
return this.performActions([{
|
|
38
|
+
type: 'pointer',
|
|
39
|
+
id: 'pointer1',
|
|
40
|
+
parameters: { pointerType: 'mouse' },
|
|
41
|
+
actions: [
|
|
42
|
+
{ type: 'pointerMove', origin: this, x: 0, y: 0 },
|
|
43
|
+
{ type: 'pointerDown', button: 0 },
|
|
44
|
+
{ type: 'pointerUp', button: 0 },
|
|
45
|
+
{ type: 'pause', duration: 10 },
|
|
46
|
+
{ type: 'pointerDown', button: 0 },
|
|
47
|
+
{ type: 'pointerUp', button: 0 }
|
|
48
|
+
]
|
|
49
|
+
}]);
|
|
50
|
+
}
|
|
51
|
+
exports.default = doubleClick;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare type DragAndDropOptions = {
|
|
2
|
+
duration?: number;
|
|
3
|
+
};
|
|
4
|
+
declare type ElementCoordinates = {
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Drag an item to a destination element or position.
|
|
11
|
+
*
|
|
12
|
+
* :::info
|
|
13
|
+
*
|
|
14
|
+
* The functionality of this command highly depends on the way drag and drop is
|
|
15
|
+
* implemented in your app. If you experience issues please post your example
|
|
16
|
+
* in [#4134](https://github.com/webdriverio/webdriverio/issues/4134).
|
|
17
|
+
*
|
|
18
|
+
* :::
|
|
19
|
+
*
|
|
20
|
+
* <example>
|
|
21
|
+
:example.test.js
|
|
22
|
+
it('should demonstrate the dragAndDrop command', async () => {
|
|
23
|
+
const elem = await $('#someElem')
|
|
24
|
+
const target = await $('#someTarget')
|
|
25
|
+
|
|
26
|
+
// drag and drop to other element
|
|
27
|
+
await elem.dragAndDrop(target)
|
|
28
|
+
|
|
29
|
+
// drag and drop relative from current position
|
|
30
|
+
await elem.dragAndDrop({ x: 100, y: 200 })
|
|
31
|
+
})
|
|
32
|
+
* </example>
|
|
33
|
+
*
|
|
34
|
+
* @alias element.dragAndDrop
|
|
35
|
+
* @param {Element|DragAndDropCoordinate} target destination element or object with x and y properties
|
|
36
|
+
* @param {DragAndDropOptions=} options dragAndDrop command options
|
|
37
|
+
* @param {Number=} options.duration how long the drag should take place
|
|
38
|
+
*/
|
|
39
|
+
export default function dragAndDrop(this: WebdriverIO.Element, target: WebdriverIO.Element | ElementCoordinates, { duration }?: DragAndDropOptions): Promise<void>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=dragAndDrop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dragAndDrop.d.ts","sourceRoot":"","sources":["../../../src/commands/element/dragAndDrop.ts"],"names":[],"mappings":"AAOA,aAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,aAAK,kBAAkB,GAAG;IACtB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAA8B,WAAW,CACrC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,kBAAkB,EAChD,EAAE,QAAa,EAAE,GAAE,kBAAuB,iBAyE7C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../constants");
|
|
4
|
+
const ACTION_BUTTON = 0;
|
|
5
|
+
const sleep = (time = 0) => new Promise((resolve) => setTimeout(resolve, time));
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* Drag an item to a destination element or position.
|
|
9
|
+
*
|
|
10
|
+
* :::info
|
|
11
|
+
*
|
|
12
|
+
* The functionality of this command highly depends on the way drag and drop is
|
|
13
|
+
* implemented in your app. If you experience issues please post your example
|
|
14
|
+
* in [#4134](https://github.com/webdriverio/webdriverio/issues/4134).
|
|
15
|
+
*
|
|
16
|
+
* :::
|
|
17
|
+
*
|
|
18
|
+
* <example>
|
|
19
|
+
:example.test.js
|
|
20
|
+
it('should demonstrate the dragAndDrop command', async () => {
|
|
21
|
+
const elem = await $('#someElem')
|
|
22
|
+
const target = await $('#someTarget')
|
|
23
|
+
|
|
24
|
+
// drag and drop to other element
|
|
25
|
+
await elem.dragAndDrop(target)
|
|
26
|
+
|
|
27
|
+
// drag and drop relative from current position
|
|
28
|
+
await elem.dragAndDrop({ x: 100, y: 200 })
|
|
29
|
+
})
|
|
30
|
+
* </example>
|
|
31
|
+
*
|
|
32
|
+
* @alias element.dragAndDrop
|
|
33
|
+
* @param {Element|DragAndDropCoordinate} target destination element or object with x and y properties
|
|
34
|
+
* @param {DragAndDropOptions=} options dragAndDrop command options
|
|
35
|
+
* @param {Number=} options.duration how long the drag should take place
|
|
36
|
+
*/
|
|
37
|
+
async function dragAndDrop(target, { duration = 10 } = {}) {
|
|
38
|
+
const moveToCoordinates = target;
|
|
39
|
+
const moveToElement = target;
|
|
40
|
+
/**
|
|
41
|
+
* fail if
|
|
42
|
+
*/
|
|
43
|
+
if (
|
|
44
|
+
/**
|
|
45
|
+
* no target was specified
|
|
46
|
+
*/
|
|
47
|
+
!target ||
|
|
48
|
+
(
|
|
49
|
+
/**
|
|
50
|
+
* target is not from type element
|
|
51
|
+
*/
|
|
52
|
+
target.constructor.name !== 'Element' &&
|
|
53
|
+
/**
|
|
54
|
+
* and is also not an object with x and y number parameters
|
|
55
|
+
*/
|
|
56
|
+
(typeof moveToCoordinates.x !== 'number' ||
|
|
57
|
+
typeof moveToCoordinates.y !== 'number'))) {
|
|
58
|
+
throw new Error('command dragAndDrop requires an WebdriverIO Element or and object with "x" and "y" variables as first parameter');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* allow to specify an element or an x/y vector
|
|
62
|
+
*/
|
|
63
|
+
const isMovingToElement = target.constructor.name === 'Element';
|
|
64
|
+
if (!this.isW3C) {
|
|
65
|
+
await this.moveTo();
|
|
66
|
+
await this.buttonDown(ACTION_BUTTON);
|
|
67
|
+
if (isMovingToElement) {
|
|
68
|
+
await moveToElement.moveTo();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
await this.moveToElement(null, moveToCoordinates.x, moveToCoordinates.y);
|
|
72
|
+
}
|
|
73
|
+
await sleep(duration);
|
|
74
|
+
return this.buttonUp(ACTION_BUTTON);
|
|
75
|
+
}
|
|
76
|
+
const sourceRef = { [constants_1.ELEMENT_KEY]: this[constants_1.ELEMENT_KEY] };
|
|
77
|
+
const targetRef = { [constants_1.ELEMENT_KEY]: moveToElement[constants_1.ELEMENT_KEY] };
|
|
78
|
+
const origin = sourceRef;
|
|
79
|
+
const targetOrigin = isMovingToElement ? targetRef : 'pointer';
|
|
80
|
+
const targetX = isMovingToElement ? 0 : moveToCoordinates.x;
|
|
81
|
+
const targetY = isMovingToElement ? 0 : moveToCoordinates.y;
|
|
82
|
+
/**
|
|
83
|
+
* W3C way of handle the drag and drop action
|
|
84
|
+
*/
|
|
85
|
+
return this.performActions([{
|
|
86
|
+
type: 'pointer',
|
|
87
|
+
id: 'finger1',
|
|
88
|
+
parameters: { pointerType: 'mouse' },
|
|
89
|
+
actions: [
|
|
90
|
+
{ type: 'pointerMove', duration: 0, origin, x: 0, y: 0 },
|
|
91
|
+
{ type: 'pointerDown', button: ACTION_BUTTON },
|
|
92
|
+
{ type: 'pause', duration: 10 },
|
|
93
|
+
{ type: 'pointerMove', duration, origin: targetOrigin, x: targetX, y: targetY },
|
|
94
|
+
{ type: 'pointerUp', button: ACTION_BUTTON }
|
|
95
|
+
]
|
|
96
|
+
}]).then(() => this.releaseActions());
|
|
97
|
+
}
|
|
98
|
+
exports.default = dragAndDrop;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Get an attribute from a DOM-element based on the attribute name.
|
|
4
|
+
*
|
|
5
|
+
* <example>
|
|
6
|
+
:index.html
|
|
7
|
+
<form action="/submit" method="post" class="loginForm">
|
|
8
|
+
<input type="text" name="name" placeholder="username"></input>
|
|
9
|
+
<input type="text" name="password" placeholder="password"></input>
|
|
10
|
+
<input type="submit" name="submit" value="submit"></input>
|
|
11
|
+
</form>
|
|
12
|
+
:getAttribute.js
|
|
13
|
+
it('should demonstrate the getAttribute command', async () => {
|
|
14
|
+
const form = await $('form')
|
|
15
|
+
const attr = await form.getAttribute('method')
|
|
16
|
+
console.log(attr) // outputs: "post"
|
|
17
|
+
})
|
|
18
|
+
* </example>
|
|
19
|
+
*
|
|
20
|
+
* @alias element.getAttribute
|
|
21
|
+
* @param {String} attributeName requested attribute
|
|
22
|
+
* @return {String|null} The value of the attribute, or null if it is not set on the element.
|
|
23
|
+
* @uses protocol/elements, protocol/elementIdAttribute
|
|
24
|
+
* @type property
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export default function getAttribute(this: WebdriverIO.Element, attributeName: string): Promise<string>;
|
|
28
|
+
//# sourceMappingURL=getAttribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAttribute.d.ts","sourceRoot":"","sources":["../../../src/commands/element/getAttribute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,aAAa,EAAE,MAAM,mBAGxB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Get an attribute from a DOM-element based on the attribute name.
|
|
6
|
+
*
|
|
7
|
+
* <example>
|
|
8
|
+
:index.html
|
|
9
|
+
<form action="/submit" method="post" class="loginForm">
|
|
10
|
+
<input type="text" name="name" placeholder="username"></input>
|
|
11
|
+
<input type="text" name="password" placeholder="password"></input>
|
|
12
|
+
<input type="submit" name="submit" value="submit"></input>
|
|
13
|
+
</form>
|
|
14
|
+
:getAttribute.js
|
|
15
|
+
it('should demonstrate the getAttribute command', async () => {
|
|
16
|
+
const form = await $('form')
|
|
17
|
+
const attr = await form.getAttribute('method')
|
|
18
|
+
console.log(attr) // outputs: "post"
|
|
19
|
+
})
|
|
20
|
+
* </example>
|
|
21
|
+
*
|
|
22
|
+
* @alias element.getAttribute
|
|
23
|
+
* @param {String} attributeName requested attribute
|
|
24
|
+
* @return {String|null} The value of the attribute, or null if it is not set on the element.
|
|
25
|
+
* @uses protocol/elements, protocol/elementIdAttribute
|
|
26
|
+
* @type property
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
function getAttribute(attributeName) {
|
|
30
|
+
return this.getElementAttribute(this.elementId, attributeName);
|
|
31
|
+
}
|
|
32
|
+
exports.default = getAttribute;
|