webdriverio 9.25.0 → 9.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/browser.d.ts +36 -0
- package/build/commands/browser.d.ts.map +1 -1
- package/build/commands/mobile/background.d.ts +26 -0
- package/build/commands/mobile/background.d.ts.map +1 -0
- package/build/commands/mobile/closeApp.d.ts +35 -0
- package/build/commands/mobile/closeApp.d.ts.map +1 -0
- package/build/commands/mobile/deepLink.d.ts +10 -3
- package/build/commands/mobile/deepLink.d.ts.map +1 -1
- package/build/commands/mobile/dragAndDrop.d.ts +2 -0
- package/build/commands/mobile/dragAndDrop.d.ts.map +1 -1
- package/build/commands/mobile/fingerPrint.d.ts +20 -0
- package/build/commands/mobile/fingerPrint.d.ts.map +1 -0
- package/build/commands/mobile/getClipboard.d.ts +24 -0
- package/build/commands/mobile/getClipboard.d.ts.map +1 -0
- package/build/commands/mobile/getContext.d.ts +2 -0
- package/build/commands/mobile/getContext.d.ts.map +1 -1
- package/build/commands/mobile/getContexts.d.ts +2 -0
- package/build/commands/mobile/getContexts.d.ts.map +1 -1
- package/build/commands/mobile/getCurrentActivity.d.ts +20 -0
- package/build/commands/mobile/getCurrentActivity.d.ts.map +1 -0
- package/build/commands/mobile/getCurrentPackage.d.ts +20 -0
- package/build/commands/mobile/getCurrentPackage.d.ts.map +1 -0
- package/build/commands/mobile/getDisplayDensity.d.ts +18 -0
- package/build/commands/mobile/getDisplayDensity.d.ts.map +1 -0
- package/build/commands/mobile/getPerformanceData.d.ts +28 -0
- package/build/commands/mobile/getPerformanceData.d.ts.map +1 -0
- package/build/commands/mobile/getPerformanceDataTypes.d.ts +21 -0
- package/build/commands/mobile/getPerformanceDataTypes.d.ts.map +1 -0
- package/build/commands/mobile/getStrings.d.ts +26 -0
- package/build/commands/mobile/getStrings.d.ts.map +1 -0
- package/build/commands/mobile/getSystemBars.d.ts +19 -0
- package/build/commands/mobile/getSystemBars.d.ts.map +1 -0
- package/build/commands/mobile/gsmCall.d.ts +23 -0
- package/build/commands/mobile/gsmCall.d.ts.map +1 -0
- package/build/commands/mobile/gsmSignal.d.ts +22 -0
- package/build/commands/mobile/gsmSignal.d.ts.map +1 -0
- package/build/commands/mobile/gsmVoice.d.ts +20 -0
- package/build/commands/mobile/gsmVoice.d.ts.map +1 -0
- package/build/commands/mobile/isLocked.d.ts +20 -0
- package/build/commands/mobile/isLocked.d.ts.map +1 -0
- package/build/commands/mobile/launchApp.d.ts +46 -0
- package/build/commands/mobile/launchApp.d.ts.map +1 -0
- package/build/commands/mobile/lock.d.ts +28 -0
- package/build/commands/mobile/lock.d.ts.map +1 -0
- package/build/commands/mobile/longPress.d.ts +2 -0
- package/build/commands/mobile/longPress.d.ts.map +1 -1
- package/build/commands/mobile/longPressKeyCode.d.ts +21 -0
- package/build/commands/mobile/longPressKeyCode.d.ts.map +1 -0
- package/build/commands/mobile/openNotifications.d.ts +17 -0
- package/build/commands/mobile/openNotifications.d.ts.map +1 -0
- package/build/commands/mobile/pinch.d.ts +2 -0
- package/build/commands/mobile/pinch.d.ts.map +1 -1
- package/build/commands/mobile/powerAC.d.ts +19 -0
- package/build/commands/mobile/powerAC.d.ts.map +1 -0
- package/build/commands/mobile/powerCapacity.d.ts +19 -0
- package/build/commands/mobile/powerCapacity.d.ts.map +1 -0
- package/build/commands/mobile/pressKeyCode.d.ts +24 -0
- package/build/commands/mobile/pressKeyCode.d.ts.map +1 -0
- package/build/commands/mobile/queryAppState.d.ts +32 -0
- package/build/commands/mobile/queryAppState.d.ts.map +1 -0
- package/build/commands/mobile/relaunchActiveApp.d.ts +2 -0
- package/build/commands/mobile/relaunchActiveApp.d.ts.map +1 -1
- package/build/commands/mobile/sendKeyEvent.d.ts +26 -0
- package/build/commands/mobile/sendKeyEvent.d.ts.map +1 -0
- package/build/commands/mobile/sendSms.d.ts +20 -0
- package/build/commands/mobile/sendSms.d.ts.map +1 -0
- package/build/commands/mobile/setClipboard.d.ts +26 -0
- package/build/commands/mobile/setClipboard.d.ts.map +1 -0
- package/build/commands/mobile/shake.d.ts +17 -0
- package/build/commands/mobile/shake.d.ts.map +1 -0
- package/build/commands/mobile/startActivity.d.ts +90 -0
- package/build/commands/mobile/startActivity.d.ts.map +1 -0
- package/build/commands/mobile/swipe.d.ts +2 -0
- package/build/commands/mobile/swipe.d.ts.map +1 -1
- package/build/commands/mobile/switchContext.d.ts +2 -0
- package/build/commands/mobile/switchContext.d.ts.map +1 -1
- package/build/commands/mobile/tap.d.ts +2 -0
- package/build/commands/mobile/tap.d.ts.map +1 -1
- package/build/commands/mobile/toggleAirplaneMode.d.ts +29 -0
- package/build/commands/mobile/toggleAirplaneMode.d.ts.map +1 -0
- package/build/commands/mobile/toggleData.d.ts +27 -0
- package/build/commands/mobile/toggleData.d.ts.map +1 -0
- package/build/commands/mobile/toggleEnrollTouchId.d.ts +27 -0
- package/build/commands/mobile/toggleEnrollTouchId.d.ts.map +1 -0
- package/build/commands/mobile/toggleLocationServices.d.ts +17 -0
- package/build/commands/mobile/toggleLocationServices.d.ts.map +1 -0
- package/build/commands/mobile/toggleNetworkSpeed.d.ts +20 -0
- package/build/commands/mobile/toggleNetworkSpeed.d.ts.map +1 -0
- package/build/commands/mobile/toggleWiFi.d.ts +27 -0
- package/build/commands/mobile/toggleWiFi.d.ts.map +1 -0
- package/build/commands/mobile/touchId.d.ts +34 -0
- package/build/commands/mobile/touchId.d.ts.map +1 -0
- package/build/commands/mobile/unlock.d.ts +41 -0
- package/build/commands/mobile/unlock.d.ts.map +1 -0
- package/build/commands/mobile/zoom.d.ts +2 -0
- package/build/commands/mobile/zoom.d.ts.map +1 -1
- package/build/commands/mobile.d.ts +36 -0
- package/build/commands/mobile.d.ts.map +1 -1
- package/build/index.js +950 -138
- package/build/node.js +958 -148
- package/build/utils/mobile.d.ts +15 -0
- package/build/utils/mobile.d.ts.map +1 -1
- package/package.json +7 -7
package/build/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// src/index.ts
|
|
26
|
-
import
|
|
26
|
+
import logger30 from "@wdio/logger";
|
|
27
27
|
import WebDriver, { DEFAULTS } from "webdriver";
|
|
28
28
|
import { validateConfig } from "@wdio/config";
|
|
29
29
|
import { enableFileLogging, wrapCommand as wrapCommand3, isBidi } from "@wdio/utils";
|
|
@@ -97,7 +97,7 @@ async function refetchElement(currentElement, commandName) {
|
|
|
97
97
|
import cssValue from "css-value";
|
|
98
98
|
import rgb2hex from "rgb2hex";
|
|
99
99
|
import GraphemeSplitter from "grapheme-splitter";
|
|
100
|
-
import
|
|
100
|
+
import logger29 from "@wdio/logger";
|
|
101
101
|
import isPlainObject from "is-plain-obj";
|
|
102
102
|
import { ELEMENT_KEY as ELEMENT_KEY20 } from "webdriver";
|
|
103
103
|
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject37 } from "@wdio/utils";
|
|
@@ -111,7 +111,9 @@ __export(browser_exports, {
|
|
|
111
111
|
action: () => action,
|
|
112
112
|
actions: () => actions,
|
|
113
113
|
addInitScript: () => addInitScript,
|
|
114
|
+
background: () => background,
|
|
114
115
|
call: () => call,
|
|
116
|
+
closeApp: () => closeApp,
|
|
115
117
|
custom$: () => custom$,
|
|
116
118
|
custom$$: () => custom$$,
|
|
117
119
|
debug: () => debug,
|
|
@@ -121,17 +123,38 @@ __export(browser_exports, {
|
|
|
121
123
|
emulate: () => emulate,
|
|
122
124
|
execute: () => execute,
|
|
123
125
|
executeAsync: () => executeAsync,
|
|
126
|
+
fingerPrint: () => fingerPrint,
|
|
127
|
+
getClipboard: () => getClipboard,
|
|
124
128
|
getContext: () => getContext,
|
|
125
129
|
getContexts: () => getContexts,
|
|
126
130
|
getCookies: () => getCookies,
|
|
131
|
+
getCurrentActivity: () => getCurrentActivity,
|
|
132
|
+
getCurrentPackage: () => getCurrentPackage,
|
|
133
|
+
getDisplayDensity: () => getDisplayDensity,
|
|
134
|
+
getPerformanceData: () => getPerformanceData,
|
|
135
|
+
getPerformanceDataTypes: () => getPerformanceDataTypes,
|
|
127
136
|
getPuppeteer: () => getPuppeteer,
|
|
137
|
+
getStrings: () => getStrings,
|
|
138
|
+
getSystemBars: () => getSystemBars,
|
|
128
139
|
getWindowSize: () => getWindowSize,
|
|
140
|
+
gsmCall: () => gsmCall,
|
|
141
|
+
gsmSignal: () => gsmSignal,
|
|
142
|
+
gsmVoice: () => gsmVoice,
|
|
143
|
+
isLocked: () => isLocked,
|
|
129
144
|
keys: () => keys,
|
|
145
|
+
launchApp: () => launchApp,
|
|
146
|
+
lock: () => lock,
|
|
147
|
+
longPressKeyCode: () => longPressKeyCode,
|
|
130
148
|
mock: () => mock,
|
|
131
149
|
mockClearAll: () => mockClearAll,
|
|
132
150
|
mockRestoreAll: () => mockRestoreAll,
|
|
133
151
|
newWindow: () => newWindow2,
|
|
152
|
+
openNotifications: () => openNotifications,
|
|
134
153
|
pause: () => pause,
|
|
154
|
+
powerAC: () => powerAC,
|
|
155
|
+
powerCapacity: () => powerCapacity,
|
|
156
|
+
pressKeyCode: () => pressKeyCode,
|
|
157
|
+
queryAppState: () => queryAppState,
|
|
135
158
|
react$: () => react$3,
|
|
136
159
|
react$$: () => react$$3,
|
|
137
160
|
relaunchActiveApp: () => relaunchActiveApp,
|
|
@@ -141,10 +164,15 @@ __export(browser_exports, {
|
|
|
141
164
|
saveRecordingScreen: () => saveRecordingScreen,
|
|
142
165
|
saveScreenshot: () => saveScreenshot,
|
|
143
166
|
scroll: () => scroll,
|
|
167
|
+
sendKeyEvent: () => sendKeyEvent,
|
|
168
|
+
sendSms: () => sendSms,
|
|
169
|
+
setClipboard: () => setClipboard,
|
|
144
170
|
setCookies: () => setCookies,
|
|
145
171
|
setTimeout: () => setTimeout2,
|
|
146
172
|
setViewport: () => setViewport,
|
|
147
173
|
setWindowSize: () => setWindowSize,
|
|
174
|
+
shake: () => shake,
|
|
175
|
+
startActivity: () => startActivity,
|
|
148
176
|
swipe: () => swipe,
|
|
149
177
|
switchContext: () => switchContext,
|
|
150
178
|
switchFrame: () => switchFrame,
|
|
@@ -153,7 +181,15 @@ __export(browser_exports, {
|
|
|
153
181
|
throttle: () => throttle,
|
|
154
182
|
throttleCPU: () => throttleCPU,
|
|
155
183
|
throttleNetwork: () => throttleNetwork,
|
|
184
|
+
toggleAirplaneMode: () => toggleAirplaneMode,
|
|
185
|
+
toggleData: () => toggleData,
|
|
186
|
+
toggleEnrollTouchId: () => toggleEnrollTouchId,
|
|
187
|
+
toggleLocationServices: () => toggleLocationServices,
|
|
188
|
+
toggleNetworkSpeed: () => toggleNetworkSpeed,
|
|
189
|
+
toggleWiFi: () => toggleWiFi,
|
|
156
190
|
touchAction: () => touchAction2,
|
|
191
|
+
touchId: () => touchId,
|
|
192
|
+
unlock: () => unlock,
|
|
157
193
|
uploadFile: () => uploadFile,
|
|
158
194
|
url: () => url,
|
|
159
195
|
waitUntil: () => waitUntil
|
|
@@ -3052,7 +3088,7 @@ var ReferenceValue = class {
|
|
|
3052
3088
|
};
|
|
3053
3089
|
|
|
3054
3090
|
// src/session/context.ts
|
|
3055
|
-
import
|
|
3091
|
+
import logger5 from "@wdio/logger";
|
|
3056
3092
|
|
|
3057
3093
|
// src/session/session.ts
|
|
3058
3094
|
var sessionManager = /* @__PURE__ */ new Map();
|
|
@@ -3126,6 +3162,20 @@ onCommand_fn = function(ev) {
|
|
|
3126
3162
|
};
|
|
3127
3163
|
|
|
3128
3164
|
// src/utils/mobile.ts
|
|
3165
|
+
import logger4 from "@wdio/logger";
|
|
3166
|
+
var log4 = logger4("webdriver");
|
|
3167
|
+
function isUnknownMethodError(err) {
|
|
3168
|
+
if (!(err instanceof Error)) {
|
|
3169
|
+
return false;
|
|
3170
|
+
}
|
|
3171
|
+
const msg = err.message.toLowerCase();
|
|
3172
|
+
return msg.includes("unknown method") || msg.includes("unknown command");
|
|
3173
|
+
}
|
|
3174
|
+
function logAppiumDeprecationWarning(mobileCommand, protocolEndpoint) {
|
|
3175
|
+
log4.warn(
|
|
3176
|
+
"The `".concat(mobileCommand, "` execute method is not supported by your Appium driver. ") + "Falling back to the deprecated `".concat(protocolEndpoint, "` protocol endpoint. ") + "Please upgrade your Appium driver to a version that supports `".concat(mobileCommand, "`.")
|
|
3177
|
+
);
|
|
3178
|
+
}
|
|
3129
3179
|
function getNativeContext({ capabilities, isMobile }) {
|
|
3130
3180
|
var _a, _b;
|
|
3131
3181
|
if (!capabilities || typeof capabilities !== "object" || !isMobile) {
|
|
@@ -3176,7 +3226,7 @@ function validatePinchAndZoomOptions({ browser, gesture, options }) {
|
|
|
3176
3226
|
}
|
|
3177
3227
|
|
|
3178
3228
|
// src/session/context.ts
|
|
3179
|
-
var
|
|
3229
|
+
var log5 = logger5("webdriverio:context");
|
|
3180
3230
|
var COMMANDS_REQUIRING_RESET = ["deleteSession", "refresh", "switchToParentFrame"];
|
|
3181
3231
|
function getContextManager(browser) {
|
|
3182
3232
|
return SessionManager.getSessionManager(browser, ContextManager);
|
|
@@ -3241,7 +3291,7 @@ var _ContextManager = class _ContextManager extends SessionManager {
|
|
|
3241
3291
|
}
|
|
3242
3292
|
if (__privateGet(this, _browser3).isMobile && !__privateGet(this, _isNativeContext) && !__privateGet(this, _mobileContext) && __privateGet(this, _getContextSupport)) {
|
|
3243
3293
|
const context = await __privateGet(this, _browser3).getContext().catch((err) => {
|
|
3244
|
-
|
|
3294
|
+
log5.warn(
|
|
3245
3295
|
"Error getting context: ".concat(err, "\n\n") + "WebDriver capabilities: ".concat(JSON.stringify(__privateGet(this, _browser3).capabilities), "\n") + "Requested WebDriver capabilities: ".concat(JSON.stringify(__privateGet(this, _browser3).requestedCapabilities))
|
|
3246
3296
|
);
|
|
3247
3297
|
if (err.message.includes("Request failed with status code 405")) {
|
|
@@ -3510,8 +3560,8 @@ async function executeAsync(script, ...args) {
|
|
|
3510
3560
|
}
|
|
3511
3561
|
|
|
3512
3562
|
// src/commands/browser/getCookies.ts
|
|
3513
|
-
import
|
|
3514
|
-
var
|
|
3563
|
+
import logger6 from "@wdio/logger";
|
|
3564
|
+
var log6 = logger6("webdriverio");
|
|
3515
3565
|
async function getCookies(filter) {
|
|
3516
3566
|
const usesMultipleFilter = Array.isArray(filter) && filter.length > 1;
|
|
3517
3567
|
if (!this.isBidi || usesMultipleFilter) {
|
|
@@ -3539,7 +3589,7 @@ async function getCookies(filter) {
|
|
|
3539
3589
|
try {
|
|
3540
3590
|
const { cookies } = await this.storageGetCookies(params);
|
|
3541
3591
|
if (cookies.length === 0) {
|
|
3542
|
-
|
|
3592
|
+
log6.debug("BiDi getCookies returned empty, falling back to classic");
|
|
3543
3593
|
return getCookiesClassic.call(this, filter);
|
|
3544
3594
|
}
|
|
3545
3595
|
return cookies.map((cookie) => ({
|
|
@@ -3547,7 +3597,7 @@ async function getCookies(filter) {
|
|
|
3547
3597
|
value: cookie.value.type === "base64" ? Buffer.from(cookie.value.value, "base64").toString("utf-8") : cookie.value.value
|
|
3548
3598
|
}));
|
|
3549
3599
|
} catch (err) {
|
|
3550
|
-
|
|
3600
|
+
log6.warn("BiDi getCookies failed, falling back to classic: ".concat(err.message));
|
|
3551
3601
|
return getCookiesClassic.call(this, filter);
|
|
3552
3602
|
}
|
|
3553
3603
|
}
|
|
@@ -3557,7 +3607,7 @@ async function getCookiesClassic(names) {
|
|
|
3557
3607
|
}
|
|
3558
3608
|
const usesMultipleFilter = Array.isArray(names) && names.length > 1;
|
|
3559
3609
|
if (usesMultipleFilter) {
|
|
3560
|
-
|
|
3610
|
+
log6.warn(
|
|
3561
3611
|
"Passing a string array as filter for `getCookies` is deprecated and its support will be removed in an upcoming version of WebdriverIO!"
|
|
3562
3612
|
);
|
|
3563
3613
|
const allCookies2 = await this.getAllCookies();
|
|
@@ -3579,7 +3629,7 @@ function getCookieFilter(names) {
|
|
|
3579
3629
|
}
|
|
3580
3630
|
return (Array.isArray(names) ? names : [names]).map((filter) => {
|
|
3581
3631
|
if (typeof filter === "string") {
|
|
3582
|
-
|
|
3632
|
+
log6.warn("Passing string values into `getCookie` is deprecated and its support will be removed in an upcoming version of WebdriverIO!");
|
|
3583
3633
|
return { name: filter };
|
|
3584
3634
|
}
|
|
3585
3635
|
return filter;
|
|
@@ -3587,9 +3637,9 @@ function getCookieFilter(names) {
|
|
|
3587
3637
|
}
|
|
3588
3638
|
|
|
3589
3639
|
// src/commands/browser/getPuppeteer.ts
|
|
3590
|
-
import
|
|
3640
|
+
import logger7 from "@wdio/logger";
|
|
3591
3641
|
import { userImport } from "@wdio/utils";
|
|
3592
|
-
var
|
|
3642
|
+
var log7 = logger7("webdriverio");
|
|
3593
3643
|
var DEBUG_PIPE_FLAG = "remote-debugging-pipe";
|
|
3594
3644
|
async function getPuppeteer() {
|
|
3595
3645
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -3603,7 +3653,7 @@ async function getPuppeteer() {
|
|
|
3603
3653
|
);
|
|
3604
3654
|
}
|
|
3605
3655
|
if ((_a = this.puppeteer) == null ? void 0 : _a.connected) {
|
|
3606
|
-
|
|
3656
|
+
log7.debug("Reusing existing puppeteer session");
|
|
3607
3657
|
return this.puppeteer;
|
|
3608
3658
|
}
|
|
3609
3659
|
const { headers } = this.options;
|
|
@@ -3713,7 +3763,7 @@ async function keys(value) {
|
|
|
3713
3763
|
import { getBrowserObject as getBrowserObject6 } from "@wdio/utils";
|
|
3714
3764
|
|
|
3715
3765
|
// src/utils/interception/index.ts
|
|
3716
|
-
import
|
|
3766
|
+
import logger8 from "@wdio/logger";
|
|
3717
3767
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3718
3768
|
|
|
3719
3769
|
// src/utils/Timer.ts
|
|
@@ -3890,7 +3940,7 @@ function getPatternParam(pattern, key) {
|
|
|
3890
3940
|
}
|
|
3891
3941
|
|
|
3892
3942
|
// src/utils/interception/index.ts
|
|
3893
|
-
var
|
|
3943
|
+
var log8 = logger8("WebDriverInterception");
|
|
3894
3944
|
var hasSubscribedToEvents = false;
|
|
3895
3945
|
var _pattern, _mockId, _filterOptions, _browser4, _eventHandler, _restored, _requestOverwrites, _respondOverwrites, _calls, _responseBodies, _WebDriverInterception_instances, emit_fn, addEventHandler_fn, handleBeforeRequestSent_fn, handleResponseStarted_fn, handleNetworkProvideResponseError_fn, isRequestMatching_fn, matchesFilterOptions_fn, _setOverwrite, ensureNotRestored_fn;
|
|
3896
3946
|
var _WebDriverInterception = class _WebDriverInterception {
|
|
@@ -3928,7 +3978,7 @@ var _WebDriverInterception = class _WebDriverInterception {
|
|
|
3928
3978
|
"network.responseStarted"
|
|
3929
3979
|
]
|
|
3930
3980
|
});
|
|
3931
|
-
|
|
3981
|
+
log8.info("subscribed to network events");
|
|
3932
3982
|
hasSubscribedToEvents = true;
|
|
3933
3983
|
}
|
|
3934
3984
|
const interception = await browser.networkAddIntercept({
|
|
@@ -3955,7 +4005,7 @@ var _WebDriverInterception = class _WebDriverInterception {
|
|
|
3955
4005
|
return null;
|
|
3956
4006
|
}
|
|
3957
4007
|
if (/[^A-Za-z0-9+/=\s]/.test(body.value)) {
|
|
3958
|
-
|
|
4008
|
+
log8.warn("Invalid base64 data for request ".concat(requestId));
|
|
3959
4009
|
return null;
|
|
3960
4010
|
}
|
|
3961
4011
|
return Buffer.from(body.value, "base64");
|
|
@@ -4009,7 +4059,7 @@ var _WebDriverInterception = class _WebDriverInterception {
|
|
|
4009
4059
|
__privateSet(this, _respondOverwrites, []);
|
|
4010
4060
|
__privateSet(this, _restored, true);
|
|
4011
4061
|
const handle = await __privateGet(this, _browser4).getWindowHandle();
|
|
4012
|
-
|
|
4062
|
+
log8.trace("Restoring mock for ".concat(handle));
|
|
4013
4063
|
SESSION_MOCKS[handle].delete(this);
|
|
4014
4064
|
if (__privateGet(this, _mockId)) {
|
|
4015
4065
|
await __privateGet(this, _browser4).networkRemoveIntercept({ intercept: __privateGet(this, _mockId) });
|
|
@@ -4302,11 +4352,11 @@ async function mock(url2, filterOptions) {
|
|
|
4302
4352
|
}
|
|
4303
4353
|
|
|
4304
4354
|
// src/commands/browser/mockClearAll.ts
|
|
4305
|
-
import
|
|
4306
|
-
var
|
|
4355
|
+
import logger9 from "@wdio/logger";
|
|
4356
|
+
var log9 = logger9("webdriverio:mockClearAll");
|
|
4307
4357
|
async function mockClearAll() {
|
|
4308
4358
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4309
|
-
|
|
4359
|
+
log9.trace("Clearing mocks for ".concat(handle));
|
|
4310
4360
|
for (const mock2 of mocks) {
|
|
4311
4361
|
mock2.clear();
|
|
4312
4362
|
}
|
|
@@ -4314,11 +4364,11 @@ async function mockClearAll() {
|
|
|
4314
4364
|
}
|
|
4315
4365
|
|
|
4316
4366
|
// src/commands/browser/mockRestoreAll.ts
|
|
4317
|
-
import
|
|
4318
|
-
var
|
|
4367
|
+
import logger10 from "@wdio/logger";
|
|
4368
|
+
var log10 = logger10("webdriverio:mockRestoreAll");
|
|
4319
4369
|
async function mockRestoreAll() {
|
|
4320
4370
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4321
|
-
|
|
4371
|
+
log10.trace("Clearing mocks for ".concat(handle));
|
|
4322
4372
|
for (const mock2 of mocks) {
|
|
4323
4373
|
await mock2.restore();
|
|
4324
4374
|
}
|
|
@@ -4334,8 +4384,8 @@ function newWindow(url2, windowName, windowFeatures) {
|
|
|
4334
4384
|
}
|
|
4335
4385
|
|
|
4336
4386
|
// src/commands/browser/newWindow.ts
|
|
4337
|
-
import
|
|
4338
|
-
var
|
|
4387
|
+
import logger11 from "@wdio/logger";
|
|
4388
|
+
var log11 = logger11("webdriverio:newWindow");
|
|
4339
4389
|
var WAIT_FOR_NEW_HANDLE_TIMEOUT = 3e3;
|
|
4340
4390
|
async function newWindow2(url2, { type = "window", windowName = "", windowFeatures = "" } = {}) {
|
|
4341
4391
|
if (typeof url2 !== "string") {
|
|
@@ -4345,7 +4395,7 @@ async function newWindow2(url2, { type = "window", windowName = "", windowFeatur
|
|
|
4345
4395
|
throw new Error("Invalid type '".concat(type, "' provided to newWindow command. Use either 'tab' or 'window'"));
|
|
4346
4396
|
}
|
|
4347
4397
|
if (windowName || windowFeatures) {
|
|
4348
|
-
|
|
4398
|
+
log11.warn('The "windowName" and "windowFeatures" options are deprecated and only supported in WebDriver Classic sessions.');
|
|
4349
4399
|
}
|
|
4350
4400
|
if (this.isMobile) {
|
|
4351
4401
|
throw new Error("newWindow command is not supported on mobile platforms");
|
|
@@ -4450,14 +4500,14 @@ async function react$3(selector, { props = {}, state = {} } = {}) {
|
|
|
4450
4500
|
}
|
|
4451
4501
|
|
|
4452
4502
|
// src/commands/browser/reloadSession.ts
|
|
4453
|
-
import
|
|
4503
|
+
import logger14 from "@wdio/logger";
|
|
4454
4504
|
|
|
4455
4505
|
// src/session/polyfill.ts
|
|
4456
|
-
import
|
|
4506
|
+
import logger12 from "@wdio/logger";
|
|
4457
4507
|
function getPolyfillManager(browser) {
|
|
4458
4508
|
return SessionManager.getSessionManager(browser, PolyfillManager);
|
|
4459
4509
|
}
|
|
4460
|
-
var
|
|
4510
|
+
var log12 = logger12("webdriverio:PolyfillManager");
|
|
4461
4511
|
var _initialize, _browser5, _scriptsRegisteredInContexts, _registerScriptsListener, _PolyfillManager_instances, registerScripts_fn;
|
|
4462
4512
|
var _PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
4463
4513
|
constructor(browser) {
|
|
@@ -4500,7 +4550,7 @@ registerScripts_fn = function(context) {
|
|
|
4500
4550
|
return;
|
|
4501
4551
|
}
|
|
4502
4552
|
const functionDeclaration = createFunctionDeclarationFromString(polyfillFn);
|
|
4503
|
-
|
|
4553
|
+
log12.info("Adding polyfill script to context with id ".concat(context.context));
|
|
4504
4554
|
__privateGet(this, _scriptsRegisteredInContexts).add(context.context);
|
|
4505
4555
|
return Promise.all([
|
|
4506
4556
|
!context.parent ? __privateGet(this, _browser5).scriptAddPreloadScript({
|
|
@@ -4519,7 +4569,7 @@ registerScripts_fn = function(context) {
|
|
|
4519
4569
|
var PolyfillManager = _PolyfillManager;
|
|
4520
4570
|
|
|
4521
4571
|
// src/session/shadowRoot.ts
|
|
4522
|
-
import
|
|
4572
|
+
import logger13 from "@wdio/logger";
|
|
4523
4573
|
|
|
4524
4574
|
// src/scripts/customElement.ts
|
|
4525
4575
|
function customElementWrapper() {
|
|
@@ -4554,7 +4604,7 @@ function customElementWrapper() {
|
|
|
4554
4604
|
}
|
|
4555
4605
|
|
|
4556
4606
|
// src/session/shadowRoot.ts
|
|
4557
|
-
var
|
|
4607
|
+
var log13 = logger13("webdriverio:ShadowRootManager");
|
|
4558
4608
|
function getShadowRootManager(browser) {
|
|
4559
4609
|
return SessionManager.getSessionManager(browser, ShadowRootManager);
|
|
4560
4610
|
}
|
|
@@ -4651,9 +4701,9 @@ var _ShadowRootManager = class _ShadowRootManager extends SessionManager {
|
|
|
4651
4701
|
!((_b = (_a = shadowElem.value) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.sharedId) || // we expect the shadow root to have a proper type
|
|
4652
4702
|
((_c = shadowElem.value.shadowRoot.value) == null ? void 0 : _c.nodeType) !== 11
|
|
4653
4703
|
) {
|
|
4654
|
-
return
|
|
4704
|
+
return log13.warn("Expected element with shadow root but found <".concat((_d = shadowElem.value) == null ? void 0 : _d.localName, " />"));
|
|
4655
4705
|
}
|
|
4656
|
-
|
|
4706
|
+
log13.info("Registered new shadow root for element <".concat(shadowElem.value.localName, " /> with id ").concat(shadowElem.value.shadowRoot.sharedId));
|
|
4657
4707
|
const newTree = new ShadowRootTree(
|
|
4658
4708
|
shadowElem.sharedId,
|
|
4659
4709
|
shadowElem.value.shadowRoot.sharedId,
|
|
@@ -4922,16 +4972,16 @@ _responseCompletedListener = new WeakMap();
|
|
|
4922
4972
|
_beforeRequestSentListener = new WeakMap();
|
|
4923
4973
|
_fetchErrorListener = new WeakMap();
|
|
4924
4974
|
_NetworkManager_instances = new WeakSet();
|
|
4925
|
-
beforeRequestSent_fn = function(
|
|
4975
|
+
beforeRequestSent_fn = function(log30) {
|
|
4926
4976
|
var _a;
|
|
4927
|
-
if (
|
|
4977
|
+
if (log30.navigation) {
|
|
4928
4978
|
return;
|
|
4929
4979
|
}
|
|
4930
|
-
const request = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this,
|
|
4980
|
+
const request = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log30.navigation);
|
|
4931
4981
|
if (!request) {
|
|
4932
4982
|
return;
|
|
4933
4983
|
}
|
|
4934
|
-
const { request: id, headers, cookies, url: url2 } =
|
|
4984
|
+
const { request: id, headers, cookies, url: url2 } = log30.request;
|
|
4935
4985
|
(_a = request.children) == null ? void 0 : _a.push({
|
|
4936
4986
|
id,
|
|
4937
4987
|
url: url2,
|
|
@@ -4947,52 +4997,52 @@ beforeRequestSent_fn = function(log29) {
|
|
|
4947
4997
|
sameSite: cookie.sameSite,
|
|
4948
4998
|
expiry: cookie.expiry
|
|
4949
4999
|
})),
|
|
4950
|
-
timestamp:
|
|
5000
|
+
timestamp: log30.timestamp
|
|
4951
5001
|
});
|
|
4952
5002
|
};
|
|
4953
|
-
navigationStarted_fn2 = function(
|
|
5003
|
+
navigationStarted_fn2 = function(log30) {
|
|
4954
5004
|
if (
|
|
4955
5005
|
/**
|
|
4956
5006
|
* we need a navigation id to identify the request
|
|
4957
5007
|
*/
|
|
4958
|
-
!
|
|
5008
|
+
!log30.navigation || /**
|
|
4959
5009
|
* ignore urls that users wouldn't navigate to
|
|
4960
5010
|
*/
|
|
4961
|
-
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) =>
|
|
5011
|
+
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) => log30.url.startsWith(protocol))
|
|
4962
5012
|
) {
|
|
4963
|
-
if (
|
|
5013
|
+
if (log30.navigation === null && log30.url === "") {
|
|
4964
5014
|
__privateSet(this, _lastNetworkId, UNKNOWN_NAVIGATION_ID);
|
|
4965
5015
|
return __privateGet(this, _requests).set(UNKNOWN_NAVIGATION_ID, {
|
|
4966
5016
|
url: "",
|
|
4967
5017
|
headers: {},
|
|
4968
|
-
timestamp:
|
|
5018
|
+
timestamp: log30.timestamp,
|
|
4969
5019
|
redirectChain: [],
|
|
4970
5020
|
children: []
|
|
4971
5021
|
});
|
|
4972
5022
|
}
|
|
4973
5023
|
return;
|
|
4974
5024
|
}
|
|
4975
|
-
__privateSet(this, _lastNetworkId,
|
|
4976
|
-
__privateGet(this, _requests).set(
|
|
4977
|
-
url:
|
|
5025
|
+
__privateSet(this, _lastNetworkId, log30.navigation);
|
|
5026
|
+
__privateGet(this, _requests).set(log30.navigation, {
|
|
5027
|
+
url: log30.url,
|
|
4978
5028
|
headers: {},
|
|
4979
|
-
timestamp:
|
|
4980
|
-
navigation:
|
|
5029
|
+
timestamp: log30.timestamp,
|
|
5030
|
+
navigation: log30.navigation,
|
|
4981
5031
|
redirectChain: [],
|
|
4982
5032
|
children: []
|
|
4983
5033
|
});
|
|
4984
5034
|
};
|
|
4985
|
-
fetchError_fn = function(
|
|
5035
|
+
fetchError_fn = function(log30) {
|
|
4986
5036
|
var _a;
|
|
4987
|
-
const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this,
|
|
5037
|
+
const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log30.navigation);
|
|
4988
5038
|
if (!response) {
|
|
4989
5039
|
return;
|
|
4990
5040
|
}
|
|
4991
|
-
const request = (_a = response.children) == null ? void 0 : _a.find((child) => child.id ===
|
|
5041
|
+
const request = (_a = response.children) == null ? void 0 : _a.find((child) => child.id === log30.request.request);
|
|
4992
5042
|
if (!request) {
|
|
4993
5043
|
return;
|
|
4994
5044
|
}
|
|
4995
|
-
request.error =
|
|
5045
|
+
request.error = log30.errorText;
|
|
4996
5046
|
};
|
|
4997
5047
|
findRootRequest_fn = function(navigationId) {
|
|
4998
5048
|
const response = __privateGet(this, _requests).get(navigationId || UNKNOWN_NAVIGATION_ID);
|
|
@@ -5002,23 +5052,23 @@ findRootRequest_fn = function(navigationId) {
|
|
|
5002
5052
|
const firstRequest = __privateGet(this, _requests).values().next().value;
|
|
5003
5053
|
return __privateGet(this, _lastNetworkId) ? __privateGet(this, _requests).get(__privateGet(this, _lastNetworkId)) || firstRequest : firstRequest;
|
|
5004
5054
|
};
|
|
5005
|
-
responseCompleted_fn = function(
|
|
5055
|
+
responseCompleted_fn = function(log30) {
|
|
5006
5056
|
var _a, _b, _c;
|
|
5007
|
-
const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this,
|
|
5057
|
+
const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log30.navigation);
|
|
5008
5058
|
if (!response) {
|
|
5009
5059
|
return;
|
|
5010
5060
|
}
|
|
5011
5061
|
if (!response.navigation && response.url === "") {
|
|
5012
|
-
response.url =
|
|
5013
|
-
response.navigation =
|
|
5062
|
+
response.url = log30.request.url;
|
|
5063
|
+
response.navigation = log30.navigation;
|
|
5014
5064
|
}
|
|
5015
|
-
if (
|
|
5016
|
-
if (response.url !==
|
|
5065
|
+
if (log30.navigation === response.navigation) {
|
|
5066
|
+
if (response.url !== log30.response.url) {
|
|
5017
5067
|
(_a = response.redirectChain) == null ? void 0 : _a.push(response.url);
|
|
5018
5068
|
}
|
|
5019
|
-
response.url =
|
|
5020
|
-
const { headers: requestHeaders } =
|
|
5021
|
-
const { fromCache, headers: responseHeaders, mimeType, status } =
|
|
5069
|
+
response.url = log30.response.url;
|
|
5070
|
+
const { headers: requestHeaders } = log30.request;
|
|
5071
|
+
const { fromCache, headers: responseHeaders, mimeType, status } = log30.response;
|
|
5022
5072
|
response.headers = headerListToObject(requestHeaders), response.response = {
|
|
5023
5073
|
fromCache,
|
|
5024
5074
|
headers: headerListToObject(responseHeaders),
|
|
@@ -5027,15 +5077,15 @@ responseCompleted_fn = function(log29) {
|
|
|
5027
5077
|
};
|
|
5028
5078
|
return;
|
|
5029
5079
|
}
|
|
5030
|
-
const request = (_b = response.children) == null ? void 0 : _b.find((child) => child.id ===
|
|
5080
|
+
const request = (_b = response.children) == null ? void 0 : _b.find((child) => child.id === log30.request.request);
|
|
5031
5081
|
if (!request) {
|
|
5032
5082
|
return;
|
|
5033
5083
|
}
|
|
5034
5084
|
request.response = {
|
|
5035
|
-
fromCache:
|
|
5036
|
-
headers: headerListToObject(
|
|
5037
|
-
mimeType:
|
|
5038
|
-
status:
|
|
5085
|
+
fromCache: log30.response.fromCache,
|
|
5086
|
+
headers: headerListToObject(log30.response.headers),
|
|
5087
|
+
mimeType: log30.response.mimeType,
|
|
5088
|
+
status: log30.response.status
|
|
5039
5089
|
};
|
|
5040
5090
|
(_c = response.children) == null ? void 0 : _c.push(request);
|
|
5041
5091
|
};
|
|
@@ -5087,12 +5137,12 @@ _initialize4 = new WeakMap();
|
|
|
5087
5137
|
_autoHandleDialog = new WeakMap();
|
|
5088
5138
|
_handleUserPromptListener = new WeakMap();
|
|
5089
5139
|
_DialogManager_instances = new WeakSet();
|
|
5090
|
-
handleUserPrompt_fn = async function(
|
|
5140
|
+
handleUserPrompt_fn = async function(log30) {
|
|
5091
5141
|
if (__privateGet(this, _autoHandleDialog)) {
|
|
5092
5142
|
try {
|
|
5093
5143
|
return await __privateGet(this, _browser8).browsingContextHandleUserPrompt({
|
|
5094
5144
|
accept: false,
|
|
5095
|
-
context:
|
|
5145
|
+
context: log30.context
|
|
5096
5146
|
});
|
|
5097
5147
|
} catch (err) {
|
|
5098
5148
|
if (err instanceof Error && (err.message.includes("no such alert") || err.message.includes("no such frame"))) {
|
|
@@ -5101,7 +5151,7 @@ handleUserPrompt_fn = async function(log29) {
|
|
|
5101
5151
|
throw err;
|
|
5102
5152
|
}
|
|
5103
5153
|
}
|
|
5104
|
-
const dialog = new Dialog(
|
|
5154
|
+
const dialog = new Dialog(log30, __privateGet(this, _browser8));
|
|
5105
5155
|
__privateGet(this, _browser8).emit("dialog", dialog);
|
|
5106
5156
|
};
|
|
5107
5157
|
/**
|
|
@@ -5190,7 +5240,7 @@ function registerSessionManager(instance) {
|
|
|
5190
5240
|
}
|
|
5191
5241
|
|
|
5192
5242
|
// src/commands/browser/reloadSession.ts
|
|
5193
|
-
var
|
|
5243
|
+
var log14 = logger14("webdriverio");
|
|
5194
5244
|
async function reloadSession(newCapabilities) {
|
|
5195
5245
|
var _a;
|
|
5196
5246
|
const oldSessionId = this.sessionId;
|
|
@@ -5198,11 +5248,11 @@ async function reloadSession(newCapabilities) {
|
|
|
5198
5248
|
try {
|
|
5199
5249
|
await this.deleteSession({ shutdownDriver });
|
|
5200
5250
|
} catch (err) {
|
|
5201
|
-
|
|
5251
|
+
log14.warn("Suppressing error closing the session: ".concat(err.stack));
|
|
5202
5252
|
}
|
|
5203
5253
|
if ((_a = this.puppeteer) == null ? void 0 : _a.connected) {
|
|
5204
5254
|
this.puppeteer.disconnect();
|
|
5205
|
-
|
|
5255
|
+
log14.debug("Disconnected puppeteer session");
|
|
5206
5256
|
}
|
|
5207
5257
|
const ProtocolDriver = (await import(
|
|
5208
5258
|
/* @vite-ignore */
|
|
@@ -5248,11 +5298,11 @@ async function saveScreenshot(filepath, options) {
|
|
|
5248
5298
|
}
|
|
5249
5299
|
|
|
5250
5300
|
// src/commands/browser/scroll.ts
|
|
5251
|
-
import
|
|
5252
|
-
var
|
|
5301
|
+
import logger15 from "@wdio/logger";
|
|
5302
|
+
var log15 = logger15("webdriverio");
|
|
5253
5303
|
function scroll(x = 0, y = 0) {
|
|
5254
5304
|
if (!x && !y) {
|
|
5255
|
-
|
|
5305
|
+
log15.warn('"scroll" command was called with no parameters, skipping execution');
|
|
5256
5306
|
return Promise.resolve();
|
|
5257
5307
|
}
|
|
5258
5308
|
if (this.isMobile) {
|
|
@@ -5266,8 +5316,8 @@ function scroll(x = 0, y = 0) {
|
|
|
5266
5316
|
}
|
|
5267
5317
|
|
|
5268
5318
|
// src/commands/browser/setCookies.ts
|
|
5269
|
-
import
|
|
5270
|
-
var
|
|
5319
|
+
import logger16 from "@wdio/logger";
|
|
5320
|
+
var log16 = logger16("webdriverio");
|
|
5271
5321
|
async function setCookies(cookieObjs) {
|
|
5272
5322
|
const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
|
|
5273
5323
|
if (cookieObjsList.some((obj) => typeof obj !== "object")) {
|
|
@@ -5304,7 +5354,7 @@ async function setCookies(cookieObjs) {
|
|
|
5304
5354
|
}
|
|
5305
5355
|
})));
|
|
5306
5356
|
} catch (err) {
|
|
5307
|
-
|
|
5357
|
+
log16.warn("BiDi setCookies failed, falling back to classic: ".concat(err.message));
|
|
5308
5358
|
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5309
5359
|
}
|
|
5310
5360
|
return;
|
|
@@ -5410,7 +5460,7 @@ async function switchWindow(matcher) {
|
|
|
5410
5460
|
}
|
|
5411
5461
|
|
|
5412
5462
|
// src/commands/browser/switchFrame.ts
|
|
5413
|
-
import
|
|
5463
|
+
import logger17 from "@wdio/logger";
|
|
5414
5464
|
import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
|
|
5415
5465
|
|
|
5416
5466
|
// src/scripts/shadowDom.ts
|
|
@@ -5438,7 +5488,7 @@ function findIframeInShadowDOM(fragment) {
|
|
|
5438
5488
|
}
|
|
5439
5489
|
|
|
5440
5490
|
// src/commands/browser/switchFrame.ts
|
|
5441
|
-
var
|
|
5491
|
+
var log17 = logger17("webdriverio:switchFrame");
|
|
5442
5492
|
async function switchFrame(context) {
|
|
5443
5493
|
var _a;
|
|
5444
5494
|
function isPossiblyUnresolvedElement(input) {
|
|
@@ -5478,13 +5528,13 @@ async function switchFrame(context) {
|
|
|
5478
5528
|
const urlContextContaining = sessionContext.findContext(context, tree.contexts, "byUrlContaining");
|
|
5479
5529
|
const contextIdContext = sessionContext.findContext(context, tree.contexts, "byContextId");
|
|
5480
5530
|
if (urlContext) {
|
|
5481
|
-
|
|
5531
|
+
log17.info('Found context by url "'.concat(urlContext.url, '" with context id "').concat(urlContext.context, '"'));
|
|
5482
5532
|
return urlContext.context;
|
|
5483
5533
|
} else if (urlContextContaining) {
|
|
5484
|
-
|
|
5534
|
+
log17.info('Found context by url containing "'.concat(urlContextContaining.url, '" with context id "').concat(urlContextContaining.context, '"'));
|
|
5485
5535
|
return urlContextContaining.context;
|
|
5486
5536
|
} else if (contextIdContext) {
|
|
5487
|
-
|
|
5537
|
+
log17.info('Found context by id "'.concat(contextIdContext, '" with url "').concat(contextIdContext.url, '"'));
|
|
5488
5538
|
return contextIdContext.context;
|
|
5489
5539
|
}
|
|
5490
5540
|
return false;
|
|
@@ -5512,7 +5562,7 @@ async function switchFrame(context) {
|
|
|
5512
5562
|
arguments: args.map((arg) => LocalValue.getArgument(arg)),
|
|
5513
5563
|
target: { context: id }
|
|
5514
5564
|
};
|
|
5515
|
-
const result = await this.scriptCallFunction(params).catch((err) =>
|
|
5565
|
+
const result = await this.scriptCallFunction(params).catch((err) => log17.warn("Failed to identify frame context id: ".concat(err.message)));
|
|
5516
5566
|
if (!result) {
|
|
5517
5567
|
return [];
|
|
5518
5568
|
}
|
|
@@ -5548,18 +5598,18 @@ async function switchFrame(context) {
|
|
|
5548
5598
|
return this.switchFrame(iframeElement);
|
|
5549
5599
|
}
|
|
5550
5600
|
}
|
|
5551
|
-
|
|
5601
|
+
log17.warn('Shadow DOM iframe with src containing "'.concat(urlFragment, '" found, but could not be resolved into a WebdriverIO element.'));
|
|
5552
5602
|
}
|
|
5553
5603
|
let desiredFrame;
|
|
5554
5604
|
let desiredContext = newContextId;
|
|
5555
5605
|
const contextQueue = [];
|
|
5556
|
-
|
|
5606
|
+
log17.info("Available frames to switch to: ".concat(allFrames.length, ", desired context to switch: ").concat(desiredContext));
|
|
5557
5607
|
while (desiredContext !== currentContext) {
|
|
5558
5608
|
desiredFrame = allFrames.find(({ context: context2 }) => context2 === desiredContext);
|
|
5559
5609
|
if (!desiredFrame) {
|
|
5560
5610
|
break;
|
|
5561
5611
|
}
|
|
5562
|
-
|
|
5612
|
+
log17.info(
|
|
5563
5613
|
contextQueue.length === 0 ? "Found desired frame with element id ".concat(desiredFrame.frameElement[ELEMENT_KEY8]) : "to switch to desired frame, we need to switch to ".concat(desiredFrame.context, " first")
|
|
5564
5614
|
);
|
|
5565
5615
|
contextQueue.unshift(desiredFrame);
|
|
@@ -5595,7 +5645,7 @@ async function switchFrame(context) {
|
|
|
5595
5645
|
target: { context: contextId }
|
|
5596
5646
|
};
|
|
5597
5647
|
const result = await this.scriptCallFunction(params).catch((err) => {
|
|
5598
|
-
|
|
5648
|
+
log17.warn("switchFrame context callback threw error: ".concat(err.message));
|
|
5599
5649
|
return void 0;
|
|
5600
5650
|
});
|
|
5601
5651
|
if (result && result.type === "success" && result.result.type === "boolean" && result.result.value) {
|
|
@@ -5641,11 +5691,11 @@ function toggleDisableDeprecationWarning() {
|
|
|
5641
5691
|
}
|
|
5642
5692
|
|
|
5643
5693
|
// src/commands/browser/throttle.ts
|
|
5644
|
-
import
|
|
5694
|
+
import logger18 from "@wdio/logger";
|
|
5645
5695
|
import { getBrowserObject as getBrowserObject8 } from "@wdio/utils";
|
|
5646
|
-
var
|
|
5696
|
+
var log18 = logger18("webdriverio:throttle");
|
|
5647
5697
|
async function throttle(params) {
|
|
5648
|
-
|
|
5698
|
+
log18.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
5649
5699
|
const browser = getBrowserObject8(this);
|
|
5650
5700
|
await browser.throttleNetwork(params);
|
|
5651
5701
|
}
|
|
@@ -5914,7 +5964,7 @@ function waitUntil(condition, {
|
|
|
5914
5964
|
}
|
|
5915
5965
|
|
|
5916
5966
|
// src/commands/mobile/swipe.ts
|
|
5917
|
-
import
|
|
5967
|
+
import logger19 from "@wdio/logger";
|
|
5918
5968
|
|
|
5919
5969
|
// src/types.ts
|
|
5920
5970
|
var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
@@ -5926,7 +5976,7 @@ var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
|
5926
5976
|
})(MobileScrollDirection || {});
|
|
5927
5977
|
|
|
5928
5978
|
// src/commands/mobile/swipe.ts
|
|
5929
|
-
var
|
|
5979
|
+
var log19 = logger19("webdriverio");
|
|
5930
5980
|
var SWIPE_DEFAULTS = {
|
|
5931
5981
|
DIRECTION: "up" /* Up */,
|
|
5932
5982
|
DURATION: 1500,
|
|
@@ -5939,7 +5989,7 @@ async function swipe(options) {
|
|
|
5939
5989
|
}
|
|
5940
5990
|
let { scrollableElement, from, to } = options || {};
|
|
5941
5991
|
if (scrollableElement && (from || to)) {
|
|
5942
|
-
|
|
5992
|
+
log19.warn("`scrollableElement` is provided, so `from` and `to` will be ignored.");
|
|
5943
5993
|
}
|
|
5944
5994
|
if (!from || !to) {
|
|
5945
5995
|
scrollableElement = scrollableElement || await getScrollableElement(browser);
|
|
@@ -5961,9 +6011,9 @@ async function calculateFromTo({
|
|
|
5961
6011
|
let swipePercentage = SWIPE_DEFAULTS.PERCENT;
|
|
5962
6012
|
if (percentage !== void 0) {
|
|
5963
6013
|
if (isNaN(percentage)) {
|
|
5964
|
-
|
|
6014
|
+
log19.warn("The percentage to swipe should be a number.");
|
|
5965
6015
|
} else if (percentage < 0 || percentage > 1) {
|
|
5966
|
-
|
|
6016
|
+
log19.warn("The percentage to swipe should be a number between 0 and 1.");
|
|
5967
6017
|
} else {
|
|
5968
6018
|
swipePercentage = percentage;
|
|
5969
6019
|
}
|
|
@@ -6029,9 +6079,9 @@ async function w3cSwipe({ browser, duration, from, to }) {
|
|
|
6029
6079
|
}
|
|
6030
6080
|
|
|
6031
6081
|
// src/commands/mobile/tap.ts
|
|
6032
|
-
import
|
|
6082
|
+
import logger20 from "@wdio/logger";
|
|
6033
6083
|
import { getBrowserObject as getBrowserObject11 } from "@wdio/utils";
|
|
6034
|
-
var
|
|
6084
|
+
var log20 = logger20("webdriver");
|
|
6035
6085
|
async function tap(options) {
|
|
6036
6086
|
const isElement2 = this.selector !== void 0;
|
|
6037
6087
|
const element = isElement2 ? this : null;
|
|
@@ -6077,7 +6127,7 @@ async function elementTap(browser, element, options) {
|
|
|
6077
6127
|
return await nativeTap(element, browser, options);
|
|
6078
6128
|
}
|
|
6079
6129
|
if (options) {
|
|
6080
|
-
|
|
6130
|
+
log20.warn("The options object is not supported in Web environments and will be ignored.");
|
|
6081
6131
|
}
|
|
6082
6132
|
return await webTap(element);
|
|
6083
6133
|
}
|
|
@@ -6144,8 +6194,8 @@ async function screenTap(browser, options) {
|
|
|
6144
6194
|
}
|
|
6145
6195
|
|
|
6146
6196
|
// src/commands/mobile/getContext.ts
|
|
6147
|
-
import
|
|
6148
|
-
var
|
|
6197
|
+
import logger21 from "@wdio/logger";
|
|
6198
|
+
var log21 = logger21("webdriver");
|
|
6149
6199
|
async function getContext(options) {
|
|
6150
6200
|
const browser = this;
|
|
6151
6201
|
if (!browser.isMobile) {
|
|
@@ -6173,25 +6223,25 @@ async function getDetailedContext(browser, currentAppiumContext, options) {
|
|
|
6173
6223
|
});
|
|
6174
6224
|
const parsedContexts = detailedContexts.filter((context) => context.id === currentAppiumContext);
|
|
6175
6225
|
if (parsedContexts.length > 1) {
|
|
6176
|
-
|
|
6226
|
+
log21.warn("We found more than 1 detailed context for the current context '".concat(currentAppiumContext, "'. We will return the first context."));
|
|
6177
6227
|
return parsedContexts[0];
|
|
6178
6228
|
} else if (parsedContexts.length === 0) {
|
|
6179
|
-
|
|
6229
|
+
log21.warn("We did not get back any detailed context for the current context '".concat(currentAppiumContext, "'. We will return the current context as a string."));
|
|
6180
6230
|
return currentAppiumContext;
|
|
6181
6231
|
}
|
|
6182
6232
|
return parsedContexts[0];
|
|
6183
6233
|
}
|
|
6184
6234
|
|
|
6185
6235
|
// src/commands/mobile/getContexts.ts
|
|
6186
|
-
import
|
|
6187
|
-
var
|
|
6236
|
+
import logger22 from "@wdio/logger";
|
|
6237
|
+
var log22 = logger22("webdriver");
|
|
6188
6238
|
async function getContexts(options) {
|
|
6189
6239
|
const browser = this;
|
|
6190
6240
|
if (!browser.isMobile) {
|
|
6191
6241
|
throw new Error("The `getContexts` command is only available for mobile platforms.");
|
|
6192
6242
|
}
|
|
6193
6243
|
if (!options || !options.returnDetailedContexts) {
|
|
6194
|
-
|
|
6244
|
+
log22.info("The standard Appium `contexts` method is used. If you want to get more detailed data, you can set `returnDetailedContexts` to `true`.");
|
|
6195
6245
|
return browser.getAppiumContexts();
|
|
6196
6246
|
}
|
|
6197
6247
|
const defaultOptions = {
|
|
@@ -6321,8 +6371,8 @@ async function getCurrentContexts({
|
|
|
6321
6371
|
}
|
|
6322
6372
|
|
|
6323
6373
|
// src/commands/mobile/switchContext.ts
|
|
6324
|
-
import
|
|
6325
|
-
var
|
|
6374
|
+
import logger23 from "@wdio/logger";
|
|
6375
|
+
var log23 = logger23("webdriver");
|
|
6326
6376
|
async function switchContext(options) {
|
|
6327
6377
|
const browser = this;
|
|
6328
6378
|
if (!browser.isMobile) {
|
|
@@ -6332,7 +6382,7 @@ async function switchContext(options) {
|
|
|
6332
6382
|
throw new Error("You need to provide at least a context name to switch to. See https://webdriver.io/docs/api/mobile/switchContext for more information.");
|
|
6333
6383
|
}
|
|
6334
6384
|
if (typeof options === "string") {
|
|
6335
|
-
|
|
6385
|
+
log23.info("The standard Appium `context`-method is used. If you want to switch to a webview with a specific title or url, please provide an object with the `title` or `url` property. See https://webdriver.io/docs/api/mobile/switchContext for more information.");
|
|
6336
6386
|
return browser.switchAppiumContext(options);
|
|
6337
6387
|
}
|
|
6338
6388
|
if (!options.title && !options.url) {
|
|
@@ -6361,7 +6411,7 @@ async function switchToContext({ browser, options }) {
|
|
|
6361
6411
|
if (!matchingContext) {
|
|
6362
6412
|
throw new Error(reasons.join("\n"));
|
|
6363
6413
|
}
|
|
6364
|
-
|
|
6414
|
+
log23.info("WebdriverIO found a matching context:", JSON.stringify(matchingContext, null, 2));
|
|
6365
6415
|
if (!browser.isIOS) {
|
|
6366
6416
|
const webviewName = "WEBVIEW_".concat(identifier);
|
|
6367
6417
|
await browser.switchAppiumContext(webviewName);
|
|
@@ -6429,7 +6479,7 @@ async function relaunchActiveApp() {
|
|
|
6429
6479
|
}
|
|
6430
6480
|
|
|
6431
6481
|
// src/commands/mobile/deepLink.ts
|
|
6432
|
-
async function deepLink(link, appIdentifier) {
|
|
6482
|
+
async function deepLink(link, appIdentifier, waitForLaunch) {
|
|
6433
6483
|
const browser = this;
|
|
6434
6484
|
if (!browser.isMobile) {
|
|
6435
6485
|
throw new Error("The `deepLink` command is only available for mobile platforms.");
|
|
@@ -6442,16 +6492,778 @@ async function deepLink(link, appIdentifier) {
|
|
|
6442
6492
|
const identifierValue = browser.isIOS ? "bundleId" : "package";
|
|
6443
6493
|
throw new Error("When using a deep link URL for ".concat(mobileOS, ", you need to provide the `").concat(identifierValue, "` of the app that the deep link should open."));
|
|
6444
6494
|
}
|
|
6445
|
-
|
|
6495
|
+
const args = {
|
|
6446
6496
|
url: link,
|
|
6447
6497
|
[browser.isIOS ? "bundleId" : "package"]: appIdentifier
|
|
6448
|
-
}
|
|
6498
|
+
};
|
|
6499
|
+
if (!browser.isIOS && waitForLaunch !== void 0) {
|
|
6500
|
+
args.waitForLaunch = waitForLaunch;
|
|
6501
|
+
}
|
|
6502
|
+
return browser.execute("mobile:deepLink", args);
|
|
6449
6503
|
}
|
|
6450
6504
|
function isDeepLinkUrl(link) {
|
|
6451
6505
|
const deepLinkRegex = /^(?!https?:\/\/)[a-zA-Z][\w+\-.]*:\/\//;
|
|
6452
6506
|
return deepLinkRegex.test(link);
|
|
6453
6507
|
}
|
|
6454
6508
|
|
|
6509
|
+
// src/commands/mobile/lock.ts
|
|
6510
|
+
async function lock(seconds) {
|
|
6511
|
+
const browser = this;
|
|
6512
|
+
if (!browser.isMobile) {
|
|
6513
|
+
throw new Error("The `lock` command is only available for mobile platforms.");
|
|
6514
|
+
}
|
|
6515
|
+
try {
|
|
6516
|
+
return await browser.execute("mobile: lock", { seconds });
|
|
6517
|
+
} catch (err) {
|
|
6518
|
+
if (!isUnknownMethodError(err)) {
|
|
6519
|
+
throw err;
|
|
6520
|
+
}
|
|
6521
|
+
logAppiumDeprecationWarning("mobile: lock", "/appium/device/lock");
|
|
6522
|
+
return browser.appiumLock(seconds);
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
|
|
6526
|
+
// src/commands/mobile/touchId.ts
|
|
6527
|
+
async function touchId(match, type = "touchId") {
|
|
6528
|
+
const browser = this;
|
|
6529
|
+
if (!browser.isMobile) {
|
|
6530
|
+
throw new Error("The `touchId` command is only available for mobile platforms.");
|
|
6531
|
+
}
|
|
6532
|
+
if (!browser.isIOS) {
|
|
6533
|
+
throw new Error("The `touchId` command is only available for iOS. For Android, use `fingerPrint` instead.");
|
|
6534
|
+
}
|
|
6535
|
+
try {
|
|
6536
|
+
return await browser.execute("mobile: sendBiometricMatch", { match, type });
|
|
6537
|
+
} catch (err) {
|
|
6538
|
+
if (!isUnknownMethodError(err)) {
|
|
6539
|
+
throw err;
|
|
6540
|
+
}
|
|
6541
|
+
logAppiumDeprecationWarning("mobile: sendBiometricMatch", "/appium/simulator/touch_id");
|
|
6542
|
+
return browser.appiumTouchId(match);
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
|
|
6546
|
+
// src/commands/mobile/toggleEnrollTouchId.ts
|
|
6547
|
+
async function toggleEnrollTouchId(enabled) {
|
|
6548
|
+
const browser = this;
|
|
6549
|
+
if (!browser.isMobile) {
|
|
6550
|
+
throw new Error("The `toggleEnrollTouchId` command is only available for mobile platforms.");
|
|
6551
|
+
}
|
|
6552
|
+
if (!browser.isIOS) {
|
|
6553
|
+
throw new Error("The `toggleEnrollTouchId` command is only available for iOS.");
|
|
6554
|
+
}
|
|
6555
|
+
try {
|
|
6556
|
+
return await browser.execute("mobile: enrollBiometric", { enabled });
|
|
6557
|
+
} catch (err) {
|
|
6558
|
+
if (!isUnknownMethodError(err)) {
|
|
6559
|
+
throw err;
|
|
6560
|
+
}
|
|
6561
|
+
logAppiumDeprecationWarning("mobile: enrollBiometric", "/appium/simulator/toggle_touch_id_enrollment");
|
|
6562
|
+
return browser.appiumToggleEnrollTouchId(enabled);
|
|
6563
|
+
}
|
|
6564
|
+
}
|
|
6565
|
+
|
|
6566
|
+
// src/commands/mobile/launchApp.ts
|
|
6567
|
+
async function launchApp(options) {
|
|
6568
|
+
var _a, _b;
|
|
6569
|
+
const browser = this;
|
|
6570
|
+
if (!browser.isMobile) {
|
|
6571
|
+
throw new Error("The `launchApp` command is only available for mobile platforms.");
|
|
6572
|
+
}
|
|
6573
|
+
let mobileCmd;
|
|
6574
|
+
let mobileArgs;
|
|
6575
|
+
if (browser.isIOS) {
|
|
6576
|
+
mobileCmd = "mobile: launchApp";
|
|
6577
|
+
const bundleId = (_a = options == null ? void 0 : options.bundleId) != null ? _a : (await browser.execute("mobile: activeAppInfo")).bundleId;
|
|
6578
|
+
mobileArgs = { bundleId };
|
|
6579
|
+
if ((options == null ? void 0 : options.arguments) !== void 0) {
|
|
6580
|
+
mobileArgs.arguments = options.arguments;
|
|
6581
|
+
}
|
|
6582
|
+
if ((options == null ? void 0 : options.environment) !== void 0) {
|
|
6583
|
+
mobileArgs.environment = options.environment;
|
|
6584
|
+
}
|
|
6585
|
+
} else {
|
|
6586
|
+
mobileCmd = "mobile: activateApp";
|
|
6587
|
+
const appId = (_b = options == null ? void 0 : options.appId) != null ? _b : await browser.getCurrentPackage();
|
|
6588
|
+
mobileArgs = { appId };
|
|
6589
|
+
}
|
|
6590
|
+
try {
|
|
6591
|
+
return await browser.execute(mobileCmd, mobileArgs);
|
|
6592
|
+
} catch (err) {
|
|
6593
|
+
if (!isUnknownMethodError(err)) {
|
|
6594
|
+
throw err;
|
|
6595
|
+
}
|
|
6596
|
+
logAppiumDeprecationWarning(mobileCmd, "/appium/app/launch");
|
|
6597
|
+
return browser.appiumLaunchApp();
|
|
6598
|
+
}
|
|
6599
|
+
}
|
|
6600
|
+
|
|
6601
|
+
// src/commands/mobile/background.ts
|
|
6602
|
+
async function background(seconds) {
|
|
6603
|
+
const browser = this;
|
|
6604
|
+
if (!browser.isMobile) {
|
|
6605
|
+
throw new Error("The `background` command is only available for mobile platforms.");
|
|
6606
|
+
}
|
|
6607
|
+
try {
|
|
6608
|
+
return await browser.execute("mobile: backgroundApp", { seconds });
|
|
6609
|
+
} catch (err) {
|
|
6610
|
+
if (!isUnknownMethodError(err)) {
|
|
6611
|
+
throw err;
|
|
6612
|
+
}
|
|
6613
|
+
logAppiumDeprecationWarning("mobile: backgroundApp", "/appium/app/background");
|
|
6614
|
+
return browser.appiumBackground(seconds);
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
|
|
6618
|
+
// src/commands/mobile/getStrings.ts
|
|
6619
|
+
async function getStrings(language, stringFile) {
|
|
6620
|
+
const browser = this;
|
|
6621
|
+
if (!browser.isMobile) {
|
|
6622
|
+
throw new Error("The `getStrings` command is only available for mobile platforms.");
|
|
6623
|
+
}
|
|
6624
|
+
try {
|
|
6625
|
+
return await browser.execute("mobile: getAppStrings", { language, stringFile });
|
|
6626
|
+
} catch (err) {
|
|
6627
|
+
if (!isUnknownMethodError(err)) {
|
|
6628
|
+
throw err;
|
|
6629
|
+
}
|
|
6630
|
+
logAppiumDeprecationWarning("mobile: getAppStrings", "/appium/app/strings");
|
|
6631
|
+
return browser.appiumGetStrings(language, stringFile);
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
|
|
6635
|
+
// src/commands/mobile/setClipboard.ts
|
|
6636
|
+
async function setClipboard(content, contentType, label) {
|
|
6637
|
+
const browser = this;
|
|
6638
|
+
if (!browser.isMobile) {
|
|
6639
|
+
throw new Error("The `setClipboard` command is only available for mobile platforms.");
|
|
6640
|
+
}
|
|
6641
|
+
try {
|
|
6642
|
+
return await browser.execute("mobile: setClipboard", { content, contentType, label });
|
|
6643
|
+
} catch (err) {
|
|
6644
|
+
if (!isUnknownMethodError(err)) {
|
|
6645
|
+
throw err;
|
|
6646
|
+
}
|
|
6647
|
+
logAppiumDeprecationWarning("mobile: setClipboard", "/appium/device/set_clipboard");
|
|
6648
|
+
return browser.appiumSetClipboard(content, contentType, label);
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6651
|
+
|
|
6652
|
+
// src/commands/mobile/getClipboard.ts
|
|
6653
|
+
async function getClipboard(contentType) {
|
|
6654
|
+
const browser = this;
|
|
6655
|
+
if (!browser.isMobile) {
|
|
6656
|
+
throw new Error("The `getClipboard` command is only available for mobile platforms.");
|
|
6657
|
+
}
|
|
6658
|
+
try {
|
|
6659
|
+
return await browser.execute("mobile: getClipboard", { contentType });
|
|
6660
|
+
} catch (err) {
|
|
6661
|
+
if (!isUnknownMethodError(err)) {
|
|
6662
|
+
throw err;
|
|
6663
|
+
}
|
|
6664
|
+
logAppiumDeprecationWarning("mobile: getClipboard", "/appium/device/get_clipboard");
|
|
6665
|
+
return browser.appiumGetClipboard(contentType);
|
|
6666
|
+
}
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6669
|
+
// src/commands/mobile/queryAppState.ts
|
|
6670
|
+
async function queryAppState(appId, bundleId) {
|
|
6671
|
+
const browser = this;
|
|
6672
|
+
if (!browser.isMobile) {
|
|
6673
|
+
throw new Error("The `queryAppState` command is only available for mobile platforms.");
|
|
6674
|
+
}
|
|
6675
|
+
try {
|
|
6676
|
+
return await browser.execute("mobile: queryAppState", { appId, bundleId });
|
|
6677
|
+
} catch (err) {
|
|
6678
|
+
if (!isUnknownMethodError(err)) {
|
|
6679
|
+
throw err;
|
|
6680
|
+
}
|
|
6681
|
+
logAppiumDeprecationWarning("mobile: queryAppState", "/appium/device/app_state");
|
|
6682
|
+
return browser.appiumQueryAppState(appId, bundleId);
|
|
6683
|
+
}
|
|
6684
|
+
}
|
|
6685
|
+
|
|
6686
|
+
// src/commands/mobile/toggleAirplaneMode.ts
|
|
6687
|
+
async function toggleAirplaneMode(enabled) {
|
|
6688
|
+
const browser = this;
|
|
6689
|
+
if (!browser.isMobile) {
|
|
6690
|
+
throw new Error("The `toggleAirplaneMode` command is only available for mobile platforms.");
|
|
6691
|
+
}
|
|
6692
|
+
if (!browser.isAndroid) {
|
|
6693
|
+
throw new Error("The `toggleAirplaneMode` command is only available for Android.");
|
|
6694
|
+
}
|
|
6695
|
+
try {
|
|
6696
|
+
return await browser.execute("mobile: setConnectivity", { airplaneMode: enabled });
|
|
6697
|
+
} catch (err) {
|
|
6698
|
+
if (!isUnknownMethodError(err)) {
|
|
6699
|
+
throw err;
|
|
6700
|
+
}
|
|
6701
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_airplane_mode");
|
|
6702
|
+
return browser.appiumToggleAirplaneMode();
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
|
|
6706
|
+
// src/commands/mobile/toggleData.ts
|
|
6707
|
+
async function toggleData(enabled) {
|
|
6708
|
+
const browser = this;
|
|
6709
|
+
if (!browser.isMobile) {
|
|
6710
|
+
throw new Error("The `toggleData` command is only available for mobile platforms.");
|
|
6711
|
+
}
|
|
6712
|
+
if (!browser.isAndroid) {
|
|
6713
|
+
throw new Error("The `toggleData` command is only available for Android.");
|
|
6714
|
+
}
|
|
6715
|
+
try {
|
|
6716
|
+
return await browser.execute("mobile: setConnectivity", { data: enabled });
|
|
6717
|
+
} catch (err) {
|
|
6718
|
+
if (!isUnknownMethodError(err)) {
|
|
6719
|
+
throw err;
|
|
6720
|
+
}
|
|
6721
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_data");
|
|
6722
|
+
return browser.appiumToggleData();
|
|
6723
|
+
}
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6726
|
+
// src/commands/mobile/toggleWiFi.ts
|
|
6727
|
+
async function toggleWiFi(enabled) {
|
|
6728
|
+
const browser = this;
|
|
6729
|
+
if (!browser.isMobile) {
|
|
6730
|
+
throw new Error("The `toggleWiFi` command is only available for mobile platforms.");
|
|
6731
|
+
}
|
|
6732
|
+
if (!browser.isAndroid) {
|
|
6733
|
+
throw new Error("The `toggleWiFi` command is only available for Android.");
|
|
6734
|
+
}
|
|
6735
|
+
try {
|
|
6736
|
+
return await browser.execute("mobile: setConnectivity", { wifi: enabled });
|
|
6737
|
+
} catch (err) {
|
|
6738
|
+
if (!isUnknownMethodError(err)) {
|
|
6739
|
+
throw err;
|
|
6740
|
+
}
|
|
6741
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_wifi");
|
|
6742
|
+
return browser.appiumToggleWiFi();
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
|
|
6746
|
+
// src/commands/mobile/unlock.ts
|
|
6747
|
+
async function unlock(options) {
|
|
6748
|
+
const browser = this;
|
|
6749
|
+
if (!browser.isMobile) {
|
|
6750
|
+
throw new Error("The `unlock` command is only available for mobile platforms.");
|
|
6751
|
+
}
|
|
6752
|
+
const args = browser.isAndroid && options ? { ...options } : {};
|
|
6753
|
+
try {
|
|
6754
|
+
return await browser.execute("mobile: unlock", args);
|
|
6755
|
+
} catch (err) {
|
|
6756
|
+
if (!isUnknownMethodError(err)) {
|
|
6757
|
+
throw err;
|
|
6758
|
+
}
|
|
6759
|
+
logAppiumDeprecationWarning("mobile: unlock", "/appium/device/unlock");
|
|
6760
|
+
return browser.appiumUnlock();
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
|
|
6764
|
+
// src/commands/mobile/isLocked.ts
|
|
6765
|
+
async function isLocked() {
|
|
6766
|
+
const browser = this;
|
|
6767
|
+
if (!browser.isMobile) {
|
|
6768
|
+
throw new Error("The `isLocked` command is only available for mobile platforms.");
|
|
6769
|
+
}
|
|
6770
|
+
try {
|
|
6771
|
+
return await browser.execute("mobile: isLocked", {});
|
|
6772
|
+
} catch (err) {
|
|
6773
|
+
if (!isUnknownMethodError(err)) {
|
|
6774
|
+
throw err;
|
|
6775
|
+
}
|
|
6776
|
+
logAppiumDeprecationWarning("mobile: isLocked", "/appium/device/is_locked");
|
|
6777
|
+
return browser.appiumIsLocked();
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6781
|
+
// src/commands/mobile/shake.ts
|
|
6782
|
+
async function shake() {
|
|
6783
|
+
const browser = this;
|
|
6784
|
+
if (!browser.isMobile) {
|
|
6785
|
+
throw new Error("The `shake` command is only available for mobile platforms.");
|
|
6786
|
+
}
|
|
6787
|
+
if (!browser.isIOS) {
|
|
6788
|
+
throw new Error("The `shake` command is only available for iOS.");
|
|
6789
|
+
}
|
|
6790
|
+
try {
|
|
6791
|
+
return await browser.execute("mobile: shake", {});
|
|
6792
|
+
} catch (err) {
|
|
6793
|
+
if (!isUnknownMethodError(err)) {
|
|
6794
|
+
throw err;
|
|
6795
|
+
}
|
|
6796
|
+
logAppiumDeprecationWarning("mobile: shake", "/appium/device/shake");
|
|
6797
|
+
return browser.appiumShake();
|
|
6798
|
+
}
|
|
6799
|
+
}
|
|
6800
|
+
|
|
6801
|
+
// src/commands/mobile/closeApp.ts
|
|
6802
|
+
async function closeApp(options) {
|
|
6803
|
+
var _a, _b;
|
|
6804
|
+
const browser = this;
|
|
6805
|
+
if (!browser.isMobile) {
|
|
6806
|
+
throw new Error("The `closeApp` command is only available for mobile platforms.");
|
|
6807
|
+
}
|
|
6808
|
+
let terminateArgs;
|
|
6809
|
+
if (browser.isIOS) {
|
|
6810
|
+
const bundleId = (_a = options == null ? void 0 : options.bundleId) != null ? _a : (await browser.execute("mobile: activeAppInfo")).bundleId;
|
|
6811
|
+
terminateArgs = { bundleId };
|
|
6812
|
+
} else {
|
|
6813
|
+
const appId = (_b = options == null ? void 0 : options.appId) != null ? _b : await browser.getCurrentPackage();
|
|
6814
|
+
terminateArgs = { appId };
|
|
6815
|
+
}
|
|
6816
|
+
try {
|
|
6817
|
+
return await browser.execute("mobile: terminateApp", terminateArgs);
|
|
6818
|
+
} catch (err) {
|
|
6819
|
+
if (!isUnknownMethodError(err)) {
|
|
6820
|
+
throw err;
|
|
6821
|
+
}
|
|
6822
|
+
logAppiumDeprecationWarning("mobile: terminateApp", "/appium/app/close");
|
|
6823
|
+
return browser.appiumCloseApp();
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6826
|
+
|
|
6827
|
+
// src/commands/mobile/getCurrentActivity.ts
|
|
6828
|
+
async function getCurrentActivity() {
|
|
6829
|
+
const browser = this;
|
|
6830
|
+
if (!browser.isMobile) {
|
|
6831
|
+
throw new Error("The `getCurrentActivity` command is only available for mobile platforms.");
|
|
6832
|
+
}
|
|
6833
|
+
if (!browser.isAndroid) {
|
|
6834
|
+
throw new Error("The `getCurrentActivity` command is only available for Android.");
|
|
6835
|
+
}
|
|
6836
|
+
try {
|
|
6837
|
+
return await browser.execute("mobile: getCurrentActivity", {});
|
|
6838
|
+
} catch (err) {
|
|
6839
|
+
if (!isUnknownMethodError(err)) {
|
|
6840
|
+
throw err;
|
|
6841
|
+
}
|
|
6842
|
+
logAppiumDeprecationWarning("mobile: getCurrentActivity", "/appium/device/current_activity");
|
|
6843
|
+
return browser.appiumGetCurrentActivity();
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
|
|
6847
|
+
// src/commands/mobile/getCurrentPackage.ts
|
|
6848
|
+
async function getCurrentPackage() {
|
|
6849
|
+
const browser = this;
|
|
6850
|
+
if (!browser.isMobile) {
|
|
6851
|
+
throw new Error("The `getCurrentPackage` command is only available for mobile platforms.");
|
|
6852
|
+
}
|
|
6853
|
+
if (!browser.isAndroid) {
|
|
6854
|
+
throw new Error("The `getCurrentPackage` command is only available for Android.");
|
|
6855
|
+
}
|
|
6856
|
+
try {
|
|
6857
|
+
return await browser.execute("mobile: getCurrentPackage", {});
|
|
6858
|
+
} catch (err) {
|
|
6859
|
+
if (!isUnknownMethodError(err)) {
|
|
6860
|
+
throw err;
|
|
6861
|
+
}
|
|
6862
|
+
logAppiumDeprecationWarning("mobile: getCurrentPackage", "/appium/device/current_package");
|
|
6863
|
+
return browser.appiumGetCurrentPackage();
|
|
6864
|
+
}
|
|
6865
|
+
}
|
|
6866
|
+
|
|
6867
|
+
// src/commands/mobile/getPerformanceData.ts
|
|
6868
|
+
async function getPerformanceData(packageName, dataType, dataReadTimeout) {
|
|
6869
|
+
const browser = this;
|
|
6870
|
+
if (!browser.isMobile) {
|
|
6871
|
+
throw new Error("The `getPerformanceData` command is only available for mobile platforms.");
|
|
6872
|
+
}
|
|
6873
|
+
if (!browser.isAndroid) {
|
|
6874
|
+
throw new Error("The `getPerformanceData` command is only available for Android.");
|
|
6875
|
+
}
|
|
6876
|
+
try {
|
|
6877
|
+
return await browser.execute("mobile: getPerformanceData", { packageName, dataType, dataReadTimeout });
|
|
6878
|
+
} catch (err) {
|
|
6879
|
+
if (!isUnknownMethodError(err)) {
|
|
6880
|
+
throw err;
|
|
6881
|
+
}
|
|
6882
|
+
logAppiumDeprecationWarning("mobile: getPerformanceData", "/appium/getPerformanceData");
|
|
6883
|
+
return browser.appiumGetPerformanceData(packageName, dataType, dataReadTimeout);
|
|
6884
|
+
}
|
|
6885
|
+
}
|
|
6886
|
+
|
|
6887
|
+
// src/commands/mobile/getPerformanceDataTypes.ts
|
|
6888
|
+
async function getPerformanceDataTypes() {
|
|
6889
|
+
const browser = this;
|
|
6890
|
+
if (!browser.isMobile) {
|
|
6891
|
+
throw new Error("The `getPerformanceDataTypes` command is only available for mobile platforms.");
|
|
6892
|
+
}
|
|
6893
|
+
if (!browser.isAndroid) {
|
|
6894
|
+
throw new Error("The `getPerformanceDataTypes` command is only available for Android.");
|
|
6895
|
+
}
|
|
6896
|
+
try {
|
|
6897
|
+
return await browser.execute("mobile: getPerformanceDataTypes", {});
|
|
6898
|
+
} catch (err) {
|
|
6899
|
+
if (!isUnknownMethodError(err)) {
|
|
6900
|
+
throw err;
|
|
6901
|
+
}
|
|
6902
|
+
logAppiumDeprecationWarning("mobile: getPerformanceDataTypes", "/appium/performanceData/types");
|
|
6903
|
+
return browser.appiumGetPerformanceDataTypes();
|
|
6904
|
+
}
|
|
6905
|
+
}
|
|
6906
|
+
|
|
6907
|
+
// src/commands/mobile/getSystemBars.ts
|
|
6908
|
+
async function getSystemBars() {
|
|
6909
|
+
const browser = this;
|
|
6910
|
+
if (!browser.isMobile) {
|
|
6911
|
+
throw new Error("The `getSystemBars` command is only available for mobile platforms.");
|
|
6912
|
+
}
|
|
6913
|
+
if (!browser.isAndroid) {
|
|
6914
|
+
throw new Error("The `getSystemBars` command is only available for Android.");
|
|
6915
|
+
}
|
|
6916
|
+
try {
|
|
6917
|
+
return await browser.execute("mobile: getSystemBars", {});
|
|
6918
|
+
} catch (err) {
|
|
6919
|
+
if (!isUnknownMethodError(err)) {
|
|
6920
|
+
throw err;
|
|
6921
|
+
}
|
|
6922
|
+
logAppiumDeprecationWarning("mobile: getSystemBars", "/appium/device/system_bars");
|
|
6923
|
+
return browser.appiumGetSystemBars();
|
|
6924
|
+
}
|
|
6925
|
+
}
|
|
6926
|
+
|
|
6927
|
+
// src/commands/mobile/getDisplayDensity.ts
|
|
6928
|
+
async function getDisplayDensity() {
|
|
6929
|
+
const browser = this;
|
|
6930
|
+
if (!browser.isMobile) {
|
|
6931
|
+
throw new Error("The `getDisplayDensity` command is only available for mobile platforms.");
|
|
6932
|
+
}
|
|
6933
|
+
if (!browser.isAndroid) {
|
|
6934
|
+
throw new Error("The `getDisplayDensity` command is only available for Android.");
|
|
6935
|
+
}
|
|
6936
|
+
try {
|
|
6937
|
+
return await browser.execute("mobile: getDisplayDensity", {});
|
|
6938
|
+
} catch (err) {
|
|
6939
|
+
if (!isUnknownMethodError(err)) {
|
|
6940
|
+
throw err;
|
|
6941
|
+
}
|
|
6942
|
+
logAppiumDeprecationWarning("mobile: getDisplayDensity", "/appium/device/display_density");
|
|
6943
|
+
return browser.appiumGetDisplayDensity();
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
|
|
6947
|
+
// src/commands/mobile/pressKeyCode.ts
|
|
6948
|
+
async function pressKeyCode(keycode, metastate, flags) {
|
|
6949
|
+
const browser = this;
|
|
6950
|
+
if (!browser.isMobile) {
|
|
6951
|
+
throw new Error("The `pressKeyCode` command is only available for mobile platforms.");
|
|
6952
|
+
}
|
|
6953
|
+
if (!browser.isAndroid) {
|
|
6954
|
+
throw new Error("The `pressKeyCode` command is only available for Android.");
|
|
6955
|
+
}
|
|
6956
|
+
try {
|
|
6957
|
+
return await browser.execute("mobile: pressKey", { keycode, metastate, flags });
|
|
6958
|
+
} catch (err) {
|
|
6959
|
+
if (!isUnknownMethodError(err)) {
|
|
6960
|
+
throw err;
|
|
6961
|
+
}
|
|
6962
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/press_keycode");
|
|
6963
|
+
return browser.appiumPressKeyCode(keycode, metastate, flags);
|
|
6964
|
+
}
|
|
6965
|
+
}
|
|
6966
|
+
|
|
6967
|
+
// src/commands/mobile/longPressKeyCode.ts
|
|
6968
|
+
async function longPressKeyCode(keycode, metastate, flags) {
|
|
6969
|
+
const browser = this;
|
|
6970
|
+
if (!browser.isMobile) {
|
|
6971
|
+
throw new Error("The `longPressKeyCode` command is only available for mobile platforms.");
|
|
6972
|
+
}
|
|
6973
|
+
if (!browser.isAndroid) {
|
|
6974
|
+
throw new Error("The `longPressKeyCode` command is only available for Android.");
|
|
6975
|
+
}
|
|
6976
|
+
try {
|
|
6977
|
+
return await browser.execute("mobile: pressKey", { keycode, metastate, flags, isLongPress: true });
|
|
6978
|
+
} catch (err) {
|
|
6979
|
+
if (!isUnknownMethodError(err)) {
|
|
6980
|
+
throw err;
|
|
6981
|
+
}
|
|
6982
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/long_press_keycode");
|
|
6983
|
+
return browser.appiumLongPressKeyCode(keycode, metastate, flags);
|
|
6984
|
+
}
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6987
|
+
// src/commands/mobile/sendKeyEvent.ts
|
|
6988
|
+
async function sendKeyEvent(keycode, metastate) {
|
|
6989
|
+
const browser = this;
|
|
6990
|
+
if (!browser.isMobile) {
|
|
6991
|
+
throw new Error("The `sendKeyEvent` command is only available for mobile platforms.");
|
|
6992
|
+
}
|
|
6993
|
+
if (!browser.isAndroid) {
|
|
6994
|
+
throw new Error("The `sendKeyEvent` command is only available for Android.");
|
|
6995
|
+
}
|
|
6996
|
+
try {
|
|
6997
|
+
const args = { keycode: parseInt(keycode, 10) };
|
|
6998
|
+
if (metastate !== void 0) {
|
|
6999
|
+
args.metastate = parseInt(metastate, 10);
|
|
7000
|
+
}
|
|
7001
|
+
return await browser.execute("mobile: pressKey", args);
|
|
7002
|
+
} catch (err) {
|
|
7003
|
+
if (!isUnknownMethodError(err)) {
|
|
7004
|
+
throw err;
|
|
7005
|
+
}
|
|
7006
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/keyevent");
|
|
7007
|
+
return browser.appiumSendKeyEvent(keycode, metastate);
|
|
7008
|
+
}
|
|
7009
|
+
}
|
|
7010
|
+
|
|
7011
|
+
// src/commands/mobile/startActivity.ts
|
|
7012
|
+
async function startActivity(appPackageOrOptions, appActivity, appWaitPackage, appWaitActivity, intentAction, intentCategory, intentFlags, optionalIntentArguments, dontStopAppOnReset) {
|
|
7013
|
+
const browser = this;
|
|
7014
|
+
if (!browser.isMobile) {
|
|
7015
|
+
throw new Error("The `startActivity` command is only available for mobile platforms.");
|
|
7016
|
+
}
|
|
7017
|
+
if (!browser.isAndroid) {
|
|
7018
|
+
throw new Error("The `startActivity` command is only available for Android.");
|
|
7019
|
+
}
|
|
7020
|
+
const opts = typeof appPackageOrOptions === "object" ? appPackageOrOptions : {
|
|
7021
|
+
appPackage: appPackageOrOptions,
|
|
7022
|
+
appActivity,
|
|
7023
|
+
appWaitPackage,
|
|
7024
|
+
appWaitActivity,
|
|
7025
|
+
intentAction,
|
|
7026
|
+
intentCategory,
|
|
7027
|
+
intentFlags,
|
|
7028
|
+
optionalIntentArguments,
|
|
7029
|
+
dontStopAppOnReset
|
|
7030
|
+
};
|
|
7031
|
+
const mobileArgs = {
|
|
7032
|
+
component: "".concat(opts.appPackage, "/").concat(opts.appActivity)
|
|
7033
|
+
};
|
|
7034
|
+
if (opts.intentAction !== void 0) {
|
|
7035
|
+
mobileArgs.action = opts.intentAction;
|
|
7036
|
+
}
|
|
7037
|
+
if (opts.intentCategory !== void 0) {
|
|
7038
|
+
mobileArgs.categories = opts.intentCategory;
|
|
7039
|
+
}
|
|
7040
|
+
if (opts.intentFlags !== void 0) {
|
|
7041
|
+
mobileArgs.flags = opts.intentFlags;
|
|
7042
|
+
}
|
|
7043
|
+
if (opts.dontStopAppOnReset !== void 0) {
|
|
7044
|
+
mobileArgs.stop = opts.dontStopAppOnReset !== "true";
|
|
7045
|
+
}
|
|
7046
|
+
try {
|
|
7047
|
+
return await browser.execute("mobile: startActivity", mobileArgs);
|
|
7048
|
+
} catch (err) {
|
|
7049
|
+
if (!isUnknownMethodError(err)) {
|
|
7050
|
+
throw err;
|
|
7051
|
+
}
|
|
7052
|
+
logAppiumDeprecationWarning("mobile: startActivity", "/appium/device/start_activity");
|
|
7053
|
+
return browser.appiumStartActivity(
|
|
7054
|
+
opts.appPackage,
|
|
7055
|
+
opts.appActivity,
|
|
7056
|
+
opts.appWaitPackage,
|
|
7057
|
+
opts.appWaitActivity,
|
|
7058
|
+
opts.intentAction,
|
|
7059
|
+
opts.intentCategory,
|
|
7060
|
+
opts.intentFlags,
|
|
7061
|
+
opts.optionalIntentArguments,
|
|
7062
|
+
opts.dontStopAppOnReset
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7065
|
+
}
|
|
7066
|
+
|
|
7067
|
+
// src/commands/mobile/openNotifications.ts
|
|
7068
|
+
async function openNotifications() {
|
|
7069
|
+
const browser = this;
|
|
7070
|
+
if (!browser.isMobile) {
|
|
7071
|
+
throw new Error("The `openNotifications` command is only available for mobile platforms.");
|
|
7072
|
+
}
|
|
7073
|
+
if (!browser.isAndroid) {
|
|
7074
|
+
throw new Error("The `openNotifications` command is only available for Android.");
|
|
7075
|
+
}
|
|
7076
|
+
try {
|
|
7077
|
+
return await browser.execute("mobile: openNotifications", {});
|
|
7078
|
+
} catch (err) {
|
|
7079
|
+
if (!isUnknownMethodError(err)) {
|
|
7080
|
+
throw err;
|
|
7081
|
+
}
|
|
7082
|
+
logAppiumDeprecationWarning("mobile: openNotifications", "/appium/device/open_notifications");
|
|
7083
|
+
return browser.appiumOpenNotifications();
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
|
|
7087
|
+
// src/commands/mobile/toggleLocationServices.ts
|
|
7088
|
+
async function toggleLocationServices() {
|
|
7089
|
+
const browser = this;
|
|
7090
|
+
if (!browser.isMobile) {
|
|
7091
|
+
throw new Error("The `toggleLocationServices` command is only available for mobile platforms.");
|
|
7092
|
+
}
|
|
7093
|
+
if (!browser.isAndroid) {
|
|
7094
|
+
throw new Error("The `toggleLocationServices` command is only available for Android.");
|
|
7095
|
+
}
|
|
7096
|
+
try {
|
|
7097
|
+
return await browser.execute("mobile: toggleGps", {});
|
|
7098
|
+
} catch (err) {
|
|
7099
|
+
if (!isUnknownMethodError(err)) {
|
|
7100
|
+
throw err;
|
|
7101
|
+
}
|
|
7102
|
+
logAppiumDeprecationWarning("mobile: toggleGps", "/appium/device/toggle_location_services");
|
|
7103
|
+
return browser.appiumToggleLocationServices();
|
|
7104
|
+
}
|
|
7105
|
+
}
|
|
7106
|
+
|
|
7107
|
+
// src/commands/mobile/toggleNetworkSpeed.ts
|
|
7108
|
+
async function toggleNetworkSpeed(netspeed) {
|
|
7109
|
+
const browser = this;
|
|
7110
|
+
if (!browser.isMobile) {
|
|
7111
|
+
throw new Error("The `toggleNetworkSpeed` command is only available for mobile platforms.");
|
|
7112
|
+
}
|
|
7113
|
+
if (!browser.isAndroid) {
|
|
7114
|
+
throw new Error("The `toggleNetworkSpeed` command is only available for Android.");
|
|
7115
|
+
}
|
|
7116
|
+
try {
|
|
7117
|
+
return await browser.execute("mobile: networkSpeed", { netspeed });
|
|
7118
|
+
} catch (err) {
|
|
7119
|
+
if (!isUnknownMethodError(err)) {
|
|
7120
|
+
throw err;
|
|
7121
|
+
}
|
|
7122
|
+
logAppiumDeprecationWarning("mobile: networkSpeed", "/appium/device/network_speed");
|
|
7123
|
+
return browser.appiumToggleNetworkSpeed(netspeed);
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
|
|
7127
|
+
// src/commands/mobile/gsmCall.ts
|
|
7128
|
+
async function gsmCall(phoneNumber, action2) {
|
|
7129
|
+
const browser = this;
|
|
7130
|
+
if (!browser.isMobile) {
|
|
7131
|
+
throw new Error("The `gsmCall` command is only available for mobile platforms.");
|
|
7132
|
+
}
|
|
7133
|
+
if (!browser.isAndroid) {
|
|
7134
|
+
throw new Error("The `gsmCall` command is only available for Android.");
|
|
7135
|
+
}
|
|
7136
|
+
try {
|
|
7137
|
+
return await browser.execute("mobile: gsmCall", { phoneNumber, action: action2 });
|
|
7138
|
+
} catch (err) {
|
|
7139
|
+
if (!isUnknownMethodError(err)) {
|
|
7140
|
+
throw err;
|
|
7141
|
+
}
|
|
7142
|
+
logAppiumDeprecationWarning("mobile: gsmCall", "/appium/device/gsm_call");
|
|
7143
|
+
return browser.appiumGsmCall(phoneNumber, action2);
|
|
7144
|
+
}
|
|
7145
|
+
}
|
|
7146
|
+
|
|
7147
|
+
// src/commands/mobile/gsmSignal.ts
|
|
7148
|
+
async function gsmSignal(signalStrength) {
|
|
7149
|
+
const browser = this;
|
|
7150
|
+
if (!browser.isMobile) {
|
|
7151
|
+
throw new Error("The `gsmSignal` command is only available for mobile platforms.");
|
|
7152
|
+
}
|
|
7153
|
+
if (!browser.isAndroid) {
|
|
7154
|
+
throw new Error("The `gsmSignal` command is only available for Android.");
|
|
7155
|
+
}
|
|
7156
|
+
try {
|
|
7157
|
+
return await browser.execute("mobile: gsmSignal", { signalStrength });
|
|
7158
|
+
} catch (err) {
|
|
7159
|
+
if (!isUnknownMethodError(err)) {
|
|
7160
|
+
throw err;
|
|
7161
|
+
}
|
|
7162
|
+
logAppiumDeprecationWarning("mobile: gsmSignal", "/appium/device/gsm_signal");
|
|
7163
|
+
return browser.appiumGsmSignal(String(signalStrength));
|
|
7164
|
+
}
|
|
7165
|
+
}
|
|
7166
|
+
|
|
7167
|
+
// src/commands/mobile/gsmVoice.ts
|
|
7168
|
+
async function gsmVoice(state) {
|
|
7169
|
+
const browser = this;
|
|
7170
|
+
if (!browser.isMobile) {
|
|
7171
|
+
throw new Error("The `gsmVoice` command is only available for mobile platforms.");
|
|
7172
|
+
}
|
|
7173
|
+
if (!browser.isAndroid) {
|
|
7174
|
+
throw new Error("The `gsmVoice` command is only available for Android.");
|
|
7175
|
+
}
|
|
7176
|
+
try {
|
|
7177
|
+
return await browser.execute("mobile: gsmVoice", { state });
|
|
7178
|
+
} catch (err) {
|
|
7179
|
+
if (!isUnknownMethodError(err)) {
|
|
7180
|
+
throw err;
|
|
7181
|
+
}
|
|
7182
|
+
logAppiumDeprecationWarning("mobile: gsmVoice", "/appium/device/gsm_voice");
|
|
7183
|
+
return browser.appiumGsmVoice(state);
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
|
|
7187
|
+
// src/commands/mobile/sendSms.ts
|
|
7188
|
+
async function sendSms(phoneNumber, message) {
|
|
7189
|
+
const browser = this;
|
|
7190
|
+
if (!browser.isMobile) {
|
|
7191
|
+
throw new Error("The `sendSms` command is only available for mobile platforms.");
|
|
7192
|
+
}
|
|
7193
|
+
if (!browser.isAndroid) {
|
|
7194
|
+
throw new Error("The `sendSms` command is only available for Android.");
|
|
7195
|
+
}
|
|
7196
|
+
try {
|
|
7197
|
+
return await browser.execute("mobile: sendSms", { phoneNumber, message });
|
|
7198
|
+
} catch (err) {
|
|
7199
|
+
if (!isUnknownMethodError(err)) {
|
|
7200
|
+
throw err;
|
|
7201
|
+
}
|
|
7202
|
+
logAppiumDeprecationWarning("mobile: sendSms", "/appium/device/send_sms");
|
|
7203
|
+
return browser.appiumSendSms(phoneNumber, message);
|
|
7204
|
+
}
|
|
7205
|
+
}
|
|
7206
|
+
|
|
7207
|
+
// src/commands/mobile/fingerPrint.ts
|
|
7208
|
+
async function fingerPrint(fingerprintId) {
|
|
7209
|
+
const browser = this;
|
|
7210
|
+
if (!browser.isMobile) {
|
|
7211
|
+
throw new Error("The `fingerPrint` command is only available for mobile platforms.");
|
|
7212
|
+
}
|
|
7213
|
+
if (!browser.isAndroid) {
|
|
7214
|
+
throw new Error("The `fingerPrint` command is only available for Android. For iOS, use `touchId` instead.");
|
|
7215
|
+
}
|
|
7216
|
+
try {
|
|
7217
|
+
return await browser.execute("mobile: fingerprint", { fingerprintId });
|
|
7218
|
+
} catch (err) {
|
|
7219
|
+
if (!isUnknownMethodError(err)) {
|
|
7220
|
+
throw err;
|
|
7221
|
+
}
|
|
7222
|
+
logAppiumDeprecationWarning("mobile: fingerprint", "/appium/device/finger_print");
|
|
7223
|
+
return browser.appiumFingerPrint(fingerprintId);
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
|
|
7227
|
+
// src/commands/mobile/powerCapacity.ts
|
|
7228
|
+
async function powerCapacity(percent) {
|
|
7229
|
+
const browser = this;
|
|
7230
|
+
if (!browser.isMobile) {
|
|
7231
|
+
throw new Error("The `powerCapacity` command is only available for mobile platforms.");
|
|
7232
|
+
}
|
|
7233
|
+
if (!browser.isAndroid) {
|
|
7234
|
+
throw new Error("The `powerCapacity` command is only available for Android.");
|
|
7235
|
+
}
|
|
7236
|
+
try {
|
|
7237
|
+
return await browser.execute("mobile: powerCapacity", { percent });
|
|
7238
|
+
} catch (err) {
|
|
7239
|
+
if (!isUnknownMethodError(err)) {
|
|
7240
|
+
throw err;
|
|
7241
|
+
}
|
|
7242
|
+
logAppiumDeprecationWarning("mobile: powerCapacity", "/appium/device/power_capacity");
|
|
7243
|
+
return browser.appiumPowerCapacity(percent);
|
|
7244
|
+
}
|
|
7245
|
+
}
|
|
7246
|
+
|
|
7247
|
+
// src/commands/mobile/powerAC.ts
|
|
7248
|
+
async function powerAC(state) {
|
|
7249
|
+
const browser = this;
|
|
7250
|
+
if (!browser.isMobile) {
|
|
7251
|
+
throw new Error("The `powerAC` command is only available for mobile platforms.");
|
|
7252
|
+
}
|
|
7253
|
+
if (!browser.isAndroid) {
|
|
7254
|
+
throw new Error("The `powerAC` command is only available for Android.");
|
|
7255
|
+
}
|
|
7256
|
+
try {
|
|
7257
|
+
return await browser.execute("mobile: powerAC", { state });
|
|
7258
|
+
} catch (err) {
|
|
7259
|
+
if (!isUnknownMethodError(err)) {
|
|
7260
|
+
throw err;
|
|
7261
|
+
}
|
|
7262
|
+
logAppiumDeprecationWarning("mobile: powerAC", "/appium/device/power_ac");
|
|
7263
|
+
return browser.appiumPowerAC(state);
|
|
7264
|
+
}
|
|
7265
|
+
}
|
|
7266
|
+
|
|
6455
7267
|
// src/commands/element.ts
|
|
6456
7268
|
var element_exports = {};
|
|
6457
7269
|
__export(element_exports, {
|
|
@@ -6540,9 +7352,9 @@ function clearValue() {
|
|
|
6540
7352
|
}
|
|
6541
7353
|
|
|
6542
7354
|
// src/commands/element/click.ts
|
|
6543
|
-
import
|
|
7355
|
+
import logger24 from "@wdio/logger";
|
|
6544
7356
|
import { getBrowserObject as getBrowserObject12 } from "@wdio/utils";
|
|
6545
|
-
var
|
|
7357
|
+
var log24 = logger24("webdriver");
|
|
6546
7358
|
function click(options) {
|
|
6547
7359
|
if (typeof options !== "undefined") {
|
|
6548
7360
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
@@ -6589,10 +7401,10 @@ async function actionClick(element, options) {
|
|
|
6589
7401
|
if (x || y) {
|
|
6590
7402
|
const { width, height } = await browser.getElementRect(element.elementId);
|
|
6591
7403
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
6592
|
-
|
|
7404
|
+
log24.warn("x would cause a out of bounds error as it goes outside of element");
|
|
6593
7405
|
}
|
|
6594
7406
|
if (y && y < -Math.floor(height / 2) || y && y > Math.floor(height / 2)) {
|
|
6595
|
-
|
|
7407
|
+
log24.warn("y would cause a out of bounds error as it goes outside of element");
|
|
6596
7408
|
}
|
|
6597
7409
|
}
|
|
6598
7410
|
const clickNested = async () => {
|
|
@@ -7480,18 +8292,18 @@ async function isStable() {
|
|
|
7480
8292
|
}
|
|
7481
8293
|
|
|
7482
8294
|
// src/commands/element/moveTo.ts
|
|
7483
|
-
import
|
|
8295
|
+
import logger25 from "@wdio/logger";
|
|
7484
8296
|
import { getBrowserObject as getBrowserObject26 } from "@wdio/utils";
|
|
7485
|
-
var
|
|
8297
|
+
var log25 = logger25("webdriver");
|
|
7486
8298
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
7487
8299
|
const browser = getBrowserObject26(this);
|
|
7488
8300
|
if (xOffset || yOffset) {
|
|
7489
8301
|
const { width, height } = await browser.getElementRect(this.elementId);
|
|
7490
8302
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
7491
|
-
|
|
8303
|
+
log25.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
7492
8304
|
}
|
|
7493
8305
|
if (yOffset && yOffset < -Math.floor(height / 2) || yOffset && yOffset > Math.floor(height / 2)) {
|
|
7494
|
-
|
|
8306
|
+
log25.warn("yOffset would cause a out of bounds error as it goes outside of element");
|
|
7495
8307
|
}
|
|
7496
8308
|
}
|
|
7497
8309
|
const moveToNested = async () => {
|
|
@@ -7575,10 +8387,10 @@ async function saveScreenshot2(filepath) {
|
|
|
7575
8387
|
}
|
|
7576
8388
|
|
|
7577
8389
|
// src/commands/element/scrollIntoView.ts
|
|
7578
|
-
import
|
|
8390
|
+
import logger26 from "@wdio/logger";
|
|
7579
8391
|
import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
|
|
7580
8392
|
import { getBrowserObject as getBrowserObject29 } from "@wdio/utils";
|
|
7581
|
-
var
|
|
8393
|
+
var log26 = logger26("webdriverio");
|
|
7582
8394
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
7583
8395
|
const browser = getBrowserObject29(this);
|
|
7584
8396
|
if (browser.isMobile) {
|
|
@@ -7631,7 +8443,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
7631
8443
|
deltaY = Math.round(deltaY - scrollY);
|
|
7632
8444
|
await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
7633
8445
|
} catch (err) {
|
|
7634
|
-
|
|
8446
|
+
log26.warn(
|
|
7635
8447
|
'Failed to execute "scrollIntoView" using WebDriver Actions API: '.concat(err.message, "!\n") + "Re-attempting using `Element.scrollIntoView` via Web API."
|
|
7636
8448
|
);
|
|
7637
8449
|
await scrollIntoViewWeb.call(this, options);
|
|
@@ -7782,7 +8594,7 @@ async function setValue(value, options) {
|
|
|
7782
8594
|
}
|
|
7783
8595
|
|
|
7784
8596
|
// src/commands/element/shadow$$.ts
|
|
7785
|
-
import
|
|
8597
|
+
import logger27 from "@wdio/logger";
|
|
7786
8598
|
import { getBrowserObject as getBrowserObject30 } from "@wdio/utils";
|
|
7787
8599
|
import { SHADOW_ELEMENT_KEY } from "webdriver";
|
|
7788
8600
|
|
|
@@ -8118,7 +8930,7 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
8118
8930
|
};
|
|
8119
8931
|
|
|
8120
8932
|
// src/commands/element/shadow$$.ts
|
|
8121
|
-
var
|
|
8933
|
+
var log27 = logger27("webdriverio");
|
|
8122
8934
|
async function shadow$$(selector) {
|
|
8123
8935
|
const browser = getBrowserObject30(this);
|
|
8124
8936
|
try {
|
|
@@ -8128,7 +8940,7 @@ async function shadow$$(selector) {
|
|
|
8128
8940
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
8129
8941
|
return enhanceElementsArray(elements, this, selector);
|
|
8130
8942
|
} catch (err) {
|
|
8131
|
-
|
|
8943
|
+
log27.warn(
|
|
8132
8944
|
"Failed to fetch element within shadow DOM using WebDriver command: ".concat(err.message, "!\n") + "Falling back to JavaScript shim."
|
|
8133
8945
|
);
|
|
8134
8946
|
return await this.$$(shadowFnFactory(selector, true));
|
|
@@ -8136,10 +8948,10 @@ async function shadow$$(selector) {
|
|
|
8136
8948
|
}
|
|
8137
8949
|
|
|
8138
8950
|
// src/commands/element/shadow$.ts
|
|
8139
|
-
import
|
|
8951
|
+
import logger28 from "@wdio/logger";
|
|
8140
8952
|
import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
|
|
8141
8953
|
import { getBrowserObject as getBrowserObject31 } from "@wdio/utils";
|
|
8142
|
-
var
|
|
8954
|
+
var log28 = logger28("webdriverio");
|
|
8143
8955
|
async function shadow$(selector) {
|
|
8144
8956
|
const browser = getBrowserObject31(this);
|
|
8145
8957
|
try {
|
|
@@ -8148,7 +8960,7 @@ async function shadow$(selector) {
|
|
|
8148
8960
|
const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
8149
8961
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
8150
8962
|
} catch (err) {
|
|
8151
|
-
|
|
8963
|
+
log28.warn(
|
|
8152
8964
|
"Failed to fetch element within shadow DOM using WebDriver command: ".concat(err.message, "!\n") + "Falling back to JavaScript shim."
|
|
8153
8965
|
);
|
|
8154
8966
|
return this.$(shadowFnFactory(selector));
|
|
@@ -8582,7 +9394,7 @@ function querySelectorAllDeep(findMany, s, r) {
|
|
|
8582
9394
|
}
|
|
8583
9395
|
|
|
8584
9396
|
// src/utils/index.ts
|
|
8585
|
-
var
|
|
9397
|
+
var log29 = logger29("webdriverio");
|
|
8586
9398
|
var INVALID_SELECTOR_ERROR = "selector needs to be typeof `string` or `function`";
|
|
8587
9399
|
var IGNORED_COMMAND_FILE_EXPORTS = ["SESSION_MOCKS", "CDP_SESSIONS"];
|
|
8588
9400
|
var scopes = {
|
|
@@ -8755,7 +9567,7 @@ async function findDeepElement(selector) {
|
|
|
8755
9567
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8756
9568
|
return scopedNodes[0];
|
|
8757
9569
|
}, (err) => {
|
|
8758
|
-
|
|
9570
|
+
log29.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
|
|
8759
9571
|
return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) : browser.findElement(using, value);
|
|
8760
9572
|
});
|
|
8761
9573
|
return deepElementResult;
|
|
@@ -8794,7 +9606,7 @@ async function findDeepElements(selector) {
|
|
|
8794
9606
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8795
9607
|
return scopedNodes;
|
|
8796
9608
|
}, (err) => {
|
|
8797
|
-
|
|
9609
|
+
log29.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
|
|
8798
9610
|
return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) : browser.findElements(using, value);
|
|
8799
9611
|
});
|
|
8800
9612
|
return deepElementResult;
|
|
@@ -8928,7 +9740,7 @@ async function getElementRect(scope) {
|
|
|
8928
9740
|
if (rectJs && typeof rectJs[key] === "number") {
|
|
8929
9741
|
rect[key] = Math.floor(rectJs[key]);
|
|
8930
9742
|
} else {
|
|
8931
|
-
|
|
9743
|
+
log29.error("getElementRect", { rect, rectJs, key });
|
|
8932
9744
|
throw new Error("Failed to receive element rects via execute command");
|
|
8933
9745
|
}
|
|
8934
9746
|
});
|
|
@@ -9374,7 +10186,7 @@ var remote = async function(params, remoteModifier) {
|
|
|
9374
10186
|
const keysToKeep = Object.keys(environment.value.variables.WDIO_WORKER_ID ? params : DEFAULTS);
|
|
9375
10187
|
const config = validateConfig(WDIO_DEFAULTS, params, keysToKeep);
|
|
9376
10188
|
await enableFileLogging(config.outputDir);
|
|
9377
|
-
|
|
10189
|
+
logger30.setLogLevelsConfig(config.logLevels, config.logLevel);
|
|
9378
10190
|
const modifier = (client, options2) => {
|
|
9379
10191
|
Object.assign(options2, Object.entries(config).reduce((a, [k, v]) => typeof v === "undefined" ? a : { ...a, [k]: v }, {}));
|
|
9380
10192
|
if (typeof remoteModifier === "function") {
|