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,160 @@
|
|
|
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
|
+
exports.MultiRemoteDriver = void 0;
|
|
7
|
+
const lodash_zip_1 = __importDefault(require("lodash.zip"));
|
|
8
|
+
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
9
|
+
const utils_1 = require("@wdio/utils");
|
|
10
|
+
const middlewares_1 = require("./middlewares");
|
|
11
|
+
const utils_2 = require("./utils");
|
|
12
|
+
/**
|
|
13
|
+
* Multiremote class
|
|
14
|
+
*/
|
|
15
|
+
class MultiRemote {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.instances = {};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* add instance to multibrowser instance
|
|
21
|
+
*/
|
|
22
|
+
async addInstance(browserName, client) {
|
|
23
|
+
this.instances[browserName] = await client;
|
|
24
|
+
return this.instances[browserName];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* modifier for multibrowser instance
|
|
28
|
+
*/
|
|
29
|
+
modifier(wrapperClient) {
|
|
30
|
+
const propertiesObject = {};
|
|
31
|
+
propertiesObject.commandList = { value: wrapperClient.commandList };
|
|
32
|
+
propertiesObject.options = { value: wrapperClient.options };
|
|
33
|
+
for (const commandName of wrapperClient.commandList) {
|
|
34
|
+
propertiesObject[commandName] = {
|
|
35
|
+
value: this.commandWrapper(commandName),
|
|
36
|
+
configurable: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
propertiesObject['__propertiesObject__'] = {
|
|
40
|
+
value: propertiesObject
|
|
41
|
+
};
|
|
42
|
+
this.baseInstance = new MultiRemoteDriver(this.instances, propertiesObject);
|
|
43
|
+
const client = Object.create(this.baseInstance, propertiesObject);
|
|
44
|
+
/**
|
|
45
|
+
* attach instances to wrapper client
|
|
46
|
+
*/
|
|
47
|
+
for (const [identifier, instance] of Object.entries(this.instances)) {
|
|
48
|
+
client[identifier] = instance;
|
|
49
|
+
}
|
|
50
|
+
return client;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* helper method to generate element objects from results, so that we can call, e.g.
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
* const elem = $('#elem')
|
|
57
|
+
* elem.getHTML()
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* or in case multiremote is used
|
|
61
|
+
*
|
|
62
|
+
* ```
|
|
63
|
+
* const elems = $$('div')
|
|
64
|
+
* elems[0].getHTML()
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
static elementWrapper(instances, result, propertiesObject, scope) {
|
|
68
|
+
const prototype = { ...propertiesObject, ...(0, lodash_clonedeep_1.default)((0, utils_2.getPrototype)('element')), scope: { value: 'element' } };
|
|
69
|
+
const element = (0, utils_1.webdriverMonad)({}, (client) => {
|
|
70
|
+
/**
|
|
71
|
+
* attach instances to wrapper client
|
|
72
|
+
*/
|
|
73
|
+
for (const [i, identifier] of Object.entries(Object.keys(instances))) {
|
|
74
|
+
client[identifier] = result[i];
|
|
75
|
+
}
|
|
76
|
+
client.instances = Object.keys(instances);
|
|
77
|
+
client.isMultiremote = true;
|
|
78
|
+
client.selector = result[0] ? result[0].selector : null;
|
|
79
|
+
delete client.sessionId;
|
|
80
|
+
return client;
|
|
81
|
+
}, prototype);
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
return element(this.sessionId, (0, middlewares_1.multiremoteHandler)(scope.commandWrapper.bind(scope)));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* handle commands for multiremote instances
|
|
87
|
+
*/
|
|
88
|
+
commandWrapper(commandName) {
|
|
89
|
+
const instances = this.instances;
|
|
90
|
+
const self = this;
|
|
91
|
+
return (0, utils_1.wrapCommand)(commandName, async function (...args) {
|
|
92
|
+
const mElem = this;
|
|
93
|
+
const scope = this.selector
|
|
94
|
+
? Object.entries(mElem.instances.reduce((ins, instanceName) => ({ ...ins, [instanceName]: mElem[instanceName] }), {}))
|
|
95
|
+
: Object.entries(instances);
|
|
96
|
+
const result = await Promise.all(scope.map(
|
|
97
|
+
// @ts-expect-error
|
|
98
|
+
([, instance]) => instance[commandName](...args)));
|
|
99
|
+
/**
|
|
100
|
+
* return element object to call commands directly
|
|
101
|
+
*/
|
|
102
|
+
if (commandName === '$') {
|
|
103
|
+
const elem = MultiRemote.elementWrapper(instances, result, this.__propertiesObject__, self);
|
|
104
|
+
return elem;
|
|
105
|
+
}
|
|
106
|
+
else if (commandName === '$$') {
|
|
107
|
+
const zippedResult = (0, lodash_zip_1.default)(...result);
|
|
108
|
+
return zippedResult.map((singleResult) => MultiRemote.elementWrapper(instances, singleResult, this.__propertiesObject__, self));
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.default = MultiRemote;
|
|
115
|
+
/**
|
|
116
|
+
* event listener class that propagates events to sub drivers
|
|
117
|
+
*/
|
|
118
|
+
/* istanbul ignore next */
|
|
119
|
+
class MultiRemoteDriver {
|
|
120
|
+
constructor(instances, propertiesObject) {
|
|
121
|
+
this.isMultiremote = true;
|
|
122
|
+
this.instances = Object.keys(instances);
|
|
123
|
+
this.__propertiesObject__ = propertiesObject;
|
|
124
|
+
}
|
|
125
|
+
on(eventName, emitter) {
|
|
126
|
+
this.instances.forEach((instanceName) => this[instanceName].on(eventName, emitter));
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
once(eventName, emitter) {
|
|
130
|
+
this.instances.forEach((instanceName) => this[instanceName].once(eventName, emitter));
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
emit(eventName, emitter) {
|
|
134
|
+
return this.instances.map((instanceName) => this[instanceName].emit(eventName, emitter)).some(Boolean);
|
|
135
|
+
}
|
|
136
|
+
eventNames() {
|
|
137
|
+
return this.instances.map((instanceName) => this[instanceName].eventNames()); // special behavior of event methods for multiremote
|
|
138
|
+
}
|
|
139
|
+
getMaxListeners() {
|
|
140
|
+
return this.instances.map((instanceName) => this[instanceName].getMaxListeners()); // special behavior of event methods for multiremote
|
|
141
|
+
}
|
|
142
|
+
listenerCount(eventName) {
|
|
143
|
+
return this.instances.map((instanceName) => this[instanceName].listenerCount(eventName)); // special behavior of event methods for multiremote
|
|
144
|
+
}
|
|
145
|
+
listeners(eventName) {
|
|
146
|
+
return this.instances.map((instanceName) => this[instanceName].listeners(eventName)).reduce((prev, cur) => {
|
|
147
|
+
prev.concat(cur);
|
|
148
|
+
return prev;
|
|
149
|
+
}, []);
|
|
150
|
+
}
|
|
151
|
+
removeListener(eventName, emitter) {
|
|
152
|
+
this.instances.forEach((instanceName) => this[instanceName].removeListener(eventName, emitter));
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
removeAllListeners(eventName) {
|
|
156
|
+
this.instances.forEach((instanceName) => this[instanceName].removeAllListeners(eventName));
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.MultiRemoteDriver = MultiRemoteDriver;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Options } from '@wdio/types';
|
|
2
|
+
import type { AttachOptions } from 'webdriver';
|
|
3
|
+
/**
|
|
4
|
+
* create `browser` object with capabilities and environment flags before session is started
|
|
5
|
+
* so that Mocha/Jasmine users can filter their specs based on flags or use capabilities in test titles
|
|
6
|
+
*/
|
|
7
|
+
export default class ProtocolStub {
|
|
8
|
+
static newSession(options: Options.WebDriver): Promise<Record<string, any>>;
|
|
9
|
+
/**
|
|
10
|
+
* added just in case user wants to somehow reload webdriver or devtools session
|
|
11
|
+
* before it was started.
|
|
12
|
+
*/
|
|
13
|
+
static reloadSession(): void;
|
|
14
|
+
static attachToSession(options: AttachOptions, modifier?: (...args: any[]) => any): Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=protocol-stub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-stub.d.ts","sourceRoot":"","sources":["../src/protocol-stub.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,OAAO,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAO9C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;WAChB,UAAU,CAAE,OAAO,EAAE,OAAO,CAAC,SAAS;IAanD;;;OAGG;IACH,MAAM,CAAC,aAAa;IAIpB,MAAM,CAAC,eAAe,CAClB,OAAO,EAAE,aAAa,EACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;CAazC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@wdio/utils");
|
|
4
|
+
/**
|
|
5
|
+
* these commands can be used outside test scope and may be used accidentally by user before browser session is started
|
|
6
|
+
*/
|
|
7
|
+
const WARN_ON_COMMANDS = ['addCommand', 'overwriteCommand'];
|
|
8
|
+
/**
|
|
9
|
+
* create `browser` object with capabilities and environment flags before session is started
|
|
10
|
+
* so that Mocha/Jasmine users can filter their specs based on flags or use capabilities in test titles
|
|
11
|
+
*/
|
|
12
|
+
class ProtocolStub {
|
|
13
|
+
static async newSession(options) {
|
|
14
|
+
const capabilities = emulateSessionCapabilities((options.capabilities || {}));
|
|
15
|
+
const browser = addCommands({
|
|
16
|
+
capabilities,
|
|
17
|
+
...(0, utils_1.capabilitiesEnvironmentDetector)(capabilities, options._automationProtocol || 'webdriver')
|
|
18
|
+
});
|
|
19
|
+
return browser;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* added just in case user wants to somehow reload webdriver or devtools session
|
|
23
|
+
* before it was started.
|
|
24
|
+
*/
|
|
25
|
+
static reloadSession() {
|
|
26
|
+
throw new Error('Protocol Stub: Make sure to start webdriver or devtools session before reloading it.');
|
|
27
|
+
}
|
|
28
|
+
static attachToSession(options, modifier) {
|
|
29
|
+
if (options || !modifier) {
|
|
30
|
+
return ProtocolStub.newSession(options);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* MultiRemote
|
|
34
|
+
*/
|
|
35
|
+
return addCommands(modifier({
|
|
36
|
+
commandList: []
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = ProtocolStub;
|
|
41
|
+
/**
|
|
42
|
+
* provide better visibility to users that want to add / overwrite commands
|
|
43
|
+
* before session is started
|
|
44
|
+
* @param {object} browser
|
|
45
|
+
*/
|
|
46
|
+
function addCommands(browser) {
|
|
47
|
+
WARN_ON_COMMANDS.forEach((commandName) => {
|
|
48
|
+
browser[commandName] = commandNotAvailable(commandName);
|
|
49
|
+
});
|
|
50
|
+
return browser;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* transform capabilities provided by user to look like
|
|
54
|
+
* capabilities returned by WebDriver
|
|
55
|
+
* @param {object} caps user defined capabilities
|
|
56
|
+
* @return {object}
|
|
57
|
+
*/
|
|
58
|
+
function emulateSessionCapabilities(caps) {
|
|
59
|
+
const capabilities = {};
|
|
60
|
+
// remove appium vendor prefix from capabilities
|
|
61
|
+
Object.entries(caps).forEach(([key, value]) => {
|
|
62
|
+
const newKey = key.replace('appium:', '');
|
|
63
|
+
capabilities[newKey] = value;
|
|
64
|
+
});
|
|
65
|
+
// isChrome
|
|
66
|
+
if (caps.browserName && caps.browserName.toLowerCase() === 'chrome') {
|
|
67
|
+
capabilities.chrome = true;
|
|
68
|
+
}
|
|
69
|
+
return capabilities;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* warn user to avoid usage of command before browser session is started.
|
|
73
|
+
* @param {string} commandName
|
|
74
|
+
*/
|
|
75
|
+
function commandNotAvailable(commandName) {
|
|
76
|
+
return () => { throw new Error(`Unable to use '${commandName}' before browser session is started.`); };
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get HTML of selector element
|
|
3
|
+
*
|
|
4
|
+
* @param {String} element element to get HTML from
|
|
5
|
+
* @param {Boolean} includeSelectorTag if true, selector tag gets included (uses outerHTML)
|
|
6
|
+
* @return {String} html source
|
|
7
|
+
*/
|
|
8
|
+
export default function getHTML(element: HTMLElement, includeSelectorTag: boolean): string;
|
|
9
|
+
//# sourceMappingURL=getHTML.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHTML.d.ts","sourceRoot":"","sources":["../../src/scripts/getHTML.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,UAEjF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* get HTML of selector element
|
|
4
|
+
*
|
|
5
|
+
* @param {String} element element to get HTML from
|
|
6
|
+
* @param {Boolean} includeSelectorTag if true, selector tag gets included (uses outerHTML)
|
|
7
|
+
* @return {String} html source
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
function getHTML(element, includeSelectorTag) {
|
|
11
|
+
return element[includeSelectorTag ? 'outerHTML' : 'innerHTML'];
|
|
12
|
+
}
|
|
13
|
+
exports.default = getHTML;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get property from element
|
|
3
|
+
* @param {String} element element with requested property
|
|
4
|
+
* @param {String} property requested property
|
|
5
|
+
* @return {String} the value of the property
|
|
6
|
+
*/
|
|
7
|
+
export default function getProperty(element: HTMLElement, property: keyof HTMLElement): string | number | boolean | HTMLElement | Element | ChildNode | ParentNode | (() => DOMRect) | Document | ((event: Event) => boolean) | ((this: GlobalEventHandlers, ev: UIEvent) => any) | ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: FocusEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: DragEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | OnErrorEventHandler | ((this: GlobalEventHandlers, ev: FocusEvent) => any) | ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: MouseEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: PointerEvent) => any) | ((this: GlobalEventHandlers, ev: ProgressEvent<EventTarget>) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: UIEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: TouchEvent) => any) | ((this: GlobalEventHandlers, ev: TouchEvent) => any) | ((this: GlobalEventHandlers, ev: TouchEvent) => any) | ((this: GlobalEventHandlers, ev: TouchEvent) => any) | ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: Event) => any) | ((this: GlobalEventHandlers, ev: WheelEvent) => any) | (() => ElementInternals) | (() => void) | {
|
|
8
|
+
<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
9
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
10
|
+
} | {
|
|
11
|
+
<K_1 extends keyof HTMLElementEventMap>(type: K_1, listener: (this: HTMLElement, ev: HTMLElementEventMap[K_1]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
12
|
+
(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
13
|
+
} | NamedNodeMap | DOMTokenList | ((this: Element, ev: Event) => any) | ((this: Element, ev: Event) => any) | ShadowRoot | ((init: ShadowRootInit) => ShadowRoot) | {
|
|
14
|
+
<K_2 extends keyof HTMLElementTagNameMap>(selector: K_2): HTMLElementTagNameMap[K_2] | null;
|
|
15
|
+
<K_3 extends keyof SVGElementTagNameMap>(selector: K_3): SVGElementTagNameMap[K_3] | null;
|
|
16
|
+
<E extends Element = Element>(selectors: string): E | null;
|
|
17
|
+
} | ((qualifiedName: string) => string | null) | ((namespace: string | null, localName: string) => string | null) | (() => string[]) | ((qualifiedName: string) => Attr | null) | ((namespace: string | null, localName: string) => Attr | null) | (() => DOMRectList) | ((classNames: string) => HTMLCollectionOf<Element>) | {
|
|
18
|
+
<K_4 extends keyof HTMLElementTagNameMap>(qualifiedName: K_4): HTMLCollectionOf<HTMLElementTagNameMap[K_4]>;
|
|
19
|
+
<K_5 extends keyof SVGElementTagNameMap>(qualifiedName: K_5): HTMLCollectionOf<SVGElementTagNameMap[K_5]>;
|
|
20
|
+
(qualifiedName: string): HTMLCollectionOf<Element>;
|
|
21
|
+
} | {
|
|
22
|
+
(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
|
|
23
|
+
(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
|
|
24
|
+
(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
|
|
25
|
+
} | ((qualifiedName: string) => boolean) | ((namespace: string | null, localName: string) => boolean) | (() => boolean) | ((pointerId: number) => boolean) | ((where: InsertPosition, element: Element) => Element | null) | ((position: InsertPosition, text: string) => void) | ((where: InsertPosition, data: string) => void) | ((selectors: string) => boolean) | ((pointerId: number) => void) | ((qualifiedName: string) => void) | ((namespace: string | null, localName: string) => void) | ((attr: Attr) => Attr) | ((options?: FullscreenOptions | undefined) => Promise<void>) | (() => void) | {
|
|
26
|
+
(options?: ScrollToOptions | undefined): void;
|
|
27
|
+
(x: number, y: number): void;
|
|
28
|
+
} | {
|
|
29
|
+
(options?: ScrollToOptions | undefined): void;
|
|
30
|
+
(x: number, y: number): void;
|
|
31
|
+
} | ((arg?: boolean | ScrollIntoViewOptions | undefined) => void) | {
|
|
32
|
+
(options?: ScrollToOptions | undefined): void;
|
|
33
|
+
(x: number, y: number): void;
|
|
34
|
+
} | ((qualifiedName: string, value: string) => void) | ((namespace: string | null, qualifiedName: string, value: string) => void) | ((attr: Attr) => Attr | null) | ((attr: Attr) => Attr | null) | ((pointerId: number) => void) | ((qualifiedName: string, force?: boolean | undefined) => boolean) | ((selectors: string) => boolean) | NodeListOf<ChildNode> | (<T extends Node>(node: T) => T) | ((deep?: boolean | undefined) => Node) | ((other: Node) => number) | ((other: Node | null) => boolean) | ((options?: GetRootNodeOptions | undefined) => Node) | (() => boolean) | (<T_1 extends Node>(node: T_1, child: Node | null) => T_1) | ((namespace: string | null) => boolean) | ((otherNode: Node | null) => boolean) | ((otherNode: Node | null) => boolean) | ((prefix: string | null) => string | null) | ((namespace: string | null) => string | null) | (() => void) | (<T_2 extends Node>(child: T_2) => T_2) | (<T_3 extends Node>(node: Node, child: T_3) => T_3) | ((keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions | undefined) => Animation) | ((options?: GetAnimationsOptions | undefined) => Animation[]) | ((...nodes: (string | Node)[]) => void) | ((...nodes: (string | Node)[]) => void) | (() => void) | ((...nodes: (string | Node)[]) => void) | HTMLCollection | ((...nodes: (string | Node)[]) => void) | ((...nodes: (string | Node)[]) => void) | {
|
|
35
|
+
<K_6 extends keyof HTMLElementTagNameMap>(selectors: K_6): HTMLElementTagNameMap[K_6] | null;
|
|
36
|
+
<K_7 extends keyof SVGElementTagNameMap>(selectors: K_7): SVGElementTagNameMap[K_7] | null;
|
|
37
|
+
<E_1 extends Element = Element>(selectors: string): E_1 | null;
|
|
38
|
+
} | {
|
|
39
|
+
<K_8 extends keyof HTMLElementTagNameMap>(selectors: K_8): NodeListOf<HTMLElementTagNameMap[K_8]>;
|
|
40
|
+
<K_9 extends keyof SVGElementTagNameMap>(selectors: K_9): NodeListOf<SVGElementTagNameMap[K_9]>;
|
|
41
|
+
<E_2 extends Element = Element>(selectors: string): NodeListOf<E_2>;
|
|
42
|
+
} | ((...nodes: (string | Node)[]) => void) | HTMLSlotElement | ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | ((this: DocumentAndElementEventHandlers, ev: ClipboardEvent) => any) | CSSStyleDeclaration | DOMStringMap | (() => void) | ((options?: FocusOptions | undefined) => void) | undefined;
|
|
43
|
+
//# sourceMappingURL=getProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getProperty.d.ts","sourceRoot":"","sources":["../../src/scripts/getProperty.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oYAErF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* get property from element
|
|
5
|
+
* @param {String} element element with requested property
|
|
6
|
+
* @param {String} property requested property
|
|
7
|
+
* @return {String} the value of the property
|
|
8
|
+
*/
|
|
9
|
+
function getProperty(element, property) {
|
|
10
|
+
return element[property];
|
|
11
|
+
}
|
|
12
|
+
exports.default = getProperty;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check if element is within the viewport or is overlapped by another element or disabled
|
|
3
|
+
* @param {HTMLElement} elem element to check
|
|
4
|
+
* @return {Boolean} false if element is not overlapped
|
|
5
|
+
*/
|
|
6
|
+
export default function isElementClickable(elem: HTMLElement): boolean;
|
|
7
|
+
//# sourceMappingURL=isElementClickable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isElementClickable.d.ts","sourceRoot":"","sources":["../../src/scripts/isElementClickable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,IAAI,EAAE,WAAW,WA4I5D"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* check if element is within the viewport or is overlapped by another element or disabled
|
|
5
|
+
* @param {HTMLElement} elem element to check
|
|
6
|
+
* @return {Boolean} false if element is not overlapped
|
|
7
|
+
*/
|
|
8
|
+
function isElementClickable(elem) {
|
|
9
|
+
if (!elem.getBoundingClientRect || !elem.scrollIntoView || !elem.contains || !elem.getClientRects || !document.elementFromPoint) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// Edge before switching to Chromium
|
|
13
|
+
const isOldEdge = !!window.StyleMedia;
|
|
14
|
+
// returns true for Chrome and Firefox and false for Safari, Edge and IE
|
|
15
|
+
const scrollIntoViewFullSupport = !(window.safari || isOldEdge);
|
|
16
|
+
// get overlapping element
|
|
17
|
+
function getOverlappingElement(elem, context) {
|
|
18
|
+
context = context || document;
|
|
19
|
+
const elemDimension = elem.getBoundingClientRect();
|
|
20
|
+
const x = elemDimension.left + (elem.clientWidth / 2);
|
|
21
|
+
const y = elemDimension.top + (elem.clientHeight / 2);
|
|
22
|
+
return context.elementFromPoint(x, y);
|
|
23
|
+
}
|
|
24
|
+
// get overlapping element rects (currently only the first)
|
|
25
|
+
// applicable if element's text is multiline.
|
|
26
|
+
function getOverlappingRects(elem, context) {
|
|
27
|
+
context = context || document;
|
|
28
|
+
const elems = [];
|
|
29
|
+
const rects = elem.getClientRects();
|
|
30
|
+
// webdriver clicks on center of the first element's rect (line of text), it might change in future
|
|
31
|
+
const rect = rects[0];
|
|
32
|
+
const x = rect.left + (rect.width / 2);
|
|
33
|
+
const y = rect.top + (rect.height / 2);
|
|
34
|
+
elems.push(context.elementFromPoint(x, y));
|
|
35
|
+
return elems;
|
|
36
|
+
}
|
|
37
|
+
// get overlapping elements
|
|
38
|
+
function getOverlappingElements(elem, context) {
|
|
39
|
+
return [getOverlappingElement(elem, context)].concat(getOverlappingRects(elem, context));
|
|
40
|
+
}
|
|
41
|
+
// is a node a descendant of a given node
|
|
42
|
+
function nodeContains(elem, otherNode) {
|
|
43
|
+
// Edge doesn't support neither Shadow Dom nor contains if ShadowRoot polyfill is used
|
|
44
|
+
if (isOldEdge) {
|
|
45
|
+
let tmpElement = otherNode;
|
|
46
|
+
while (tmpElement) {
|
|
47
|
+
if (tmpElement === elem) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
tmpElement = tmpElement.parentNode;
|
|
51
|
+
// DocumentFragment / ShadowRoot polyfill like ShadyRoot
|
|
52
|
+
if (tmpElement && tmpElement.nodeType === 11 && tmpElement.host) {
|
|
53
|
+
tmpElement = tmpElement.host;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return elem.contains(otherNode);
|
|
59
|
+
}
|
|
60
|
+
// is one of overlapping elements the `elem` or one of its child
|
|
61
|
+
function isOverlappingElementMatch(elementsFromPoint, elem) {
|
|
62
|
+
if (elementsFromPoint.some(function (elementFromPoint) {
|
|
63
|
+
return elementFromPoint === elem || nodeContains(elem, elementFromPoint);
|
|
64
|
+
})) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// shadow root
|
|
68
|
+
// filter unique elements with shadowRoot
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
let elemsWithShadowRoot = [].concat(elementsFromPoint);
|
|
71
|
+
elemsWithShadowRoot = elemsWithShadowRoot.filter(function (x) {
|
|
72
|
+
return x && x.shadowRoot && x.shadowRoot.elementFromPoint;
|
|
73
|
+
});
|
|
74
|
+
// getOverlappingElements of every element with shadowRoot
|
|
75
|
+
let shadowElementsFromPoint = [];
|
|
76
|
+
for (let i = 0; i < elemsWithShadowRoot.length; ++i) {
|
|
77
|
+
let shadowElement = elemsWithShadowRoot[i];
|
|
78
|
+
shadowElementsFromPoint = shadowElementsFromPoint.concat(getOverlappingElements(elem, shadowElement.shadowRoot));
|
|
79
|
+
}
|
|
80
|
+
// remove duplicates and parents
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
shadowElementsFromPoint = [].concat(shadowElementsFromPoint);
|
|
83
|
+
shadowElementsFromPoint = shadowElementsFromPoint.filter(function (x) {
|
|
84
|
+
return !elementsFromPoint.includes(x);
|
|
85
|
+
});
|
|
86
|
+
if (shadowElementsFromPoint.length === 0) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return isOverlappingElementMatch(shadowElementsFromPoint, elem);
|
|
90
|
+
}
|
|
91
|
+
// copied from `isElementInViewport.js`
|
|
92
|
+
function isElementInViewport(elem) {
|
|
93
|
+
if (!elem.getBoundingClientRect) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const rect = elem.getBoundingClientRect();
|
|
97
|
+
const windowHeight = (window.innerHeight || document.documentElement.clientHeight);
|
|
98
|
+
const windowWidth = (window.innerWidth || document.documentElement.clientWidth);
|
|
99
|
+
const vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) > 0);
|
|
100
|
+
const horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) > 0);
|
|
101
|
+
return (vertInView && horInView);
|
|
102
|
+
}
|
|
103
|
+
function isClickable(elem) {
|
|
104
|
+
return (isElementInViewport(elem) && elem.disabled !== true &&
|
|
105
|
+
isOverlappingElementMatch(getOverlappingElements(elem), elem));
|
|
106
|
+
}
|
|
107
|
+
// scroll to the element if it's not clickable
|
|
108
|
+
if (!isClickable(elem)) {
|
|
109
|
+
// works well in dialogs, but the element may be still overlapped by some sticky header/footer
|
|
110
|
+
elem.scrollIntoView(scrollIntoViewFullSupport ? { block: 'nearest', inline: 'nearest' } : false);
|
|
111
|
+
// if element is still not clickable take another scroll attempt
|
|
112
|
+
if (!isClickable(elem)) {
|
|
113
|
+
// scroll to element, try put it in the screen center.
|
|
114
|
+
// Should definitely work even if element was covered with sticky header/footer
|
|
115
|
+
elem.scrollIntoView(scrollIntoViewFullSupport ? { block: 'center', inline: 'center' } : true);
|
|
116
|
+
return isClickable(elem);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
exports.default = isElementClickable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check if element is visible
|
|
3
|
+
* @param {HTMLElement} elem element to check
|
|
4
|
+
* @return {Boolean} true if element is within viewport
|
|
5
|
+
*/
|
|
6
|
+
export default function isElementDisplayed(element: Element): boolean;
|
|
7
|
+
//# sourceMappingURL=isElementDisplayed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isElementDisplayed.d.ts","sourceRoot":"","sources":["../../src/scripts/isElementDisplayed.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAsOrE"}
|