webdriverio 7.16.16 → 7.17.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/package.json +7 -7
- package/build/commands/browser/$$.d.ts +0 -50
- package/build/commands/browser/$$.d.ts.map +0 -1
- package/build/commands/browser/$$.js +0 -57
- package/build/commands/browser/$.d.ts +0 -77
- package/build/commands/browser/$.d.ts.map +0 -1
- package/build/commands/browser/$.js +0 -91
- package/build/commands/browser/addCommand.d.ts +0 -37
- package/build/commands/browser/addCommand.d.ts.map +0 -1
- package/build/commands/browser/addCommand.js +0 -37
- package/build/commands/browser/call.d.ts +0 -42
- package/build/commands/browser/call.d.ts.map +0 -1
- package/build/commands/browser/call.js +0 -49
- package/build/commands/browser/custom$$.d.ts +0 -26
- package/build/commands/browser/custom$$.d.ts.map +0 -1
- package/build/commands/browser/custom$$.js +0 -47
- package/build/commands/browser/custom$.d.ts +0 -25
- package/build/commands/browser/custom$.d.ts.map +0 -1
- package/build/commands/browser/custom$.js +0 -47
- package/build/commands/browser/debug.d.ts +0 -32
- package/build/commands/browser/debug.d.ts.map +0 -1
- package/build/commands/browser/debug.js +0 -108
- package/build/commands/browser/deleteCookies.d.ts +0 -45
- package/build/commands/browser/deleteCookies.d.ts.map +0 -1
- package/build/commands/browser/deleteCookies.js +0 -56
- package/build/commands/browser/execute.d.ts +0 -37
- package/build/commands/browser/execute.d.ts.map +0 -1
- package/build/commands/browser/execute.js +0 -55
- package/build/commands/browser/executeAsync.d.ts +0 -45
- package/build/commands/browser/executeAsync.d.ts.map +0 -1
- package/build/commands/browser/executeAsync.js +0 -63
- package/build/commands/browser/getCookies.d.ts +0 -34
- package/build/commands/browser/getCookies.d.ts.map +0 -1
- package/build/commands/browser/getCookies.js +0 -46
- package/build/commands/browser/getPuppeteer.d.ts +0 -38
- package/build/commands/browser/getPuppeteer.d.ts.map +0 -1
- package/build/commands/browser/getPuppeteer.js +0 -119
- package/build/commands/browser/getWindowSize.d.ts +0 -25
- package/build/commands/browser/getWindowSize.d.ts.map +0 -1
- package/build/commands/browser/getWindowSize.js +0 -30
- package/build/commands/browser/keys.d.ts +0 -28
- package/build/commands/browser/keys.d.ts.map +0 -1
- package/build/commands/browser/keys.js +0 -64
- package/build/commands/browser/mock.d.ts +0 -111
- package/build/commands/browser/mock.d.ts.map +0 -1
- package/build/commands/browser/mock.js +0 -164
- package/build/commands/browser/mockClearAll.d.ts +0 -28
- package/build/commands/browser/mockClearAll.d.ts.map +0 -1
- package/build/commands/browser/mockClearAll.js +0 -43
- package/build/commands/browser/mockRestoreAll.d.ts +0 -26
- package/build/commands/browser/mockRestoreAll.d.ts.map +0 -1
- package/build/commands/browser/mockRestoreAll.js +0 -41
- package/build/commands/browser/newWindow.d.ts +0 -41
- package/build/commands/browser/newWindow.d.ts.map +0 -1
- package/build/commands/browser/newWindow.js +0 -83
- package/build/commands/browser/overwriteCommand.d.ts +0 -32
- package/build/commands/browser/overwriteCommand.d.ts.map +0 -1
- package/build/commands/browser/overwriteCommand.js +0 -32
- package/build/commands/browser/pause.d.ts +0 -23
- package/build/commands/browser/pause.d.ts.map +0 -1
- package/build/commands/browser/pause.js +0 -27
- package/build/commands/browser/react$$.d.ts +0 -36
- package/build/commands/browser/react$$.d.ts.map +0 -1
- package/build/commands/browser/react$$.js +0 -51
- package/build/commands/browser/react$.d.ts +0 -46
- package/build/commands/browser/react$.d.ts.map +0 -1
- package/build/commands/browser/react$.js +0 -59
- package/build/commands/browser/reloadSession.d.ts +0 -23
- package/build/commands/browser/reloadSession.d.ts.map +0 -1
- package/build/commands/browser/reloadSession.js +0 -58
- package/build/commands/browser/savePDF.d.ts +0 -46
- package/build/commands/browser/savePDF.d.ts.map +0 -1
- package/build/commands/browser/savePDF.js +0 -51
- package/build/commands/browser/saveRecordingScreen.d.ts +0 -28
- package/build/commands/browser/saveRecordingScreen.d.ts.map +0 -1
- package/build/commands/browser/saveRecordingScreen.js +0 -47
- package/build/commands/browser/saveScreenshot.d.ts +0 -22
- package/build/commands/browser/saveScreenshot.d.ts.map +0 -1
- package/build/commands/browser/saveScreenshot.js +0 -41
- package/build/commands/browser/setCookies.d.ts +0 -57
- package/build/commands/browser/setCookies.d.ts.map +0 -1
- package/build/commands/browser/setCookies.js +0 -66
- package/build/commands/browser/setTimeout.d.ts +0 -31
- package/build/commands/browser/setTimeout.d.ts.map +0 -1
- package/build/commands/browser/setTimeout.js +0 -61
- package/build/commands/browser/setWindowSize.d.ts +0 -20
- package/build/commands/browser/setWindowSize.d.ts.map +0 -1
- package/build/commands/browser/setWindowSize.js +0 -43
- package/build/commands/browser/switchWindow.d.ts +0 -30
- package/build/commands/browser/switchWindow.d.ts.map +0 -1
- package/build/commands/browser/switchWindow.js +0 -73
- package/build/commands/browser/throttle.d.ts +0 -3
- package/build/commands/browser/throttle.d.ts.map +0 -1
- package/build/commands/browser/throttle.js +0 -144
- package/build/commands/browser/touchAction.d.ts +0 -61
- package/build/commands/browser/touchAction.d.ts.map +0 -1
- package/build/commands/browser/touchAction.js +0 -65
- package/build/commands/browser/uploadFile.d.ts +0 -32
- package/build/commands/browser/uploadFile.d.ts.map +0 -1
- package/build/commands/browser/uploadFile.js +0 -63
- package/build/commands/browser/url.d.ts +0 -38
- package/build/commands/browser/url.d.ts.map +0 -1
- package/build/commands/browser/url.js +0 -49
- package/build/commands/browser/waitUntil.d.ts +0 -44
- package/build/commands/browser/waitUntil.d.ts.map +0 -1
- package/build/commands/browser/waitUntil.js +0 -73
- package/build/commands/browser.d.ts +0 -70
- package/build/commands/browser.d.ts.map +0 -1
- package/build/commands/browser.js +0 -44
- package/build/commands/constant.d.ts +0 -19
- package/build/commands/constant.d.ts.map +0 -1
- package/build/commands/constant.js +0 -91
- package/build/commands/element/$$.d.ts +0 -46
- package/build/commands/element/$$.d.ts.map +0 -1
- package/build/commands/element/$$.js +0 -50
- package/build/commands/element/$.d.ts +0 -72
- package/build/commands/element/$.d.ts.map +0 -1
- package/build/commands/element/$.js +0 -76
- package/build/commands/element/addValue.d.ts +0 -33
- package/build/commands/element/addValue.d.ts.map +0 -1
- package/build/commands/element/addValue.js +0 -48
- package/build/commands/element/clearValue.d.ts +0 -28
- package/build/commands/element/clearValue.d.ts.map +0 -1
- package/build/commands/element/clearValue.js +0 -32
- package/build/commands/element/click.d.ts +0 -73
- package/build/commands/element/click.d.ts.map +0 -1
- package/build/commands/element/click.js +0 -134
- package/build/commands/element/custom$$.d.ts +0 -28
- package/build/commands/element/custom$$.d.ts.map +0 -1
- package/build/commands/element/custom$$.js +0 -57
- package/build/commands/element/custom$.d.ts +0 -27
- package/build/commands/element/custom$.d.ts.map +0 -1
- package/build/commands/element/custom$.js +0 -57
- package/build/commands/element/doubleClick.d.ts +0 -25
- package/build/commands/element/doubleClick.d.ts.map +0 -1
- package/build/commands/element/doubleClick.js +0 -51
- package/build/commands/element/dragAndDrop.d.ts +0 -41
- package/build/commands/element/dragAndDrop.d.ts.map +0 -1
- package/build/commands/element/dragAndDrop.js +0 -98
- package/build/commands/element/getAttribute.d.ts +0 -28
- package/build/commands/element/getAttribute.d.ts.map +0 -1
- package/build/commands/element/getAttribute.js +0 -32
- package/build/commands/element/getCSSProperty.d.ts +0 -71
- package/build/commands/element/getCSSProperty.d.ts.map +0 -1
- package/build/commands/element/getCSSProperty.js +0 -108
- package/build/commands/element/getComputedLabel.d.ts +0 -20
- package/build/commands/element/getComputedLabel.d.ts.map +0 -1
- package/build/commands/element/getComputedLabel.js +0 -24
- package/build/commands/element/getComputedRole.d.ts +0 -20
- package/build/commands/element/getComputedRole.d.ts.map +0 -1
- package/build/commands/element/getComputedRole.js +0 -24
- package/build/commands/element/getHTML.d.ts +0 -32
- package/build/commands/element/getHTML.d.ts.map +0 -1
- package/build/commands/element/getHTML.js +0 -46
- package/build/commands/element/getLocation.d.ts +0 -6
- package/build/commands/element/getLocation.d.ts.map +0 -1
- package/build/commands/element/getLocation.js +0 -46
- package/build/commands/element/getProperty.d.ts +0 -53
- package/build/commands/element/getProperty.d.ts.map +0 -1
- package/build/commands/element/getProperty.js +0 -31
- package/build/commands/element/getSize.d.ts +0 -6
- package/build/commands/element/getSize.d.ts.map +0 -1
- package/build/commands/element/getSize.js +0 -47
- package/build/commands/element/getTagName.d.ts +0 -25
- package/build/commands/element/getTagName.d.ts.map +0 -1
- package/build/commands/element/getTagName.js +0 -29
- package/build/commands/element/getText.d.ts +0 -42
- package/build/commands/element/getText.d.ts.map +0 -1
- package/build/commands/element/getText.js +0 -46
- package/build/commands/element/getValue.d.ts +0 -25
- package/build/commands/element/getValue.d.ts.map +0 -1
- package/build/commands/element/getValue.js +0 -33
- package/build/commands/element/isClickable.d.ts +0 -40
- package/build/commands/element/isClickable.d.ts.map +0 -1
- package/build/commands/element/isClickable.js +0 -57
- package/build/commands/element/isDisplayed.d.ts +0 -50
- package/build/commands/element/isDisplayed.d.ts.map +0 -1
- package/build/commands/element/isDisplayed.js +0 -85
- package/build/commands/element/isDisplayedInViewport.d.ts +0 -38
- package/build/commands/element/isDisplayedInViewport.d.ts.map +0 -1
- package/build/commands/element/isDisplayedInViewport.js +0 -55
- package/build/commands/element/isEnabled.d.ts +0 -34
- package/build/commands/element/isEnabled.d.ts.map +0 -1
- package/build/commands/element/isEnabled.js +0 -38
- package/build/commands/element/isEqual.d.ts +0 -24
- package/build/commands/element/isEqual.d.ts.map +0 -1
- package/build/commands/element/isEqual.js +0 -52
- package/build/commands/element/isExisting.d.ts +0 -49
- package/build/commands/element/isExisting.d.ts.map +0 -1
- package/build/commands/element/isExisting.js +0 -65
- package/build/commands/element/isFocused.d.ts +0 -28
- package/build/commands/element/isFocused.d.ts.map +0 -1
- package/build/commands/element/isFocused.js +0 -42
- package/build/commands/element/isSelected.d.ts +0 -31
- package/build/commands/element/isSelected.d.ts.map +0 -1
- package/build/commands/element/isSelected.js +0 -35
- package/build/commands/element/moveTo.d.ts +0 -21
- package/build/commands/element/moveTo.d.ts.map +0 -1
- package/build/commands/element/moveTo.js +0 -39
- package/build/commands/element/nextElement.d.ts +0 -25
- package/build/commands/element/nextElement.d.ts.map +0 -1
- package/build/commands/element/nextElement.js +0 -31
- package/build/commands/element/parentElement.d.ts +0 -25
- package/build/commands/element/parentElement.d.ts.map +0 -1
- package/build/commands/element/parentElement.js +0 -31
- package/build/commands/element/previousElement.d.ts +0 -25
- package/build/commands/element/previousElement.d.ts.map +0 -1
- package/build/commands/element/previousElement.js +0 -31
- package/build/commands/element/react$$.d.ts +0 -36
- package/build/commands/element/react$$.d.ts.map +0 -1
- package/build/commands/element/react$$.js +0 -51
- package/build/commands/element/react$.d.ts +0 -46
- package/build/commands/element/react$.d.ts.map +0 -1
- package/build/commands/element/react$.js +0 -59
- package/build/commands/element/saveScreenshot.d.ts +0 -21
- package/build/commands/element/saveScreenshot.d.ts.map +0 -1
- package/build/commands/element/saveScreenshot.js +0 -40
- package/build/commands/element/scrollIntoView.d.ts +0 -21
- package/build/commands/element/scrollIntoView.d.ts.map +0 -1
- package/build/commands/element/scrollIntoView.js +0 -31
- package/build/commands/element/selectByAttribute.d.ts +0 -37
- package/build/commands/element/selectByAttribute.d.ts.map +0 -1
- package/build/commands/element/selectByAttribute.js +0 -59
- package/build/commands/element/selectByIndex.d.ts +0 -31
- package/build/commands/element/selectByIndex.d.ts.map +0 -1
- package/build/commands/element/selectByIndex.js +0 -55
- package/build/commands/element/selectByVisibleText.d.ts +0 -31
- package/build/commands/element/selectByVisibleText.d.ts.map +0 -1
- package/build/commands/element/selectByVisibleText.js +0 -66
- package/build/commands/element/setValue.d.ts +0 -29
- package/build/commands/element/setValue.d.ts.map +0 -1
- package/build/commands/element/setValue.js +0 -33
- package/build/commands/element/shadow$$.d.ts +0 -22
- package/build/commands/element/shadow$$.d.ts.map +0 -1
- package/build/commands/element/shadow$$.js +0 -27
- package/build/commands/element/shadow$.d.ts +0 -22
- package/build/commands/element/shadow$.d.ts.map +0 -1
- package/build/commands/element/shadow$.js +0 -27
- package/build/commands/element/touchAction.d.ts +0 -54
- package/build/commands/element/touchAction.d.ts.map +0 -1
- package/build/commands/element/touchAction.js +0 -58
- package/build/commands/element/waitForClickable.d.ts +0 -34
- package/build/commands/element/waitForClickable.d.ts.map +0 -1
- package/build/commands/element/waitForClickable.js +0 -37
- package/build/commands/element/waitForDisplayed.d.ts +0 -44
- package/build/commands/element/waitForDisplayed.d.ts.map +0 -1
- package/build/commands/element/waitForDisplayed.js +0 -47
- package/build/commands/element/waitForEnabled.d.ts +0 -46
- package/build/commands/element/waitForEnabled.d.ts.map +0 -1
- package/build/commands/element/waitForEnabled.js +0 -55
- package/build/commands/element/waitForExist.d.ts +0 -46
- package/build/commands/element/waitForExist.d.ts.map +0 -1
- package/build/commands/element/waitForExist.js +0 -49
- package/build/commands/element/waitUntil.d.ts +0 -49
- package/build/commands/element/waitUntil.d.ts.map +0 -1
- package/build/commands/element/waitUntil.js +0 -53
- package/build/commands/element.d.ts +0 -100
- package/build/commands/element.d.ts.map +0 -1
- package/build/commands/element.js +0 -63
- package/build/commands/mock/abort.d.ts +0 -19
- package/build/commands/mock/abort.d.ts.map +0 -1
- package/build/commands/mock/abort.js +0 -20
- package/build/commands/mock/abortOnce.d.ts +0 -27
- package/build/commands/mock/abortOnce.d.ts.map +0 -1
- package/build/commands/mock/abortOnce.js +0 -28
- package/build/commands/mock/clear.d.ts +0 -18
- package/build/commands/mock/clear.d.ts.map +0 -1
- package/build/commands/mock/clear.js +0 -19
- package/build/commands/mock/respond.d.ts +0 -54
- package/build/commands/mock/respond.d.ts.map +0 -1
- package/build/commands/mock/respond.js +0 -55
- package/build/commands/mock/respondOnce.d.ts +0 -55
- package/build/commands/mock/respondOnce.d.ts.map +0 -1
- package/build/commands/mock/respondOnce.js +0 -56
- package/build/commands/mock/restore.d.ts +0 -18
- package/build/commands/mock/restore.d.ts.map +0 -1
- package/build/commands/mock/restore.js +0 -19
- package/build/constants.d.ts +0 -14
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -286
- package/build/index.d.ts +0 -45
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -171
- package/build/middlewares.d.ts +0 -12
- package/build/middlewares.d.ts.map +0 -1
- package/build/middlewares.js +0 -65
- package/build/multiremote.d.ts +0 -71
- package/build/multiremote.d.ts.map +0 -1
- package/build/multiremote.js +0 -160
- package/build/protocol-stub.d.ts +0 -16
- package/build/protocol-stub.d.ts.map +0 -1
- package/build/protocol-stub.js +0 -77
- package/build/scripts/getHTML.d.ts +0 -9
- package/build/scripts/getHTML.d.ts.map +0 -1
- package/build/scripts/getHTML.js +0 -13
- package/build/scripts/getProperty.d.ts +0 -43
- package/build/scripts/getProperty.d.ts.map +0 -1
- package/build/scripts/getProperty.js +0 -12
- package/build/scripts/isElementClickable.d.ts +0 -7
- package/build/scripts/isElementClickable.d.ts.map +0 -1
- package/build/scripts/isElementClickable.js +0 -121
- package/build/scripts/isElementDisplayed.d.ts +0 -7
- package/build/scripts/isElementDisplayed.d.ts.map +0 -1
- package/build/scripts/isElementDisplayed.js +0 -216
- package/build/scripts/isElementInViewport.d.ts +0 -10
- package/build/scripts/isElementInViewport.d.ts.map +0 -1
- package/build/scripts/isElementInViewport.js +0 -22
- package/build/scripts/isFocused.d.ts +0 -7
- package/build/scripts/isFocused.d.ts.map +0 -1
- package/build/scripts/isFocused.js +0 -11
- package/build/scripts/newWindow.d.ts +0 -10
- package/build/scripts/newWindow.d.ts.map +0 -1
- package/build/scripts/newWindow.js +0 -14
- package/build/scripts/resq.d.ts +0 -6
- package/build/scripts/resq.d.ts.map +0 -1
- package/build/scripts/resq.js +0 -58
- package/build/scripts/shadowFnFactory.d.ts +0 -2
- package/build/scripts/shadowFnFactory.d.ts.map +0 -1
- package/build/scripts/shadowFnFactory.js +0 -17
- package/build/types.d.ts +0 -402
- package/build/types.d.ts.map +0 -1
- package/build/types.js +0 -2
- package/build/utils/SevereServiceError.d.ts +0 -7
- package/build/utils/SevereServiceError.d.ts.map +0 -1
- package/build/utils/SevereServiceError.js +0 -12
- package/build/utils/Timer.d.ts +0 -33
- package/build/utils/Timer.d.ts.map +0 -1
- package/build/utils/Timer.js +0 -126
- package/build/utils/detectBackend.d.ts +0 -23
- package/build/utils/detectBackend.d.ts.map +0 -1
- package/build/utils/detectBackend.js +0 -119
- package/build/utils/findStrategy.d.ts +0 -10
- package/build/utils/findStrategy.d.ts.map +0 -1
- package/build/utils/findStrategy.js +0 -267
- package/build/utils/getElementObject.d.ts +0 -17
- package/build/utils/getElementObject.d.ts.map +0 -1
- package/build/utils/getElementObject.js +0 -107
- package/build/utils/implicitWait.d.ts +0 -7
- package/build/utils/implicitWait.d.ts.map +0 -1
- package/build/utils/implicitWait.js +0 -39
- package/build/utils/index.d.ts +0 -102
- package/build/utils/index.d.ts.map +0 -1
- package/build/utils/index.js +0 -543
- package/build/utils/interception/devtools.d.ts +0 -61
- package/build/utils/interception/devtools.d.ts.map +0 -1
- package/build/utils/interception/devtools.js +0 -247
- package/build/utils/interception/index.d.ts +0 -26
- package/build/utils/interception/index.d.ts.map +0 -1
- package/build/utils/interception/index.js +0 -49
- package/build/utils/interception/types.d.ts +0 -94
- package/build/utils/interception/types.d.ts.map +0 -1
- package/build/utils/interception/types.js +0 -2
- package/build/utils/interception/webdriver.d.ts +0 -48
- package/build/utils/interception/webdriver.d.ts.map +0 -1
- package/build/utils/interception/webdriver.js +0 -75
- package/build/utils/refetchElement.d.ts +0 -6
- package/build/utils/refetchElement.d.ts.map +0 -1
- package/build/utils/refetchElement.js +0 -32
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DEFAULT_HOSTNAME = '127.0.0.1';
|
|
4
|
-
const DEFAULT_PORT = 4444;
|
|
5
|
-
const DEFAULT_PROTOCOL = 'http';
|
|
6
|
-
const DEFAULT_PATH = '/';
|
|
7
|
-
const LEGACY_PATH = '/wd/hub';
|
|
8
|
-
const REGION_MAPPING = {
|
|
9
|
-
'us': 'us-west-1.',
|
|
10
|
-
'eu': 'eu-central-1.',
|
|
11
|
-
'eu-central-1': 'eu-central-1.',
|
|
12
|
-
'us-east-1': 'us-east-1.',
|
|
13
|
-
'apac': 'apac-southeast-1.',
|
|
14
|
-
'apac-southeast-1': 'apac-southeast-1',
|
|
15
|
-
};
|
|
16
|
-
function getSauceEndpoint(region, { isRDC, isVisual } = {}) {
|
|
17
|
-
const shortRegion = REGION_MAPPING[region] ? region : 'us';
|
|
18
|
-
if (isRDC) {
|
|
19
|
-
return `${shortRegion}1.appium.testobject.com`;
|
|
20
|
-
}
|
|
21
|
-
else if (isVisual) {
|
|
22
|
-
return 'hub.screener.io';
|
|
23
|
-
}
|
|
24
|
-
return `ondemand.${REGION_MAPPING[shortRegion]}saucelabs.com`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* helper to detect the Selenium backend according to given capabilities
|
|
28
|
-
*/
|
|
29
|
-
function detectBackend(options = {}) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
let { port, hostname, user, key, protocol, region, headless, path, capabilities } = options;
|
|
32
|
-
/**
|
|
33
|
-
* browserstack
|
|
34
|
-
* e.g. zHcv9sZ39ip8ZPsxBVJ2
|
|
35
|
-
*/
|
|
36
|
-
if (typeof user === 'string' && typeof key === 'string' && key.length === 20) {
|
|
37
|
-
return {
|
|
38
|
-
protocol: protocol || 'https',
|
|
39
|
-
hostname: hostname || 'hub-cloud.browserstack.com',
|
|
40
|
-
port: port || 443,
|
|
41
|
-
path: path || LEGACY_PATH
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* testingbot
|
|
46
|
-
* e.g. ec337d7b677720a4dde7bd72be0bfc67
|
|
47
|
-
*/
|
|
48
|
-
if (typeof user === 'string' && typeof key === 'string' && key.length === 32) {
|
|
49
|
-
return {
|
|
50
|
-
protocol: protocol || 'https',
|
|
51
|
-
hostname: hostname || 'hub.testingbot.com',
|
|
52
|
-
port: port || 443,
|
|
53
|
-
path: path || LEGACY_PATH
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sauce Labs
|
|
58
|
-
* e.g. 50aa152c-1932-B2f0-9707-18z46q2n1mb0
|
|
59
|
-
*
|
|
60
|
-
* For Sauce Labs Legacy RDC we only need to determine if the sauce option has a `testobject_api_key`.
|
|
61
|
-
* Same for Sauce Visual where an apiKey can be passed in through the capabilities (soon to be legacy too).
|
|
62
|
-
*/
|
|
63
|
-
const isRDC = Boolean(!Array.isArray(capabilities) && ((_a = capabilities) === null || _a === void 0 ? void 0 : _a.testobject_api_key));
|
|
64
|
-
const isVisual = Boolean(!Array.isArray(capabilities) && capabilities && ((_b = capabilities['sauce:visual']) === null || _b === void 0 ? void 0 : _b.apiKey));
|
|
65
|
-
if ((typeof user === 'string' && typeof key === 'string' && key.length === 36) ||
|
|
66
|
-
// Or only RDC or visual
|
|
67
|
-
(isRDC || isVisual)) {
|
|
68
|
-
// Sauce headless is currently only in us-east-1
|
|
69
|
-
const sauceRegion = headless ? 'us-east-1' : region;
|
|
70
|
-
return {
|
|
71
|
-
protocol: protocol || 'https',
|
|
72
|
-
hostname: hostname || getSauceEndpoint(sauceRegion, { isRDC, isVisual }),
|
|
73
|
-
port: port || 443,
|
|
74
|
-
path: path || LEGACY_PATH
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Lambdatest
|
|
79
|
-
* e.g. cYAjKrqGwyPjPQv41ICDF4C5OjlxzA9epZsnugVJJxqOReWRWU
|
|
80
|
-
*/
|
|
81
|
-
if (typeof user === 'string' && typeof key === 'string' && key.length === 50) {
|
|
82
|
-
return {
|
|
83
|
-
protocol: protocol || DEFAULT_PROTOCOL,
|
|
84
|
-
hostname: hostname || 'hub.lambdatest.com',
|
|
85
|
-
port: port || 80,
|
|
86
|
-
path: path || LEGACY_PATH
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (
|
|
90
|
-
/**
|
|
91
|
-
* user and key are set in config
|
|
92
|
-
*/
|
|
93
|
-
(typeof user === 'string' || typeof key === 'string') &&
|
|
94
|
-
/**
|
|
95
|
-
* but no custom WebDriver endpoint was configured
|
|
96
|
-
*/
|
|
97
|
-
!hostname) {
|
|
98
|
-
throw new Error('A "user" or "key" was provided but could not be connected to a ' +
|
|
99
|
-
'known cloud service (Sauce Labs, Browerstack, Testingbot or Lambdatest). ' +
|
|
100
|
-
'Please check if given user and key properties are correct!');
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* default values if on of the WebDriver criticial options is set
|
|
104
|
-
*/
|
|
105
|
-
if (hostname || port || protocol || path) {
|
|
106
|
-
return {
|
|
107
|
-
hostname: hostname || DEFAULT_HOSTNAME,
|
|
108
|
-
port: port || DEFAULT_PORT,
|
|
109
|
-
protocol: protocol || DEFAULT_PROTOCOL,
|
|
110
|
-
path: path || DEFAULT_PATH
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* no cloud provider detected, pass on provided params and eventually
|
|
115
|
-
* fallback to DevTools protocol
|
|
116
|
-
*/
|
|
117
|
-
return { hostname, port, protocol, path };
|
|
118
|
-
}
|
|
119
|
-
exports.default = detectBackend;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare type SelectorStrategy = string | {
|
|
2
|
-
name: string;
|
|
3
|
-
args: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const findStrategy: (selector: SelectorStrategy, isW3C?: boolean | undefined, isMobile?: boolean | undefined) => {
|
|
6
|
-
using: string;
|
|
7
|
-
value: string;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=findStrategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findStrategy.d.ts","sourceRoot":"","sources":["../../src/utils/findStrategy.ts"],"names":[],"mappings":"AA4BA,aAAK,gBAAgB,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAuF/D,eAAO,MAAM,YAAY,aAAuB,gBAAgB;;;CAoI/D,CAAA"}
|
|
@@ -1,267 +0,0 @@
|
|
|
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.findStrategy = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
|
|
9
|
-
const aria_query_1 = require("aria-query");
|
|
10
|
-
const constants_1 = require("../constants");
|
|
11
|
-
const DEFAULT_STRATEGY = 'css selector';
|
|
12
|
-
const DIRECT_SELECTOR_REGEXP = /^(id|css selector|xpath|link text|partial link text|name|tag name|class name|-android uiautomator|-android datamatcher|-android viewmatcher|-android viewtag|-ios uiautomation|-ios predicate string|-ios class chain|accessibility id):(.+)/;
|
|
13
|
-
const XPATH_SELECTORS_START = [
|
|
14
|
-
'/', '(', '../', './', '*/'
|
|
15
|
-
];
|
|
16
|
-
const NAME_MOBILE_SELECTORS_START = [
|
|
17
|
-
'uia', 'xcuielementtype', 'android.widget', 'cyi', 'android.view'
|
|
18
|
-
];
|
|
19
|
-
const XPATH_SELECTOR_REGEXP = [
|
|
20
|
-
// HTML tag
|
|
21
|
-
/^([a-z0-9|-]*)/,
|
|
22
|
-
// optional . or # + class or id
|
|
23
|
-
/(?:(\.|#)(-?[_a-zA-Z]+[_a-zA-Z0-9-]*))?/,
|
|
24
|
-
// optional [attribute-name="attribute-selector"]
|
|
25
|
-
/(?:\[(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)(?:=(?:"|')([a-zA-z0-9\-_. ]+)(?:"|'))?\])?/,
|
|
26
|
-
// *=query or =query
|
|
27
|
-
/(\*)?=(.+)$/,
|
|
28
|
-
];
|
|
29
|
-
const IMAGEPATH_MOBILE_SELECTORS_ENDSWITH = [
|
|
30
|
-
'.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg'
|
|
31
|
-
];
|
|
32
|
-
const defineStrategy = function (selector) {
|
|
33
|
-
// Condition with checking isPlainObject(selector) should be first because
|
|
34
|
-
// in case of "selector" argument is a plain object then .match() will cause
|
|
35
|
-
// an error like "selector.match is not a function"
|
|
36
|
-
// Use '-android datamatcher' or '-android viewmatcher' strategy if selector is a plain object (Android only)
|
|
37
|
-
if ((0, lodash_isplainobject_1.default)(selector)) {
|
|
38
|
-
if (JSON.stringify(selector).indexOf('test.espresso.matcher.ViewMatchers') < 0)
|
|
39
|
-
return '-android datamatcher';
|
|
40
|
-
return '-android viewmatcher';
|
|
41
|
-
}
|
|
42
|
-
const stringSelector = selector;
|
|
43
|
-
// Check if user has specified locator strategy directly
|
|
44
|
-
if (stringSelector.match(DIRECT_SELECTOR_REGEXP)) {
|
|
45
|
-
return 'directly';
|
|
46
|
-
}
|
|
47
|
-
// Use appium image strategy if selector ends with certain text(.jpg,.gif..)
|
|
48
|
-
if (IMAGEPATH_MOBILE_SELECTORS_ENDSWITH.some(path => {
|
|
49
|
-
const selector = stringSelector.toLowerCase();
|
|
50
|
-
return selector.endsWith(path) && selector !== path;
|
|
51
|
-
})) {
|
|
52
|
-
return '-image';
|
|
53
|
-
}
|
|
54
|
-
// Use xPath strategy if selector starts with //
|
|
55
|
-
if (XPATH_SELECTORS_START.some(option => stringSelector.startsWith(option))) {
|
|
56
|
-
return 'xpath';
|
|
57
|
-
}
|
|
58
|
-
// Use link text strategy if selector starts with =
|
|
59
|
-
if (stringSelector.startsWith('=')) {
|
|
60
|
-
return 'link text';
|
|
61
|
-
}
|
|
62
|
-
// Use partial link text strategy if selector starts with *=
|
|
63
|
-
if (stringSelector.startsWith('*=')) {
|
|
64
|
-
return 'partial link text';
|
|
65
|
-
}
|
|
66
|
-
// Use id strategy if the selector starts with id=
|
|
67
|
-
if (stringSelector.startsWith('id=')) {
|
|
68
|
-
return 'id';
|
|
69
|
-
}
|
|
70
|
-
// use shadow dom selector
|
|
71
|
-
if (stringSelector.startsWith(constants_1.DEEP_SELECTOR)) {
|
|
72
|
-
return 'shadow';
|
|
73
|
-
}
|
|
74
|
-
// Recursive element search using the UiAutomator library (Android only)
|
|
75
|
-
if (stringSelector.startsWith('android=')) {
|
|
76
|
-
return '-android uiautomator';
|
|
77
|
-
}
|
|
78
|
-
// Recursive element search using the UIAutomation library (iOS-only)
|
|
79
|
-
if (stringSelector.startsWith('ios=')) {
|
|
80
|
-
return '-ios uiautomation';
|
|
81
|
-
}
|
|
82
|
-
// Recursive element search using accessibility id
|
|
83
|
-
if (stringSelector.startsWith('~')) {
|
|
84
|
-
return 'accessibility id';
|
|
85
|
-
}
|
|
86
|
-
// Class name mobile selector
|
|
87
|
-
// for iOS = UIA...
|
|
88
|
-
// for Android = android.widget
|
|
89
|
-
if (NAME_MOBILE_SELECTORS_START.some(option => stringSelector.toLowerCase().startsWith(option))) {
|
|
90
|
-
return 'class name';
|
|
91
|
-
}
|
|
92
|
-
// Use tag name strategy if selector contains a tag
|
|
93
|
-
// e.g. "<div>" or "<div />"
|
|
94
|
-
if (stringSelector.search(/<[0-9a-zA-Z-]+( \/)*>/g) >= 0) {
|
|
95
|
-
return 'tag name';
|
|
96
|
-
}
|
|
97
|
-
// Use name strategy if selector queries elements with name attributes for JSONWP
|
|
98
|
-
// or if isMobile is used even when w3c is used
|
|
99
|
-
// e.g. "[name='myName']" or '[name="myName"]'
|
|
100
|
-
if (stringSelector.search(/^\[name=("|')([a-zA-z0-9\-_.@=[\] ']+)("|')]$/) >= 0) {
|
|
101
|
-
return 'name';
|
|
102
|
-
}
|
|
103
|
-
// Allow to move up to the parent or select current element
|
|
104
|
-
if (selector === '..' || selector === '.') {
|
|
105
|
-
return 'xpath';
|
|
106
|
-
}
|
|
107
|
-
// Any element with given class, id, or attribute and content
|
|
108
|
-
// e.g. h1.header=Welcome or [data-name=table-row]=Item or #content*=Intro
|
|
109
|
-
if (stringSelector.match(new RegExp(XPATH_SELECTOR_REGEXP.map(rx => rx.source).join('')))) {
|
|
110
|
-
return 'xpath extended';
|
|
111
|
-
}
|
|
112
|
-
if (stringSelector.match(/^\[role=[A-Za-z]+]$/)) {
|
|
113
|
-
return 'role';
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const findStrategy = function (selector, isW3C, isMobile) {
|
|
117
|
-
const stringSelector = selector;
|
|
118
|
-
let using = DEFAULT_STRATEGY;
|
|
119
|
-
let value = selector;
|
|
120
|
-
switch (defineStrategy(selector)) {
|
|
121
|
-
// user has specified locator strategy directly
|
|
122
|
-
case 'directly': {
|
|
123
|
-
const match = stringSelector.match(DIRECT_SELECTOR_REGEXP);
|
|
124
|
-
if (!match || !isMobile && isW3C && !constants_1.W3C_SELECTOR_STRATEGIES.includes(match[1])) {
|
|
125
|
-
throw new Error('InvalidSelectorStrategy'); // ToDo: move error to wdio-error package
|
|
126
|
-
}
|
|
127
|
-
using = match[1];
|
|
128
|
-
value = match[2];
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case 'xpath': {
|
|
132
|
-
using = 'xpath';
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case 'id': {
|
|
136
|
-
using = 'id';
|
|
137
|
-
value = stringSelector.slice(3);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case 'link text': {
|
|
141
|
-
using = 'link text';
|
|
142
|
-
value = stringSelector.slice(1);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
case 'partial link text': {
|
|
146
|
-
using = 'partial link text';
|
|
147
|
-
value = stringSelector.slice(2);
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
case 'shadow':
|
|
151
|
-
using = 'shadow';
|
|
152
|
-
value = stringSelector.slice(constants_1.DEEP_SELECTOR.length);
|
|
153
|
-
break;
|
|
154
|
-
case '-android uiautomator': {
|
|
155
|
-
using = '-android uiautomator';
|
|
156
|
-
value = stringSelector.slice(8);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case '-android datamatcher': {
|
|
160
|
-
using = '-android datamatcher';
|
|
161
|
-
value = JSON.stringify(value);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case '-android viewmatcher': {
|
|
165
|
-
using = '-android viewmatcher';
|
|
166
|
-
value = JSON.stringify(value);
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
case '-ios uiautomation': {
|
|
170
|
-
using = '-ios uiautomation';
|
|
171
|
-
value = stringSelector.slice(4);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
case 'accessibility id': {
|
|
175
|
-
using = 'accessibility id';
|
|
176
|
-
value = stringSelector.slice(1);
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
case 'class name': {
|
|
180
|
-
using = 'class name';
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
case 'tag name': {
|
|
184
|
-
using = 'tag name';
|
|
185
|
-
value = stringSelector.replace(/<|>|\/|\s/g, '');
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case 'name': {
|
|
189
|
-
if (isMobile || !isW3C) {
|
|
190
|
-
const match = stringSelector.match(/^\[name=("|')([a-zA-z0-9\-_.@=[\] ']+)("|')]$/);
|
|
191
|
-
if (!match) {
|
|
192
|
-
throw new Error(`InvalidSelectorMatch. Strategy 'name' has failed to match '${stringSelector}'`);
|
|
193
|
-
}
|
|
194
|
-
using = 'name';
|
|
195
|
-
value = match[2];
|
|
196
|
-
}
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case 'xpath extended': {
|
|
200
|
-
using = 'xpath';
|
|
201
|
-
const match = stringSelector.match(new RegExp(XPATH_SELECTOR_REGEXP.map(rx => rx.source).join('')));
|
|
202
|
-
if (!match) {
|
|
203
|
-
throw new Error(`InvalidSelectorMatch: Strategy 'xpath extended' has failed to match '${stringSelector}'`);
|
|
204
|
-
}
|
|
205
|
-
const PREFIX_NAME = { '.': 'class', '#': 'id' };
|
|
206
|
-
const conditions = [];
|
|
207
|
-
const [tag, prefix, name, attrName, attrValue, partial, query] = match.slice(1);
|
|
208
|
-
if (prefix) {
|
|
209
|
-
conditions.push(`contains(@${PREFIX_NAME[prefix]}, "${name}")`);
|
|
210
|
-
}
|
|
211
|
-
if (attrName) {
|
|
212
|
-
conditions.push(attrValue
|
|
213
|
-
? `contains(@${attrName}, "${attrValue}")`
|
|
214
|
-
: `@${attrName}`);
|
|
215
|
-
}
|
|
216
|
-
conditions.push(partial ? `contains(., "${query}")` : `normalize-space() = "${query}"`);
|
|
217
|
-
value = `.//${tag || '*'}[${conditions.join(' and ')}]`;
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
case '-image': {
|
|
221
|
-
using = '-image';
|
|
222
|
-
value = fs_1.default.readFileSync(stringSelector, { encoding: 'base64' });
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
case 'role': {
|
|
226
|
-
const match = stringSelector.match(/^\[role=(.+)\]/);
|
|
227
|
-
if (!match) {
|
|
228
|
-
throw new Error(`InvalidSelectorMatch. Strategy 'role' has failed to match '${stringSelector}'`);
|
|
229
|
-
}
|
|
230
|
-
using = 'css selector';
|
|
231
|
-
value = createRoleBaseXpathSelector(match[1]);
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return { using, value };
|
|
236
|
-
};
|
|
237
|
-
exports.findStrategy = findStrategy;
|
|
238
|
-
const createRoleBaseXpathSelector = (role) => {
|
|
239
|
-
var _a;
|
|
240
|
-
const locatorArr = [];
|
|
241
|
-
(_a = aria_query_1.roleElements.get(role)) === null || _a === void 0 ? void 0 : _a.forEach((value) => {
|
|
242
|
-
let locator;
|
|
243
|
-
let tagname, tagAttribute, tagAttributevalue;
|
|
244
|
-
tagname = value.name;
|
|
245
|
-
if (value.attributes instanceof Array) {
|
|
246
|
-
value.attributes.forEach((val) => {
|
|
247
|
-
tagAttribute = val.name;
|
|
248
|
-
tagAttributevalue = val.value;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
if (!tagAttribute) {
|
|
252
|
-
locator = tagname;
|
|
253
|
-
}
|
|
254
|
-
else if (!tagAttributevalue) {
|
|
255
|
-
locator = `${tagname}[${tagAttribute}]`;
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
locator = `${tagname}[${tagAttribute}="${tagAttributevalue}"]`;
|
|
259
|
-
}
|
|
260
|
-
locatorArr.push(locator);
|
|
261
|
-
});
|
|
262
|
-
let xpathLocator = `[role="${role}"]`;
|
|
263
|
-
locatorArr.forEach((loc) => {
|
|
264
|
-
xpathLocator += ',' + loc;
|
|
265
|
-
});
|
|
266
|
-
return xpathLocator;
|
|
267
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ElementReference } from '@wdio/protocols';
|
|
2
|
-
import type { Selector, ElementArray } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* transforms a findElement response into a WDIO element
|
|
5
|
-
* @param {String} selector selector that was used to query the element
|
|
6
|
-
* @param {Object} res findElement response
|
|
7
|
-
* @return {Object} WDIO element object
|
|
8
|
-
*/
|
|
9
|
-
export declare const getElement: (this: WebdriverIO.Browser | WebdriverIO.Element, selector?: Selector | undefined, res?: Error | ElementReference | undefined, isReactElement?: boolean) => WebdriverIO.Element;
|
|
10
|
-
/**
|
|
11
|
-
* transforms a findElements response into an array of WDIO elements
|
|
12
|
-
* @param {String} selector selector that was used to query the element
|
|
13
|
-
* @param {Object} res findElements response
|
|
14
|
-
* @return {Array} array of WDIO elements
|
|
15
|
-
*/
|
|
16
|
-
export declare const getElements: (this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector, elemResponse: ElementReference[], isReactElement?: boolean) => ElementArray;
|
|
17
|
-
//# sourceMappingURL=getElementObject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getElementObject.d.ts","sourceRoot":"","sources":["../../src/utils/getElementObject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAKvD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SACb,YAAY,OAAO,GAAG,mBAAmB,4GAIhD,mBA8CF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,SACd,YAAY,OAAO,GAAG,mBAAmB,YACrC,QAAQ,gBACJ,gBAAgB,EAAE,+BAEjC,YA+CF,CAAA"}
|
|
@@ -1,107 +0,0 @@
|
|
|
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.getElements = exports.getElement = void 0;
|
|
7
|
-
const utils_1 = require("@wdio/utils");
|
|
8
|
-
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
9
|
-
const _1 = require(".");
|
|
10
|
-
const middlewares_1 = require("../middlewares");
|
|
11
|
-
const constants_1 = require("../constants");
|
|
12
|
-
/**
|
|
13
|
-
* transforms a findElement response into a WDIO element
|
|
14
|
-
* @param {String} selector selector that was used to query the element
|
|
15
|
-
* @param {Object} res findElement response
|
|
16
|
-
* @return {Object} WDIO element object
|
|
17
|
-
*/
|
|
18
|
-
const getElement = function findElement(selector, res, isReactElement = false) {
|
|
19
|
-
const browser = (0, _1.getBrowserObject)(this);
|
|
20
|
-
const propertiesObject = {
|
|
21
|
-
...(0, lodash_clonedeep_1.default)(browser.__propertiesObject__),
|
|
22
|
-
...(0, _1.getPrototype)('element'),
|
|
23
|
-
scope: { value: 'element' }
|
|
24
|
-
};
|
|
25
|
-
const element = (0, utils_1.webdriverMonad)(this.options, (client) => {
|
|
26
|
-
const elementId = (0, _1.getElementFromResponse)(res);
|
|
27
|
-
if (elementId) {
|
|
28
|
-
/**
|
|
29
|
-
* set elementId for easy access
|
|
30
|
-
*/
|
|
31
|
-
client.elementId = elementId;
|
|
32
|
-
/**
|
|
33
|
-
* set element id with proper key so element can be passed into execute commands
|
|
34
|
-
*/
|
|
35
|
-
if (this.isW3C) {
|
|
36
|
-
client[constants_1.ELEMENT_KEY] = elementId;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
client.ELEMENT = elementId;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
client.error = res;
|
|
44
|
-
}
|
|
45
|
-
client.selector = selector || '';
|
|
46
|
-
client.parent = this;
|
|
47
|
-
client.emit = this.emit.bind(this);
|
|
48
|
-
client.isReactElement = isReactElement;
|
|
49
|
-
return client;
|
|
50
|
-
}, propertiesObject);
|
|
51
|
-
const elementInstance = element(this.sessionId, (0, middlewares_1.elementErrorHandler)(utils_1.wrapCommand));
|
|
52
|
-
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
53
|
-
elementInstance.addCommand = (name, fn) => {
|
|
54
|
-
browser.__propertiesObject__[name] = { value: fn };
|
|
55
|
-
origAddCommand(name, (0, utils_1.runFnInFiberContext)(fn));
|
|
56
|
-
};
|
|
57
|
-
return elementInstance;
|
|
58
|
-
};
|
|
59
|
-
exports.getElement = getElement;
|
|
60
|
-
/**
|
|
61
|
-
* transforms a findElements response into an array of WDIO elements
|
|
62
|
-
* @param {String} selector selector that was used to query the element
|
|
63
|
-
* @param {Object} res findElements response
|
|
64
|
-
* @return {Array} array of WDIO elements
|
|
65
|
-
*/
|
|
66
|
-
const getElements = function getElements(selector, elemResponse, isReactElement = false) {
|
|
67
|
-
const browser = (0, _1.getBrowserObject)(this);
|
|
68
|
-
const propertiesObject = {
|
|
69
|
-
...(0, lodash_clonedeep_1.default)(browser.__propertiesObject__),
|
|
70
|
-
...(0, _1.getPrototype)('element')
|
|
71
|
-
};
|
|
72
|
-
const elements = elemResponse.map((res, i) => {
|
|
73
|
-
propertiesObject.scope = { value: 'element' };
|
|
74
|
-
const element = (0, utils_1.webdriverMonad)(this.options, (client) => {
|
|
75
|
-
const elementId = (0, _1.getElementFromResponse)(res);
|
|
76
|
-
if (elementId) {
|
|
77
|
-
/**
|
|
78
|
-
* set elementId for easy access
|
|
79
|
-
*/
|
|
80
|
-
client.elementId = elementId;
|
|
81
|
-
/**
|
|
82
|
-
* set element id with proper key so element can be passed into execute commands
|
|
83
|
-
*/
|
|
84
|
-
const elementKey = this.isW3C ? constants_1.ELEMENT_KEY : 'ELEMENT';
|
|
85
|
-
client[elementKey] = elementId;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
client.error = res;
|
|
89
|
-
}
|
|
90
|
-
client.selector = selector;
|
|
91
|
-
client.parent = this;
|
|
92
|
-
client.index = i;
|
|
93
|
-
client.emit = this.emit.bind(this);
|
|
94
|
-
client.isReactElement = isReactElement;
|
|
95
|
-
return client;
|
|
96
|
-
}, propertiesObject);
|
|
97
|
-
const elementInstance = element(this.sessionId, (0, middlewares_1.elementErrorHandler)(utils_1.wrapCommand));
|
|
98
|
-
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
99
|
-
elementInstance.addCommand = (name, fn) => {
|
|
100
|
-
browser.__propertiesObject__[name] = { value: fn };
|
|
101
|
-
origAddCommand(name, (0, utils_1.runFnInFiberContext)(fn));
|
|
102
|
-
};
|
|
103
|
-
return elementInstance;
|
|
104
|
-
});
|
|
105
|
-
return elements;
|
|
106
|
-
};
|
|
107
|
-
exports.getElements = getElements;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* wait on element if:
|
|
3
|
-
* - elementId couldn't be fetched in the first place
|
|
4
|
-
* - command is not explicit wait command for existance or displayedness
|
|
5
|
-
*/
|
|
6
|
-
export default function implicitWait(currentElement: WebdriverIO.Element, commandName: string): Promise<WebdriverIO.Element>;
|
|
7
|
-
//# sourceMappingURL=implicitWait.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"implicitWait.d.ts","sourceRoot":"","sources":["../../src/utils/implicitWait.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAA8B,YAAY,CAAE,cAAc,EAAE,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAmClI"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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');
|
|
8
|
-
/**
|
|
9
|
-
* wait on element if:
|
|
10
|
-
* - elementId couldn't be fetched in the first place
|
|
11
|
-
* - command is not explicit wait command for existance or displayedness
|
|
12
|
-
*/
|
|
13
|
-
async function implicitWait(currentElement, commandName) {
|
|
14
|
-
if (!currentElement.elementId && !commandName.match(/(waitUntil|waitFor|isExisting|is?\w+Displayed|is?\w+Clickable)/)) {
|
|
15
|
-
log.debug(`command ${commandName} was called on an element ("${currentElement.selector}") ` +
|
|
16
|
-
'that wasn\'t found, waiting for it...');
|
|
17
|
-
try {
|
|
18
|
-
await currentElement.waitForExist();
|
|
19
|
-
/**
|
|
20
|
-
* if waitForExist was successful requery element and assign elementId to the scope
|
|
21
|
-
*/
|
|
22
|
-
return currentElement.parent.$(currentElement.selector);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
if (currentElement.selector.toString().includes('this.previousElementSibling')) {
|
|
26
|
-
throw new Error(`Can't call ${commandName} on previous element of element with selector "${currentElement.parent.selector}" because sibling wasn't found`);
|
|
27
|
-
}
|
|
28
|
-
if (currentElement.selector.toString().includes('this.nextElementSibling')) {
|
|
29
|
-
throw new Error(`Can't call ${commandName} on next element of element with selector "${currentElement.parent.selector}" because sibling wasn't found`);
|
|
30
|
-
}
|
|
31
|
-
if (currentElement.selector.toString().includes('this.parentElement')) {
|
|
32
|
-
throw new Error(`Can't call ${commandName} on parent element of element with selector "${currentElement.parent.selector}" because it wasn't found`);
|
|
33
|
-
}
|
|
34
|
-
throw new Error(`Can't call ${commandName} on element with selector "${currentElement.selector}" because element wasn't found`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return currentElement;
|
|
38
|
-
}
|
|
39
|
-
exports.default = implicitWait;
|