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/node.js
CHANGED
|
@@ -130,7 +130,7 @@ import path6 from "node:path";
|
|
|
130
130
|
import { getBrowserObject } from "@wdio/utils";
|
|
131
131
|
|
|
132
132
|
// src/session/context.ts
|
|
133
|
-
import
|
|
133
|
+
import logger3 from "@wdio/logger";
|
|
134
134
|
|
|
135
135
|
// src/environment.ts
|
|
136
136
|
var isNode = !!(typeof process !== "undefined" && process.version);
|
|
@@ -232,6 +232,20 @@ var SessionManager = class {
|
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
// src/utils/mobile.ts
|
|
235
|
+
import logger2 from "@wdio/logger";
|
|
236
|
+
var log2 = logger2("webdriver");
|
|
237
|
+
function isUnknownMethodError(err) {
|
|
238
|
+
if (!(err instanceof Error)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
const msg = err.message.toLowerCase();
|
|
242
|
+
return msg.includes("unknown method") || msg.includes("unknown command");
|
|
243
|
+
}
|
|
244
|
+
function logAppiumDeprecationWarning(mobileCommand, protocolEndpoint) {
|
|
245
|
+
log2.warn(
|
|
246
|
+
`The \`${mobileCommand}\` execute method is not supported by your Appium driver. Falling back to the deprecated \`${protocolEndpoint}\` protocol endpoint. Please upgrade your Appium driver to a version that supports \`${mobileCommand}\`.`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
235
249
|
function getNativeContext({ capabilities, isMobile }) {
|
|
236
250
|
if (!capabilities || typeof capabilities !== "object" || !isMobile) {
|
|
237
251
|
return false;
|
|
@@ -279,7 +293,7 @@ function validatePinchAndZoomOptions({ browser, gesture, options }) {
|
|
|
279
293
|
}
|
|
280
294
|
|
|
281
295
|
// src/session/context.ts
|
|
282
|
-
var
|
|
296
|
+
var log3 = logger3("webdriverio:context");
|
|
283
297
|
var COMMANDS_REQUIRING_RESET = ["deleteSession", "refresh", "switchToParentFrame"];
|
|
284
298
|
function getContextManager(browser) {
|
|
285
299
|
return SessionManager.getSessionManager(browser, ContextManager);
|
|
@@ -408,7 +422,7 @@ var ContextManager = class _ContextManager extends SessionManager {
|
|
|
408
422
|
}
|
|
409
423
|
if (this.#browser.isMobile && !this.#isNativeContext && !this.#mobileContext && this.#getContextSupport) {
|
|
410
424
|
const context = await this.#browser.getContext().catch((err) => {
|
|
411
|
-
|
|
425
|
+
log3.warn(
|
|
412
426
|
`Error getting context: ${err}
|
|
413
427
|
|
|
414
428
|
WebDriver capabilities: ${JSON.stringify(this.#browser.capabilities)}
|
|
@@ -616,7 +630,7 @@ async function saveElementScreenshot(filepath) {
|
|
|
616
630
|
}
|
|
617
631
|
|
|
618
632
|
// src/index.ts
|
|
619
|
-
import
|
|
633
|
+
import logger31 from "@wdio/logger";
|
|
620
634
|
import WebDriver, { DEFAULTS } from "webdriver";
|
|
621
635
|
import { validateConfig } from "@wdio/config";
|
|
622
636
|
import { enableFileLogging, wrapCommand as wrapCommand3, isBidi } from "@wdio/utils";
|
|
@@ -631,14 +645,14 @@ import { ELEMENT_KEY as ELEMENT_KEY21 } from "webdriver";
|
|
|
631
645
|
import { getBrowserObject as getBrowserObject39 } from "@wdio/utils";
|
|
632
646
|
|
|
633
647
|
// src/utils/implicitWait.ts
|
|
634
|
-
import
|
|
648
|
+
import logger4 from "@wdio/logger";
|
|
635
649
|
import { getBrowserObject as getBrowserObject2 } from "@wdio/utils";
|
|
636
|
-
var
|
|
650
|
+
var log4 = logger4("webdriverio");
|
|
637
651
|
async function implicitWait(currentElement, commandName) {
|
|
638
652
|
const browser = getBrowserObject2(currentElement);
|
|
639
653
|
const skipForMobileScroll = browser.isMobile && await browser.isNativeContext && (commandName === "scrollIntoView" || commandName === "tap");
|
|
640
654
|
if (!currentElement.elementId && !/(waitUntil|waitFor|isExisting|is?\w+Displayed|is?\w+Clickable)/.test(commandName) && !skipForMobileScroll) {
|
|
641
|
-
|
|
655
|
+
log4.debug(
|
|
642
656
|
`command ${commandName} was called on an element ("${currentElement.selector}") that wasn't found, waiting for it...`
|
|
643
657
|
);
|
|
644
658
|
try {
|
|
@@ -689,7 +703,7 @@ async function refetchElement(currentElement, commandName) {
|
|
|
689
703
|
import cssValue from "css-value";
|
|
690
704
|
import rgb2hex from "rgb2hex";
|
|
691
705
|
import GraphemeSplitter from "grapheme-splitter";
|
|
692
|
-
import
|
|
706
|
+
import logger30 from "@wdio/logger";
|
|
693
707
|
import isPlainObject from "is-plain-obj";
|
|
694
708
|
import { ELEMENT_KEY as ELEMENT_KEY20 } from "webdriver";
|
|
695
709
|
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject38 } from "@wdio/utils";
|
|
@@ -703,7 +717,9 @@ __export(browser_exports, {
|
|
|
703
717
|
action: () => action,
|
|
704
718
|
actions: () => actions,
|
|
705
719
|
addInitScript: () => addInitScript,
|
|
720
|
+
background: () => background,
|
|
706
721
|
call: () => call,
|
|
722
|
+
closeApp: () => closeApp,
|
|
707
723
|
custom$: () => custom$,
|
|
708
724
|
custom$$: () => custom$$,
|
|
709
725
|
debug: () => debug,
|
|
@@ -713,17 +729,38 @@ __export(browser_exports, {
|
|
|
713
729
|
emulate: () => emulate,
|
|
714
730
|
execute: () => execute,
|
|
715
731
|
executeAsync: () => executeAsync,
|
|
732
|
+
fingerPrint: () => fingerPrint,
|
|
733
|
+
getClipboard: () => getClipboard,
|
|
716
734
|
getContext: () => getContext,
|
|
717
735
|
getContexts: () => getContexts,
|
|
718
736
|
getCookies: () => getCookies,
|
|
737
|
+
getCurrentActivity: () => getCurrentActivity,
|
|
738
|
+
getCurrentPackage: () => getCurrentPackage,
|
|
739
|
+
getDisplayDensity: () => getDisplayDensity,
|
|
740
|
+
getPerformanceData: () => getPerformanceData,
|
|
741
|
+
getPerformanceDataTypes: () => getPerformanceDataTypes,
|
|
719
742
|
getPuppeteer: () => getPuppeteer,
|
|
743
|
+
getStrings: () => getStrings,
|
|
744
|
+
getSystemBars: () => getSystemBars,
|
|
720
745
|
getWindowSize: () => getWindowSize,
|
|
746
|
+
gsmCall: () => gsmCall,
|
|
747
|
+
gsmSignal: () => gsmSignal,
|
|
748
|
+
gsmVoice: () => gsmVoice,
|
|
749
|
+
isLocked: () => isLocked,
|
|
721
750
|
keys: () => keys,
|
|
751
|
+
launchApp: () => launchApp,
|
|
752
|
+
lock: () => lock,
|
|
753
|
+
longPressKeyCode: () => longPressKeyCode,
|
|
722
754
|
mock: () => mock,
|
|
723
755
|
mockClearAll: () => mockClearAll,
|
|
724
756
|
mockRestoreAll: () => mockRestoreAll,
|
|
725
757
|
newWindow: () => newWindow,
|
|
758
|
+
openNotifications: () => openNotifications,
|
|
726
759
|
pause: () => pause,
|
|
760
|
+
powerAC: () => powerAC,
|
|
761
|
+
powerCapacity: () => powerCapacity,
|
|
762
|
+
pressKeyCode: () => pressKeyCode,
|
|
763
|
+
queryAppState: () => queryAppState,
|
|
727
764
|
react$: () => react$,
|
|
728
765
|
react$$: () => react$$,
|
|
729
766
|
relaunchActiveApp: () => relaunchActiveApp,
|
|
@@ -733,10 +770,15 @@ __export(browser_exports, {
|
|
|
733
770
|
saveRecordingScreen: () => saveRecordingScreen2,
|
|
734
771
|
saveScreenshot: () => saveScreenshot2,
|
|
735
772
|
scroll: () => scroll,
|
|
773
|
+
sendKeyEvent: () => sendKeyEvent,
|
|
774
|
+
sendSms: () => sendSms,
|
|
775
|
+
setClipboard: () => setClipboard,
|
|
736
776
|
setCookies: () => setCookies,
|
|
737
777
|
setTimeout: () => setTimeout2,
|
|
738
778
|
setViewport: () => setViewport,
|
|
739
779
|
setWindowSize: () => setWindowSize,
|
|
780
|
+
shake: () => shake,
|
|
781
|
+
startActivity: () => startActivity,
|
|
740
782
|
swipe: () => swipe,
|
|
741
783
|
switchContext: () => switchContext,
|
|
742
784
|
switchFrame: () => switchFrame,
|
|
@@ -745,7 +787,15 @@ __export(browser_exports, {
|
|
|
745
787
|
throttle: () => throttle,
|
|
746
788
|
throttleCPU: () => throttleCPU,
|
|
747
789
|
throttleNetwork: () => throttleNetwork,
|
|
790
|
+
toggleAirplaneMode: () => toggleAirplaneMode,
|
|
791
|
+
toggleData: () => toggleData,
|
|
792
|
+
toggleEnrollTouchId: () => toggleEnrollTouchId,
|
|
793
|
+
toggleLocationServices: () => toggleLocationServices,
|
|
794
|
+
toggleNetworkSpeed: () => toggleNetworkSpeed,
|
|
795
|
+
toggleWiFi: () => toggleWiFi,
|
|
748
796
|
touchAction: () => touchAction2,
|
|
797
|
+
touchId: () => touchId,
|
|
798
|
+
unlock: () => unlock,
|
|
749
799
|
uploadFile: () => uploadFile2,
|
|
750
800
|
url: () => url,
|
|
751
801
|
waitUntil: () => waitUntil
|
|
@@ -1685,8 +1735,8 @@ function debug(commandTimeout = 5e3) {
|
|
|
1685
1735
|
}
|
|
1686
1736
|
|
|
1687
1737
|
// src/commands/browser/deleteCookies.ts
|
|
1688
|
-
import
|
|
1689
|
-
var
|
|
1738
|
+
import logger5 from "@wdio/logger";
|
|
1739
|
+
var log5 = logger5("webdriverio");
|
|
1690
1740
|
async function deleteCookies(filter) {
|
|
1691
1741
|
const filterArray = typeof filter === "undefined" ? void 0 : Array.isArray(filter) ? filter : [filter];
|
|
1692
1742
|
if (!this.isBidi) {
|
|
@@ -1715,7 +1765,7 @@ async function deleteCookies(filter) {
|
|
|
1715
1765
|
return;
|
|
1716
1766
|
}
|
|
1717
1767
|
} catch (err) {
|
|
1718
|
-
|
|
1768
|
+
log5.warn(`BiDi deleteCookies check failed, falling back to classic: ${err.message}`);
|
|
1719
1769
|
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1720
1770
|
return;
|
|
1721
1771
|
}
|
|
@@ -1735,7 +1785,7 @@ async function deleteCookies(filter) {
|
|
|
1735
1785
|
});
|
|
1736
1786
|
await Promise.all(bidiFilter.map((filter2) => this.storageDeleteCookies({ filter: filter2, partition })));
|
|
1737
1787
|
} catch (err) {
|
|
1738
|
-
|
|
1788
|
+
log5.warn(`BiDi deleteCookies failed, falling back to classic: ${err.message}`);
|
|
1739
1789
|
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1740
1790
|
}
|
|
1741
1791
|
return;
|
|
@@ -1772,8 +1822,8 @@ async function downloadFile2(fileName, targetDirectory) {
|
|
|
1772
1822
|
}
|
|
1773
1823
|
|
|
1774
1824
|
// src/clock.ts
|
|
1775
|
-
import
|
|
1776
|
-
var
|
|
1825
|
+
import logger6 from "@wdio/logger";
|
|
1826
|
+
var log6 = logger6("webdriverio:ClockManager");
|
|
1777
1827
|
function installFakeTimers(options) {
|
|
1778
1828
|
window.__clock = window.__wdio_sinon.install(options);
|
|
1779
1829
|
}
|
|
@@ -1797,7 +1847,7 @@ var ClockManager = class {
|
|
|
1797
1847
|
*/
|
|
1798
1848
|
async install(options) {
|
|
1799
1849
|
if (this.#isInstalled) {
|
|
1800
|
-
return
|
|
1850
|
+
return log6.warn("Fake timers are already installed");
|
|
1801
1851
|
}
|
|
1802
1852
|
if (globalThis.window) {
|
|
1803
1853
|
return;
|
|
@@ -3701,8 +3751,8 @@ async function executeAsync(script, ...args) {
|
|
|
3701
3751
|
}
|
|
3702
3752
|
|
|
3703
3753
|
// src/commands/browser/getCookies.ts
|
|
3704
|
-
import
|
|
3705
|
-
var
|
|
3754
|
+
import logger7 from "@wdio/logger";
|
|
3755
|
+
var log7 = logger7("webdriverio");
|
|
3706
3756
|
async function getCookies(filter) {
|
|
3707
3757
|
const usesMultipleFilter = Array.isArray(filter) && filter.length > 1;
|
|
3708
3758
|
if (!this.isBidi || usesMultipleFilter) {
|
|
@@ -3730,7 +3780,7 @@ async function getCookies(filter) {
|
|
|
3730
3780
|
try {
|
|
3731
3781
|
const { cookies } = await this.storageGetCookies(params);
|
|
3732
3782
|
if (cookies.length === 0) {
|
|
3733
|
-
|
|
3783
|
+
log7.debug("BiDi getCookies returned empty, falling back to classic");
|
|
3734
3784
|
return getCookiesClassic.call(this, filter);
|
|
3735
3785
|
}
|
|
3736
3786
|
return cookies.map((cookie) => ({
|
|
@@ -3738,7 +3788,7 @@ async function getCookies(filter) {
|
|
|
3738
3788
|
value: cookie.value.type === "base64" ? Buffer.from(cookie.value.value, "base64").toString("utf-8") : cookie.value.value
|
|
3739
3789
|
}));
|
|
3740
3790
|
} catch (err) {
|
|
3741
|
-
|
|
3791
|
+
log7.warn(`BiDi getCookies failed, falling back to classic: ${err.message}`);
|
|
3742
3792
|
return getCookiesClassic.call(this, filter);
|
|
3743
3793
|
}
|
|
3744
3794
|
}
|
|
@@ -3748,7 +3798,7 @@ async function getCookiesClassic(names) {
|
|
|
3748
3798
|
}
|
|
3749
3799
|
const usesMultipleFilter = Array.isArray(names) && names.length > 1;
|
|
3750
3800
|
if (usesMultipleFilter) {
|
|
3751
|
-
|
|
3801
|
+
log7.warn(
|
|
3752
3802
|
"Passing a string array as filter for `getCookies` is deprecated and its support will be removed in an upcoming version of WebdriverIO!"
|
|
3753
3803
|
);
|
|
3754
3804
|
const allCookies2 = await this.getAllCookies();
|
|
@@ -3767,7 +3817,7 @@ function getCookieFilter(names) {
|
|
|
3767
3817
|
}
|
|
3768
3818
|
return (Array.isArray(names) ? names : [names]).map((filter) => {
|
|
3769
3819
|
if (typeof filter === "string") {
|
|
3770
|
-
|
|
3820
|
+
log7.warn("Passing string values into `getCookie` is deprecated and its support will be removed in an upcoming version of WebdriverIO!");
|
|
3771
3821
|
return { name: filter };
|
|
3772
3822
|
}
|
|
3773
3823
|
return filter;
|
|
@@ -3775,9 +3825,9 @@ function getCookieFilter(names) {
|
|
|
3775
3825
|
}
|
|
3776
3826
|
|
|
3777
3827
|
// src/commands/browser/getPuppeteer.ts
|
|
3778
|
-
import
|
|
3828
|
+
import logger8 from "@wdio/logger";
|
|
3779
3829
|
import { userImport } from "@wdio/utils";
|
|
3780
|
-
var
|
|
3830
|
+
var log8 = logger8("webdriverio");
|
|
3781
3831
|
var DEBUG_PIPE_FLAG = "remote-debugging-pipe";
|
|
3782
3832
|
async function getPuppeteer() {
|
|
3783
3833
|
if (globalThis.wdio) {
|
|
@@ -3790,7 +3840,7 @@ async function getPuppeteer() {
|
|
|
3790
3840
|
);
|
|
3791
3841
|
}
|
|
3792
3842
|
if (this.puppeteer?.connected) {
|
|
3793
|
-
|
|
3843
|
+
log8.debug("Reusing existing puppeteer session");
|
|
3794
3844
|
return this.puppeteer;
|
|
3795
3845
|
}
|
|
3796
3846
|
const { headers } = this.options;
|
|
@@ -3900,7 +3950,7 @@ async function keys(value) {
|
|
|
3900
3950
|
import { getBrowserObject as getBrowserObject7 } from "@wdio/utils";
|
|
3901
3951
|
|
|
3902
3952
|
// src/utils/interception/index.ts
|
|
3903
|
-
import
|
|
3953
|
+
import logger9 from "@wdio/logger";
|
|
3904
3954
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3905
3955
|
|
|
3906
3956
|
// src/utils/Timer.ts
|
|
@@ -4071,7 +4121,7 @@ function getPatternParam(pattern, key) {
|
|
|
4071
4121
|
}
|
|
4072
4122
|
|
|
4073
4123
|
// src/utils/interception/index.ts
|
|
4074
|
-
var
|
|
4124
|
+
var log9 = logger9("WebDriverInterception");
|
|
4075
4125
|
var hasSubscribedToEvents = false;
|
|
4076
4126
|
var WebDriverInterception = class _WebDriverInterception {
|
|
4077
4127
|
#pattern;
|
|
@@ -4101,7 +4151,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4101
4151
|
"network.responseStarted"
|
|
4102
4152
|
]
|
|
4103
4153
|
});
|
|
4104
|
-
|
|
4154
|
+
log9.info("subscribed to network events");
|
|
4105
4155
|
hasSubscribedToEvents = true;
|
|
4106
4156
|
}
|
|
4107
4157
|
const interception = await browser.networkAddIntercept({
|
|
@@ -4227,7 +4277,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4227
4277
|
return null;
|
|
4228
4278
|
}
|
|
4229
4279
|
if (/[^A-Za-z0-9+/=\s]/.test(body.value)) {
|
|
4230
|
-
|
|
4280
|
+
log9.warn(`Invalid base64 data for request ${requestId}`);
|
|
4231
4281
|
return null;
|
|
4232
4282
|
}
|
|
4233
4283
|
return Buffer.from(body.value, "base64");
|
|
@@ -4325,7 +4375,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4325
4375
|
this.#respondOverwrites = [];
|
|
4326
4376
|
this.#restored = true;
|
|
4327
4377
|
const handle = await this.#browser.getWindowHandle();
|
|
4328
|
-
|
|
4378
|
+
log9.trace(`Restoring mock for ${handle}`);
|
|
4329
4379
|
SESSION_MOCKS[handle].delete(this);
|
|
4330
4380
|
if (this.#mockId) {
|
|
4331
4381
|
await this.#browser.networkRemoveIntercept({ intercept: this.#mockId });
|
|
@@ -4466,11 +4516,11 @@ async function mock(url2, filterOptions) {
|
|
|
4466
4516
|
}
|
|
4467
4517
|
|
|
4468
4518
|
// src/commands/browser/mockClearAll.ts
|
|
4469
|
-
import
|
|
4470
|
-
var
|
|
4519
|
+
import logger10 from "@wdio/logger";
|
|
4520
|
+
var log10 = logger10("webdriverio:mockClearAll");
|
|
4471
4521
|
async function mockClearAll() {
|
|
4472
4522
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4473
|
-
|
|
4523
|
+
log10.trace(`Clearing mocks for ${handle}`);
|
|
4474
4524
|
for (const mock2 of mocks) {
|
|
4475
4525
|
mock2.clear();
|
|
4476
4526
|
}
|
|
@@ -4478,11 +4528,11 @@ async function mockClearAll() {
|
|
|
4478
4528
|
}
|
|
4479
4529
|
|
|
4480
4530
|
// src/commands/browser/mockRestoreAll.ts
|
|
4481
|
-
import
|
|
4482
|
-
var
|
|
4531
|
+
import logger11 from "@wdio/logger";
|
|
4532
|
+
var log11 = logger11("webdriverio:mockRestoreAll");
|
|
4483
4533
|
async function mockRestoreAll() {
|
|
4484
4534
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4485
|
-
|
|
4535
|
+
log11.trace(`Clearing mocks for ${handle}`);
|
|
4486
4536
|
for (const mock2 of mocks) {
|
|
4487
4537
|
await mock2.restore();
|
|
4488
4538
|
}
|
|
@@ -4492,8 +4542,8 @@ async function mockRestoreAll() {
|
|
|
4492
4542
|
// src/commands/browser/newWindow.ts
|
|
4493
4543
|
import { sleep } from "@wdio/utils";
|
|
4494
4544
|
import newWindowHelper from "./scripts/newWindow.js";
|
|
4495
|
-
import
|
|
4496
|
-
var
|
|
4545
|
+
import logger12 from "@wdio/logger";
|
|
4546
|
+
var log12 = logger12("webdriverio:newWindow");
|
|
4497
4547
|
var WAIT_FOR_NEW_HANDLE_TIMEOUT = 3e3;
|
|
4498
4548
|
async function newWindow(url2, { type = "window", windowName = "", windowFeatures = "" } = {}) {
|
|
4499
4549
|
if (typeof url2 !== "string") {
|
|
@@ -4503,7 +4553,7 @@ async function newWindow(url2, { type = "window", windowName = "", windowFeature
|
|
|
4503
4553
|
throw new Error(`Invalid type '${type}' provided to newWindow command. Use either 'tab' or 'window'`);
|
|
4504
4554
|
}
|
|
4505
4555
|
if (windowName || windowFeatures) {
|
|
4506
|
-
|
|
4556
|
+
log12.warn('The "windowName" and "windowFeatures" options are deprecated and only supported in WebDriver Classic sessions.');
|
|
4507
4557
|
}
|
|
4508
4558
|
if (this.isMobile) {
|
|
4509
4559
|
throw new Error("newWindow command is not supported on mobile platforms");
|
|
@@ -4569,15 +4619,15 @@ async function react$(selector, { props = {}, state = {} } = {}) {
|
|
|
4569
4619
|
}
|
|
4570
4620
|
|
|
4571
4621
|
// src/commands/browser/reloadSession.ts
|
|
4572
|
-
import
|
|
4622
|
+
import logger15 from "@wdio/logger";
|
|
4573
4623
|
|
|
4574
4624
|
// src/session/polyfill.ts
|
|
4575
|
-
import
|
|
4625
|
+
import logger13 from "@wdio/logger";
|
|
4576
4626
|
import { polyfillFn as polyfillFn3 } from "./scripts/polyfill.js";
|
|
4577
4627
|
function getPolyfillManager(browser) {
|
|
4578
4628
|
return SessionManager.getSessionManager(browser, PolyfillManager);
|
|
4579
4629
|
}
|
|
4580
|
-
var
|
|
4630
|
+
var log13 = logger13("webdriverio:PolyfillManager");
|
|
4581
4631
|
var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
4582
4632
|
#initialize;
|
|
4583
4633
|
#browser;
|
|
@@ -4609,7 +4659,7 @@ var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
|
4609
4659
|
return;
|
|
4610
4660
|
}
|
|
4611
4661
|
const functionDeclaration = createFunctionDeclarationFromString(polyfillFn3);
|
|
4612
|
-
|
|
4662
|
+
log13.info(`Adding polyfill script to context with id ${context.context}`);
|
|
4613
4663
|
this.#scriptsRegisteredInContexts.add(context.context);
|
|
4614
4664
|
return Promise.all([
|
|
4615
4665
|
!context.parent ? this.#browser.scriptAddPreloadScript({
|
|
@@ -4631,9 +4681,9 @@ var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
|
4631
4681
|
};
|
|
4632
4682
|
|
|
4633
4683
|
// src/session/shadowRoot.ts
|
|
4634
|
-
import
|
|
4684
|
+
import logger14 from "@wdio/logger";
|
|
4635
4685
|
import customElementWrapper from "./scripts/customElement.js";
|
|
4636
|
-
var
|
|
4686
|
+
var log14 = logger14("webdriverio:ShadowRootManager");
|
|
4637
4687
|
function getShadowRootManager(browser) {
|
|
4638
4688
|
return SessionManager.getSessionManager(browser, ShadowRootManager);
|
|
4639
4689
|
}
|
|
@@ -4749,9 +4799,9 @@ var ShadowRootManager = class _ShadowRootManager extends SessionManager {
|
|
|
4749
4799
|
!shadowElem.value?.shadowRoot?.sharedId || // we expect the shadow root to have a proper type
|
|
4750
4800
|
shadowElem.value.shadowRoot.value?.nodeType !== 11
|
|
4751
4801
|
) {
|
|
4752
|
-
return
|
|
4802
|
+
return log14.warn(`Expected element with shadow root but found <${shadowElem.value?.localName} />`);
|
|
4753
4803
|
}
|
|
4754
|
-
|
|
4804
|
+
log14.info(`Registered new shadow root for element <${shadowElem.value.localName} /> with id ${shadowElem.value.shadowRoot.sharedId}`);
|
|
4755
4805
|
const newTree = new ShadowRootTree(
|
|
4756
4806
|
shadowElem.sharedId,
|
|
4757
4807
|
shadowElem.value.shadowRoot.sharedId,
|
|
@@ -4950,15 +5000,15 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4950
5000
|
async initialize() {
|
|
4951
5001
|
return this.#initialize;
|
|
4952
5002
|
}
|
|
4953
|
-
#beforeRequestSent(
|
|
4954
|
-
if (
|
|
5003
|
+
#beforeRequestSent(log31) {
|
|
5004
|
+
if (log31.navigation) {
|
|
4955
5005
|
return;
|
|
4956
5006
|
}
|
|
4957
|
-
const request = this.#findRootRequest(
|
|
5007
|
+
const request = this.#findRootRequest(log31.navigation);
|
|
4958
5008
|
if (!request) {
|
|
4959
5009
|
return;
|
|
4960
5010
|
}
|
|
4961
|
-
const { request: id, headers, cookies, url: url2 } =
|
|
5011
|
+
const { request: id, headers, cookies, url: url2 } = log31.request;
|
|
4962
5012
|
request.children?.push({
|
|
4963
5013
|
id,
|
|
4964
5014
|
url: url2,
|
|
@@ -4974,51 +5024,51 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4974
5024
|
sameSite: cookie.sameSite,
|
|
4975
5025
|
expiry: cookie.expiry
|
|
4976
5026
|
})),
|
|
4977
|
-
timestamp:
|
|
5027
|
+
timestamp: log31.timestamp
|
|
4978
5028
|
});
|
|
4979
5029
|
}
|
|
4980
|
-
#navigationStarted(
|
|
5030
|
+
#navigationStarted(log31) {
|
|
4981
5031
|
if (
|
|
4982
5032
|
/**
|
|
4983
5033
|
* we need a navigation id to identify the request
|
|
4984
5034
|
*/
|
|
4985
|
-
!
|
|
5035
|
+
!log31.navigation || /**
|
|
4986
5036
|
* ignore urls that users wouldn't navigate to
|
|
4987
5037
|
*/
|
|
4988
|
-
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) =>
|
|
5038
|
+
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) => log31.url.startsWith(protocol))
|
|
4989
5039
|
) {
|
|
4990
|
-
if (
|
|
5040
|
+
if (log31.navigation === null && log31.url === "") {
|
|
4991
5041
|
this.#lastNetworkId = UNKNOWN_NAVIGATION_ID;
|
|
4992
5042
|
return this.#requests.set(UNKNOWN_NAVIGATION_ID, {
|
|
4993
5043
|
url: "",
|
|
4994
5044
|
headers: {},
|
|
4995
|
-
timestamp:
|
|
5045
|
+
timestamp: log31.timestamp,
|
|
4996
5046
|
redirectChain: [],
|
|
4997
5047
|
children: []
|
|
4998
5048
|
});
|
|
4999
5049
|
}
|
|
5000
5050
|
return;
|
|
5001
5051
|
}
|
|
5002
|
-
this.#lastNetworkId =
|
|
5003
|
-
this.#requests.set(
|
|
5004
|
-
url:
|
|
5052
|
+
this.#lastNetworkId = log31.navigation;
|
|
5053
|
+
this.#requests.set(log31.navigation, {
|
|
5054
|
+
url: log31.url,
|
|
5005
5055
|
headers: {},
|
|
5006
|
-
timestamp:
|
|
5007
|
-
navigation:
|
|
5056
|
+
timestamp: log31.timestamp,
|
|
5057
|
+
navigation: log31.navigation,
|
|
5008
5058
|
redirectChain: [],
|
|
5009
5059
|
children: []
|
|
5010
5060
|
});
|
|
5011
5061
|
}
|
|
5012
|
-
#fetchError(
|
|
5013
|
-
const response = this.#findRootRequest(
|
|
5062
|
+
#fetchError(log31) {
|
|
5063
|
+
const response = this.#findRootRequest(log31.navigation);
|
|
5014
5064
|
if (!response) {
|
|
5015
5065
|
return;
|
|
5016
5066
|
}
|
|
5017
|
-
const request = response.children?.find((child) => child.id ===
|
|
5067
|
+
const request = response.children?.find((child) => child.id === log31.request.request);
|
|
5018
5068
|
if (!request) {
|
|
5019
5069
|
return;
|
|
5020
5070
|
}
|
|
5021
|
-
request.error =
|
|
5071
|
+
request.error = log31.errorText;
|
|
5022
5072
|
}
|
|
5023
5073
|
#findRootRequest(navigationId) {
|
|
5024
5074
|
const response = this.#requests.get(navigationId || UNKNOWN_NAVIGATION_ID);
|
|
@@ -5028,22 +5078,22 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
5028
5078
|
const firstRequest = this.#requests.values().next().value;
|
|
5029
5079
|
return this.#lastNetworkId ? this.#requests.get(this.#lastNetworkId) || firstRequest : firstRequest;
|
|
5030
5080
|
}
|
|
5031
|
-
#responseCompleted(
|
|
5032
|
-
const response = this.#findRootRequest(
|
|
5081
|
+
#responseCompleted(log31) {
|
|
5082
|
+
const response = this.#findRootRequest(log31.navigation);
|
|
5033
5083
|
if (!response) {
|
|
5034
5084
|
return;
|
|
5035
5085
|
}
|
|
5036
5086
|
if (!response.navigation && response.url === "") {
|
|
5037
|
-
response.url =
|
|
5038
|
-
response.navigation =
|
|
5087
|
+
response.url = log31.request.url;
|
|
5088
|
+
response.navigation = log31.navigation;
|
|
5039
5089
|
}
|
|
5040
|
-
if (
|
|
5041
|
-
if (response.url !==
|
|
5090
|
+
if (log31.navigation === response.navigation) {
|
|
5091
|
+
if (response.url !== log31.response.url) {
|
|
5042
5092
|
response.redirectChain?.push(response.url);
|
|
5043
5093
|
}
|
|
5044
|
-
response.url =
|
|
5045
|
-
const { headers: requestHeaders } =
|
|
5046
|
-
const { fromCache, headers: responseHeaders, mimeType, status } =
|
|
5094
|
+
response.url = log31.response.url;
|
|
5095
|
+
const { headers: requestHeaders } = log31.request;
|
|
5096
|
+
const { fromCache, headers: responseHeaders, mimeType, status } = log31.response;
|
|
5047
5097
|
response.headers = headerListToObject(requestHeaders), response.response = {
|
|
5048
5098
|
fromCache,
|
|
5049
5099
|
headers: headerListToObject(responseHeaders),
|
|
@@ -5052,15 +5102,15 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
5052
5102
|
};
|
|
5053
5103
|
return;
|
|
5054
5104
|
}
|
|
5055
|
-
const request = response.children?.find((child) => child.id ===
|
|
5105
|
+
const request = response.children?.find((child) => child.id === log31.request.request);
|
|
5056
5106
|
if (!request) {
|
|
5057
5107
|
return;
|
|
5058
5108
|
}
|
|
5059
5109
|
request.response = {
|
|
5060
|
-
fromCache:
|
|
5061
|
-
headers: headerListToObject(
|
|
5062
|
-
mimeType:
|
|
5063
|
-
status:
|
|
5110
|
+
fromCache: log31.response.fromCache,
|
|
5111
|
+
headers: headerListToObject(log31.response.headers),
|
|
5112
|
+
mimeType: log31.response.mimeType,
|
|
5113
|
+
status: log31.response.status
|
|
5064
5114
|
};
|
|
5065
5115
|
response.children?.push(request);
|
|
5066
5116
|
}
|
|
@@ -5131,12 +5181,12 @@ var DialogManager = class _DialogManager extends SessionManager {
|
|
|
5131
5181
|
/**
|
|
5132
5182
|
* capture shadow root elements propagated through console.debug
|
|
5133
5183
|
*/
|
|
5134
|
-
async #handleUserPrompt(
|
|
5184
|
+
async #handleUserPrompt(log31) {
|
|
5135
5185
|
if (this.#autoHandleDialog) {
|
|
5136
5186
|
try {
|
|
5137
5187
|
return await this.#browser.browsingContextHandleUserPrompt({
|
|
5138
5188
|
accept: false,
|
|
5139
|
-
context:
|
|
5189
|
+
context: log31.context
|
|
5140
5190
|
});
|
|
5141
5191
|
} catch (err) {
|
|
5142
5192
|
if (err instanceof Error && (err.message.includes("no such alert") || err.message.includes("no such frame"))) {
|
|
@@ -5145,7 +5195,7 @@ var DialogManager = class _DialogManager extends SessionManager {
|
|
|
5145
5195
|
throw err;
|
|
5146
5196
|
}
|
|
5147
5197
|
}
|
|
5148
|
-
const dialog = new Dialog(
|
|
5198
|
+
const dialog = new Dialog(log31, this.#browser);
|
|
5149
5199
|
this.#browser.emit("dialog", dialog);
|
|
5150
5200
|
}
|
|
5151
5201
|
/**
|
|
@@ -5228,18 +5278,18 @@ function registerSessionManager(instance) {
|
|
|
5228
5278
|
}
|
|
5229
5279
|
|
|
5230
5280
|
// src/commands/browser/reloadSession.ts
|
|
5231
|
-
var
|
|
5281
|
+
var log15 = logger15("webdriverio");
|
|
5232
5282
|
async function reloadSession(newCapabilities) {
|
|
5233
5283
|
const oldSessionId = this.sessionId;
|
|
5234
5284
|
const shutdownDriver = Boolean(newCapabilities?.browserName);
|
|
5235
5285
|
try {
|
|
5236
5286
|
await this.deleteSession({ shutdownDriver });
|
|
5237
5287
|
} catch (err) {
|
|
5238
|
-
|
|
5288
|
+
log15.warn(`Suppressing error closing the session: ${err.stack}`);
|
|
5239
5289
|
}
|
|
5240
5290
|
if (this.puppeteer?.connected) {
|
|
5241
5291
|
this.puppeteer.disconnect();
|
|
5242
|
-
|
|
5292
|
+
log15.debug("Disconnected puppeteer session");
|
|
5243
5293
|
}
|
|
5244
5294
|
const ProtocolDriver = (await import(
|
|
5245
5295
|
/* @vite-ignore */
|
|
@@ -5285,11 +5335,11 @@ async function saveScreenshot2(filepath, options) {
|
|
|
5285
5335
|
}
|
|
5286
5336
|
|
|
5287
5337
|
// src/commands/browser/scroll.ts
|
|
5288
|
-
import
|
|
5289
|
-
var
|
|
5338
|
+
import logger16 from "@wdio/logger";
|
|
5339
|
+
var log16 = logger16("webdriverio");
|
|
5290
5340
|
function scroll(x = 0, y = 0) {
|
|
5291
5341
|
if (!x && !y) {
|
|
5292
|
-
|
|
5342
|
+
log16.warn('"scroll" command was called with no parameters, skipping execution');
|
|
5293
5343
|
return Promise.resolve();
|
|
5294
5344
|
}
|
|
5295
5345
|
if (this.isMobile) {
|
|
@@ -5303,8 +5353,8 @@ function scroll(x = 0, y = 0) {
|
|
|
5303
5353
|
}
|
|
5304
5354
|
|
|
5305
5355
|
// src/commands/browser/setCookies.ts
|
|
5306
|
-
import
|
|
5307
|
-
var
|
|
5356
|
+
import logger17 from "@wdio/logger";
|
|
5357
|
+
var log17 = logger17("webdriverio");
|
|
5308
5358
|
async function setCookies(cookieObjs) {
|
|
5309
5359
|
const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
|
|
5310
5360
|
if (cookieObjsList.some((obj) => typeof obj !== "object")) {
|
|
@@ -5341,7 +5391,7 @@ async function setCookies(cookieObjs) {
|
|
|
5341
5391
|
}
|
|
5342
5392
|
})));
|
|
5343
5393
|
} catch (err) {
|
|
5344
|
-
|
|
5394
|
+
log17.warn(`BiDi setCookies failed, falling back to classic: ${err.message}`);
|
|
5345
5395
|
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5346
5396
|
}
|
|
5347
5397
|
return;
|
|
@@ -5447,10 +5497,10 @@ async function switchWindow(matcher) {
|
|
|
5447
5497
|
}
|
|
5448
5498
|
|
|
5449
5499
|
// src/commands/browser/switchFrame.ts
|
|
5450
|
-
import
|
|
5500
|
+
import logger18 from "@wdio/logger";
|
|
5451
5501
|
import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
|
|
5452
5502
|
import findIframeInShadowDOM from "./scripts/shadowDom.js";
|
|
5453
|
-
var
|
|
5503
|
+
var log18 = logger18("webdriverio:switchFrame");
|
|
5454
5504
|
async function switchFrame(context) {
|
|
5455
5505
|
function isPossiblyUnresolvedElement(input) {
|
|
5456
5506
|
return Boolean(input) && typeof input === "object" && typeof input.getElement === "function";
|
|
@@ -5489,13 +5539,13 @@ async function switchFrame(context) {
|
|
|
5489
5539
|
const urlContextContaining = sessionContext.findContext(context, tree.contexts, "byUrlContaining");
|
|
5490
5540
|
const contextIdContext = sessionContext.findContext(context, tree.contexts, "byContextId");
|
|
5491
5541
|
if (urlContext) {
|
|
5492
|
-
|
|
5542
|
+
log18.info(`Found context by url "${urlContext.url}" with context id "${urlContext.context}"`);
|
|
5493
5543
|
return urlContext.context;
|
|
5494
5544
|
} else if (urlContextContaining) {
|
|
5495
|
-
|
|
5545
|
+
log18.info(`Found context by url containing "${urlContextContaining.url}" with context id "${urlContextContaining.context}"`);
|
|
5496
5546
|
return urlContextContaining.context;
|
|
5497
5547
|
} else if (contextIdContext) {
|
|
5498
|
-
|
|
5548
|
+
log18.info(`Found context by id "${contextIdContext}" with url "${contextIdContext.url}"`);
|
|
5499
5549
|
return contextIdContext.context;
|
|
5500
5550
|
}
|
|
5501
5551
|
return false;
|
|
@@ -5524,7 +5574,7 @@ async function switchFrame(context) {
|
|
|
5524
5574
|
arguments: args.map((arg) => LocalValue.getArgument(arg)),
|
|
5525
5575
|
target: { context: id }
|
|
5526
5576
|
};
|
|
5527
|
-
const result = await this.scriptCallFunction(params).catch((err) =>
|
|
5577
|
+
const result = await this.scriptCallFunction(params).catch((err) => log18.warn(`Failed to identify frame context id: ${err.message}`));
|
|
5528
5578
|
if (!result) {
|
|
5529
5579
|
return [];
|
|
5530
5580
|
}
|
|
@@ -5560,18 +5610,18 @@ async function switchFrame(context) {
|
|
|
5560
5610
|
return this.switchFrame(iframeElement);
|
|
5561
5611
|
}
|
|
5562
5612
|
}
|
|
5563
|
-
|
|
5613
|
+
log18.warn(`Shadow DOM iframe with src containing "${urlFragment}" found, but could not be resolved into a WebdriverIO element.`);
|
|
5564
5614
|
}
|
|
5565
5615
|
let desiredFrame;
|
|
5566
5616
|
let desiredContext = newContextId;
|
|
5567
5617
|
const contextQueue = [];
|
|
5568
|
-
|
|
5618
|
+
log18.info(`Available frames to switch to: ${allFrames.length}, desired context to switch: ${desiredContext}`);
|
|
5569
5619
|
while (desiredContext !== currentContext) {
|
|
5570
5620
|
desiredFrame = allFrames.find(({ context: context2 }) => context2 === desiredContext);
|
|
5571
5621
|
if (!desiredFrame) {
|
|
5572
5622
|
break;
|
|
5573
5623
|
}
|
|
5574
|
-
|
|
5624
|
+
log18.info(
|
|
5575
5625
|
contextQueue.length === 0 ? `Found desired frame with element id ${desiredFrame.frameElement[ELEMENT_KEY8]}` : `to switch to desired frame, we need to switch to ${desiredFrame.context} first`
|
|
5576
5626
|
);
|
|
5577
5627
|
contextQueue.unshift(desiredFrame);
|
|
@@ -5610,7 +5660,7 @@ async function switchFrame(context) {
|
|
|
5610
5660
|
target: { context: contextId }
|
|
5611
5661
|
};
|
|
5612
5662
|
const result = await this.scriptCallFunction(params).catch((err) => {
|
|
5613
|
-
|
|
5663
|
+
log18.warn(`switchFrame context callback threw error: ${err.message}`);
|
|
5614
5664
|
return void 0;
|
|
5615
5665
|
});
|
|
5616
5666
|
if (result && result.type === "success" && result.result.type === "boolean" && result.result.value) {
|
|
@@ -5656,11 +5706,11 @@ function toggleDisableDeprecationWarning() {
|
|
|
5656
5706
|
}
|
|
5657
5707
|
|
|
5658
5708
|
// src/commands/browser/throttle.ts
|
|
5659
|
-
import
|
|
5709
|
+
import logger19 from "@wdio/logger";
|
|
5660
5710
|
import { getBrowserObject as getBrowserObject9 } from "@wdio/utils";
|
|
5661
|
-
var
|
|
5711
|
+
var log19 = logger19("webdriverio:throttle");
|
|
5662
5712
|
async function throttle(params) {
|
|
5663
|
-
|
|
5713
|
+
log19.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
5664
5714
|
const browser = getBrowserObject9(this);
|
|
5665
5715
|
await browser.throttleNetwork(params);
|
|
5666
5716
|
}
|
|
@@ -5929,7 +5979,7 @@ function waitUntil(condition, {
|
|
|
5929
5979
|
}
|
|
5930
5980
|
|
|
5931
5981
|
// src/commands/mobile/swipe.ts
|
|
5932
|
-
import
|
|
5982
|
+
import logger20 from "@wdio/logger";
|
|
5933
5983
|
|
|
5934
5984
|
// src/types.ts
|
|
5935
5985
|
var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
@@ -5941,7 +5991,7 @@ var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
|
5941
5991
|
})(MobileScrollDirection || {});
|
|
5942
5992
|
|
|
5943
5993
|
// src/commands/mobile/swipe.ts
|
|
5944
|
-
var
|
|
5994
|
+
var log20 = logger20("webdriverio");
|
|
5945
5995
|
var SWIPE_DEFAULTS = {
|
|
5946
5996
|
DIRECTION: "up" /* Up */,
|
|
5947
5997
|
DURATION: 1500,
|
|
@@ -5954,7 +6004,7 @@ async function swipe(options) {
|
|
|
5954
6004
|
}
|
|
5955
6005
|
let { scrollableElement, from, to } = options || {};
|
|
5956
6006
|
if (scrollableElement && (from || to)) {
|
|
5957
|
-
|
|
6007
|
+
log20.warn("`scrollableElement` is provided, so `from` and `to` will be ignored.");
|
|
5958
6008
|
}
|
|
5959
6009
|
if (!from || !to) {
|
|
5960
6010
|
scrollableElement = scrollableElement || await getScrollableElement(browser);
|
|
@@ -5976,9 +6026,9 @@ async function calculateFromTo({
|
|
|
5976
6026
|
let swipePercentage = SWIPE_DEFAULTS.PERCENT;
|
|
5977
6027
|
if (percentage !== void 0) {
|
|
5978
6028
|
if (isNaN(percentage)) {
|
|
5979
|
-
|
|
6029
|
+
log20.warn("The percentage to swipe should be a number.");
|
|
5980
6030
|
} else if (percentage < 0 || percentage > 1) {
|
|
5981
|
-
|
|
6031
|
+
log20.warn("The percentage to swipe should be a number between 0 and 1.");
|
|
5982
6032
|
} else {
|
|
5983
6033
|
swipePercentage = percentage;
|
|
5984
6034
|
}
|
|
@@ -6048,9 +6098,9 @@ async function w3cSwipe({ browser, duration, from, to }) {
|
|
|
6048
6098
|
}
|
|
6049
6099
|
|
|
6050
6100
|
// src/commands/mobile/tap.ts
|
|
6051
|
-
import
|
|
6101
|
+
import logger21 from "@wdio/logger";
|
|
6052
6102
|
import { getBrowserObject as getBrowserObject12 } from "@wdio/utils";
|
|
6053
|
-
var
|
|
6103
|
+
var log21 = logger21("webdriver");
|
|
6054
6104
|
async function tap(options) {
|
|
6055
6105
|
const isElement2 = this.selector !== void 0;
|
|
6056
6106
|
const element = isElement2 ? this : null;
|
|
@@ -6096,7 +6146,7 @@ async function elementTap(browser, element, options) {
|
|
|
6096
6146
|
return await nativeTap(element, browser, options);
|
|
6097
6147
|
}
|
|
6098
6148
|
if (options) {
|
|
6099
|
-
|
|
6149
|
+
log21.warn("The options object is not supported in Web environments and will be ignored.");
|
|
6100
6150
|
}
|
|
6101
6151
|
return await webTap(element);
|
|
6102
6152
|
}
|
|
@@ -6177,8 +6227,8 @@ async function screenTap(browser, options) {
|
|
|
6177
6227
|
}
|
|
6178
6228
|
|
|
6179
6229
|
// src/commands/mobile/getContext.ts
|
|
6180
|
-
import
|
|
6181
|
-
var
|
|
6230
|
+
import logger22 from "@wdio/logger";
|
|
6231
|
+
var log22 = logger22("webdriver");
|
|
6182
6232
|
async function getContext(options) {
|
|
6183
6233
|
const browser = this;
|
|
6184
6234
|
if (!browser.isMobile) {
|
|
@@ -6206,25 +6256,25 @@ async function getDetailedContext(browser, currentAppiumContext, options) {
|
|
|
6206
6256
|
});
|
|
6207
6257
|
const parsedContexts = detailedContexts.filter((context) => context.id === currentAppiumContext);
|
|
6208
6258
|
if (parsedContexts.length > 1) {
|
|
6209
|
-
|
|
6259
|
+
log22.warn(`We found more than 1 detailed context for the current context '${currentAppiumContext}'. We will return the first context.`);
|
|
6210
6260
|
return parsedContexts[0];
|
|
6211
6261
|
} else if (parsedContexts.length === 0) {
|
|
6212
|
-
|
|
6262
|
+
log22.warn(`We did not get back any detailed context for the current context '${currentAppiumContext}'. We will return the current context as a string.`);
|
|
6213
6263
|
return currentAppiumContext;
|
|
6214
6264
|
}
|
|
6215
6265
|
return parsedContexts[0];
|
|
6216
6266
|
}
|
|
6217
6267
|
|
|
6218
6268
|
// src/commands/mobile/getContexts.ts
|
|
6219
|
-
import
|
|
6220
|
-
var
|
|
6269
|
+
import logger23 from "@wdio/logger";
|
|
6270
|
+
var log23 = logger23("webdriver");
|
|
6221
6271
|
async function getContexts(options) {
|
|
6222
6272
|
const browser = this;
|
|
6223
6273
|
if (!browser.isMobile) {
|
|
6224
6274
|
throw new Error("The `getContexts` command is only available for mobile platforms.");
|
|
6225
6275
|
}
|
|
6226
6276
|
if (!options || !options.returnDetailedContexts) {
|
|
6227
|
-
|
|
6277
|
+
log23.info("The standard Appium `contexts` method is used. If you want to get more detailed data, you can set `returnDetailedContexts` to `true`.");
|
|
6228
6278
|
return browser.getAppiumContexts();
|
|
6229
6279
|
}
|
|
6230
6280
|
const defaultOptions = {
|
|
@@ -6351,8 +6401,8 @@ async function getCurrentContexts({
|
|
|
6351
6401
|
}
|
|
6352
6402
|
|
|
6353
6403
|
// src/commands/mobile/switchContext.ts
|
|
6354
|
-
import
|
|
6355
|
-
var
|
|
6404
|
+
import logger24 from "@wdio/logger";
|
|
6405
|
+
var log24 = logger24("webdriver");
|
|
6356
6406
|
async function switchContext(options) {
|
|
6357
6407
|
const browser = this;
|
|
6358
6408
|
if (!browser.isMobile) {
|
|
@@ -6362,7 +6412,7 @@ async function switchContext(options) {
|
|
|
6362
6412
|
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.");
|
|
6363
6413
|
}
|
|
6364
6414
|
if (typeof options === "string") {
|
|
6365
|
-
|
|
6415
|
+
log24.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.");
|
|
6366
6416
|
return browser.switchAppiumContext(options);
|
|
6367
6417
|
}
|
|
6368
6418
|
if (!options.title && !options.url) {
|
|
@@ -6390,7 +6440,7 @@ async function switchToContext({ browser, options }) {
|
|
|
6390
6440
|
if (!matchingContext) {
|
|
6391
6441
|
throw new Error(reasons.join("\n"));
|
|
6392
6442
|
}
|
|
6393
|
-
|
|
6443
|
+
log24.info("WebdriverIO found a matching context:", JSON.stringify(matchingContext, null, 2));
|
|
6394
6444
|
if (!browser.isIOS) {
|
|
6395
6445
|
const webviewName = `WEBVIEW_${identifier}`;
|
|
6396
6446
|
await browser.switchAppiumContext(webviewName);
|
|
@@ -6457,7 +6507,7 @@ async function relaunchActiveApp() {
|
|
|
6457
6507
|
}
|
|
6458
6508
|
|
|
6459
6509
|
// src/commands/mobile/deepLink.ts
|
|
6460
|
-
async function deepLink(link, appIdentifier) {
|
|
6510
|
+
async function deepLink(link, appIdentifier, waitForLaunch) {
|
|
6461
6511
|
const browser = this;
|
|
6462
6512
|
if (!browser.isMobile) {
|
|
6463
6513
|
throw new Error("The `deepLink` command is only available for mobile platforms.");
|
|
@@ -6470,16 +6520,776 @@ async function deepLink(link, appIdentifier) {
|
|
|
6470
6520
|
const identifierValue = browser.isIOS ? "bundleId" : "package";
|
|
6471
6521
|
throw new Error(`When using a deep link URL for ${mobileOS}, you need to provide the \`${identifierValue}\` of the app that the deep link should open.`);
|
|
6472
6522
|
}
|
|
6473
|
-
|
|
6523
|
+
const args = {
|
|
6474
6524
|
url: link,
|
|
6475
6525
|
[browser.isIOS ? "bundleId" : "package"]: appIdentifier
|
|
6476
|
-
}
|
|
6526
|
+
};
|
|
6527
|
+
if (!browser.isIOS && waitForLaunch !== void 0) {
|
|
6528
|
+
args.waitForLaunch = waitForLaunch;
|
|
6529
|
+
}
|
|
6530
|
+
return browser.execute("mobile:deepLink", args);
|
|
6477
6531
|
}
|
|
6478
6532
|
function isDeepLinkUrl(link) {
|
|
6479
6533
|
const deepLinkRegex = /^(?!https?:\/\/)[a-zA-Z][\w+\-.]*:\/\//;
|
|
6480
6534
|
return deepLinkRegex.test(link);
|
|
6481
6535
|
}
|
|
6482
6536
|
|
|
6537
|
+
// src/commands/mobile/lock.ts
|
|
6538
|
+
async function lock(seconds) {
|
|
6539
|
+
const browser = this;
|
|
6540
|
+
if (!browser.isMobile) {
|
|
6541
|
+
throw new Error("The `lock` command is only available for mobile platforms.");
|
|
6542
|
+
}
|
|
6543
|
+
try {
|
|
6544
|
+
return await browser.execute("mobile: lock", { seconds });
|
|
6545
|
+
} catch (err) {
|
|
6546
|
+
if (!isUnknownMethodError(err)) {
|
|
6547
|
+
throw err;
|
|
6548
|
+
}
|
|
6549
|
+
logAppiumDeprecationWarning("mobile: lock", "/appium/device/lock");
|
|
6550
|
+
return browser.appiumLock(seconds);
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
|
|
6554
|
+
// src/commands/mobile/touchId.ts
|
|
6555
|
+
async function touchId(match, type = "touchId") {
|
|
6556
|
+
const browser = this;
|
|
6557
|
+
if (!browser.isMobile) {
|
|
6558
|
+
throw new Error("The `touchId` command is only available for mobile platforms.");
|
|
6559
|
+
}
|
|
6560
|
+
if (!browser.isIOS) {
|
|
6561
|
+
throw new Error("The `touchId` command is only available for iOS. For Android, use `fingerPrint` instead.");
|
|
6562
|
+
}
|
|
6563
|
+
try {
|
|
6564
|
+
return await browser.execute("mobile: sendBiometricMatch", { match, type });
|
|
6565
|
+
} catch (err) {
|
|
6566
|
+
if (!isUnknownMethodError(err)) {
|
|
6567
|
+
throw err;
|
|
6568
|
+
}
|
|
6569
|
+
logAppiumDeprecationWarning("mobile: sendBiometricMatch", "/appium/simulator/touch_id");
|
|
6570
|
+
return browser.appiumTouchId(match);
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6573
|
+
|
|
6574
|
+
// src/commands/mobile/toggleEnrollTouchId.ts
|
|
6575
|
+
async function toggleEnrollTouchId(enabled) {
|
|
6576
|
+
const browser = this;
|
|
6577
|
+
if (!browser.isMobile) {
|
|
6578
|
+
throw new Error("The `toggleEnrollTouchId` command is only available for mobile platforms.");
|
|
6579
|
+
}
|
|
6580
|
+
if (!browser.isIOS) {
|
|
6581
|
+
throw new Error("The `toggleEnrollTouchId` command is only available for iOS.");
|
|
6582
|
+
}
|
|
6583
|
+
try {
|
|
6584
|
+
return await browser.execute("mobile: enrollBiometric", { enabled });
|
|
6585
|
+
} catch (err) {
|
|
6586
|
+
if (!isUnknownMethodError(err)) {
|
|
6587
|
+
throw err;
|
|
6588
|
+
}
|
|
6589
|
+
logAppiumDeprecationWarning("mobile: enrollBiometric", "/appium/simulator/toggle_touch_id_enrollment");
|
|
6590
|
+
return browser.appiumToggleEnrollTouchId(enabled);
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6594
|
+
// src/commands/mobile/launchApp.ts
|
|
6595
|
+
async function launchApp(options) {
|
|
6596
|
+
const browser = this;
|
|
6597
|
+
if (!browser.isMobile) {
|
|
6598
|
+
throw new Error("The `launchApp` command is only available for mobile platforms.");
|
|
6599
|
+
}
|
|
6600
|
+
let mobileCmd;
|
|
6601
|
+
let mobileArgs;
|
|
6602
|
+
if (browser.isIOS) {
|
|
6603
|
+
mobileCmd = "mobile: launchApp";
|
|
6604
|
+
const bundleId = options?.bundleId ?? (await browser.execute("mobile: activeAppInfo")).bundleId;
|
|
6605
|
+
mobileArgs = { bundleId };
|
|
6606
|
+
if (options?.arguments !== void 0) {
|
|
6607
|
+
mobileArgs.arguments = options.arguments;
|
|
6608
|
+
}
|
|
6609
|
+
if (options?.environment !== void 0) {
|
|
6610
|
+
mobileArgs.environment = options.environment;
|
|
6611
|
+
}
|
|
6612
|
+
} else {
|
|
6613
|
+
mobileCmd = "mobile: activateApp";
|
|
6614
|
+
const appId = options?.appId ?? await browser.getCurrentPackage();
|
|
6615
|
+
mobileArgs = { appId };
|
|
6616
|
+
}
|
|
6617
|
+
try {
|
|
6618
|
+
return await browser.execute(mobileCmd, mobileArgs);
|
|
6619
|
+
} catch (err) {
|
|
6620
|
+
if (!isUnknownMethodError(err)) {
|
|
6621
|
+
throw err;
|
|
6622
|
+
}
|
|
6623
|
+
logAppiumDeprecationWarning(mobileCmd, "/appium/app/launch");
|
|
6624
|
+
return browser.appiumLaunchApp();
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
6627
|
+
|
|
6628
|
+
// src/commands/mobile/background.ts
|
|
6629
|
+
async function background(seconds) {
|
|
6630
|
+
const browser = this;
|
|
6631
|
+
if (!browser.isMobile) {
|
|
6632
|
+
throw new Error("The `background` command is only available for mobile platforms.");
|
|
6633
|
+
}
|
|
6634
|
+
try {
|
|
6635
|
+
return await browser.execute("mobile: backgroundApp", { seconds });
|
|
6636
|
+
} catch (err) {
|
|
6637
|
+
if (!isUnknownMethodError(err)) {
|
|
6638
|
+
throw err;
|
|
6639
|
+
}
|
|
6640
|
+
logAppiumDeprecationWarning("mobile: backgroundApp", "/appium/app/background");
|
|
6641
|
+
return browser.appiumBackground(seconds);
|
|
6642
|
+
}
|
|
6643
|
+
}
|
|
6644
|
+
|
|
6645
|
+
// src/commands/mobile/getStrings.ts
|
|
6646
|
+
async function getStrings(language, stringFile) {
|
|
6647
|
+
const browser = this;
|
|
6648
|
+
if (!browser.isMobile) {
|
|
6649
|
+
throw new Error("The `getStrings` command is only available for mobile platforms.");
|
|
6650
|
+
}
|
|
6651
|
+
try {
|
|
6652
|
+
return await browser.execute("mobile: getAppStrings", { language, stringFile });
|
|
6653
|
+
} catch (err) {
|
|
6654
|
+
if (!isUnknownMethodError(err)) {
|
|
6655
|
+
throw err;
|
|
6656
|
+
}
|
|
6657
|
+
logAppiumDeprecationWarning("mobile: getAppStrings", "/appium/app/strings");
|
|
6658
|
+
return browser.appiumGetStrings(language, stringFile);
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
|
|
6662
|
+
// src/commands/mobile/setClipboard.ts
|
|
6663
|
+
async function setClipboard(content, contentType, label) {
|
|
6664
|
+
const browser = this;
|
|
6665
|
+
if (!browser.isMobile) {
|
|
6666
|
+
throw new Error("The `setClipboard` command is only available for mobile platforms.");
|
|
6667
|
+
}
|
|
6668
|
+
try {
|
|
6669
|
+
return await browser.execute("mobile: setClipboard", { content, contentType, label });
|
|
6670
|
+
} catch (err) {
|
|
6671
|
+
if (!isUnknownMethodError(err)) {
|
|
6672
|
+
throw err;
|
|
6673
|
+
}
|
|
6674
|
+
logAppiumDeprecationWarning("mobile: setClipboard", "/appium/device/set_clipboard");
|
|
6675
|
+
return browser.appiumSetClipboard(content, contentType, label);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6679
|
+
// src/commands/mobile/getClipboard.ts
|
|
6680
|
+
async function getClipboard(contentType) {
|
|
6681
|
+
const browser = this;
|
|
6682
|
+
if (!browser.isMobile) {
|
|
6683
|
+
throw new Error("The `getClipboard` command is only available for mobile platforms.");
|
|
6684
|
+
}
|
|
6685
|
+
try {
|
|
6686
|
+
return await browser.execute("mobile: getClipboard", { contentType });
|
|
6687
|
+
} catch (err) {
|
|
6688
|
+
if (!isUnknownMethodError(err)) {
|
|
6689
|
+
throw err;
|
|
6690
|
+
}
|
|
6691
|
+
logAppiumDeprecationWarning("mobile: getClipboard", "/appium/device/get_clipboard");
|
|
6692
|
+
return browser.appiumGetClipboard(contentType);
|
|
6693
|
+
}
|
|
6694
|
+
}
|
|
6695
|
+
|
|
6696
|
+
// src/commands/mobile/queryAppState.ts
|
|
6697
|
+
async function queryAppState(appId, bundleId) {
|
|
6698
|
+
const browser = this;
|
|
6699
|
+
if (!browser.isMobile) {
|
|
6700
|
+
throw new Error("The `queryAppState` command is only available for mobile platforms.");
|
|
6701
|
+
}
|
|
6702
|
+
try {
|
|
6703
|
+
return await browser.execute("mobile: queryAppState", { appId, bundleId });
|
|
6704
|
+
} catch (err) {
|
|
6705
|
+
if (!isUnknownMethodError(err)) {
|
|
6706
|
+
throw err;
|
|
6707
|
+
}
|
|
6708
|
+
logAppiumDeprecationWarning("mobile: queryAppState", "/appium/device/app_state");
|
|
6709
|
+
return browser.appiumQueryAppState(appId, bundleId);
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
// src/commands/mobile/toggleAirplaneMode.ts
|
|
6714
|
+
async function toggleAirplaneMode(enabled) {
|
|
6715
|
+
const browser = this;
|
|
6716
|
+
if (!browser.isMobile) {
|
|
6717
|
+
throw new Error("The `toggleAirplaneMode` command is only available for mobile platforms.");
|
|
6718
|
+
}
|
|
6719
|
+
if (!browser.isAndroid) {
|
|
6720
|
+
throw new Error("The `toggleAirplaneMode` command is only available for Android.");
|
|
6721
|
+
}
|
|
6722
|
+
try {
|
|
6723
|
+
return await browser.execute("mobile: setConnectivity", { airplaneMode: enabled });
|
|
6724
|
+
} catch (err) {
|
|
6725
|
+
if (!isUnknownMethodError(err)) {
|
|
6726
|
+
throw err;
|
|
6727
|
+
}
|
|
6728
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_airplane_mode");
|
|
6729
|
+
return browser.appiumToggleAirplaneMode();
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
|
|
6733
|
+
// src/commands/mobile/toggleData.ts
|
|
6734
|
+
async function toggleData(enabled) {
|
|
6735
|
+
const browser = this;
|
|
6736
|
+
if (!browser.isMobile) {
|
|
6737
|
+
throw new Error("The `toggleData` command is only available for mobile platforms.");
|
|
6738
|
+
}
|
|
6739
|
+
if (!browser.isAndroid) {
|
|
6740
|
+
throw new Error("The `toggleData` command is only available for Android.");
|
|
6741
|
+
}
|
|
6742
|
+
try {
|
|
6743
|
+
return await browser.execute("mobile: setConnectivity", { data: enabled });
|
|
6744
|
+
} catch (err) {
|
|
6745
|
+
if (!isUnknownMethodError(err)) {
|
|
6746
|
+
throw err;
|
|
6747
|
+
}
|
|
6748
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_data");
|
|
6749
|
+
return browser.appiumToggleData();
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
|
|
6753
|
+
// src/commands/mobile/toggleWiFi.ts
|
|
6754
|
+
async function toggleWiFi(enabled) {
|
|
6755
|
+
const browser = this;
|
|
6756
|
+
if (!browser.isMobile) {
|
|
6757
|
+
throw new Error("The `toggleWiFi` command is only available for mobile platforms.");
|
|
6758
|
+
}
|
|
6759
|
+
if (!browser.isAndroid) {
|
|
6760
|
+
throw new Error("The `toggleWiFi` command is only available for Android.");
|
|
6761
|
+
}
|
|
6762
|
+
try {
|
|
6763
|
+
return await browser.execute("mobile: setConnectivity", { wifi: enabled });
|
|
6764
|
+
} catch (err) {
|
|
6765
|
+
if (!isUnknownMethodError(err)) {
|
|
6766
|
+
throw err;
|
|
6767
|
+
}
|
|
6768
|
+
logAppiumDeprecationWarning("mobile: setConnectivity", "/appium/device/toggle_wifi");
|
|
6769
|
+
return browser.appiumToggleWiFi();
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
|
|
6773
|
+
// src/commands/mobile/unlock.ts
|
|
6774
|
+
async function unlock(options) {
|
|
6775
|
+
const browser = this;
|
|
6776
|
+
if (!browser.isMobile) {
|
|
6777
|
+
throw new Error("The `unlock` command is only available for mobile platforms.");
|
|
6778
|
+
}
|
|
6779
|
+
const args = browser.isAndroid && options ? { ...options } : {};
|
|
6780
|
+
try {
|
|
6781
|
+
return await browser.execute("mobile: unlock", args);
|
|
6782
|
+
} catch (err) {
|
|
6783
|
+
if (!isUnknownMethodError(err)) {
|
|
6784
|
+
throw err;
|
|
6785
|
+
}
|
|
6786
|
+
logAppiumDeprecationWarning("mobile: unlock", "/appium/device/unlock");
|
|
6787
|
+
return browser.appiumUnlock();
|
|
6788
|
+
}
|
|
6789
|
+
}
|
|
6790
|
+
|
|
6791
|
+
// src/commands/mobile/isLocked.ts
|
|
6792
|
+
async function isLocked() {
|
|
6793
|
+
const browser = this;
|
|
6794
|
+
if (!browser.isMobile) {
|
|
6795
|
+
throw new Error("The `isLocked` command is only available for mobile platforms.");
|
|
6796
|
+
}
|
|
6797
|
+
try {
|
|
6798
|
+
return await browser.execute("mobile: isLocked", {});
|
|
6799
|
+
} catch (err) {
|
|
6800
|
+
if (!isUnknownMethodError(err)) {
|
|
6801
|
+
throw err;
|
|
6802
|
+
}
|
|
6803
|
+
logAppiumDeprecationWarning("mobile: isLocked", "/appium/device/is_locked");
|
|
6804
|
+
return browser.appiumIsLocked();
|
|
6805
|
+
}
|
|
6806
|
+
}
|
|
6807
|
+
|
|
6808
|
+
// src/commands/mobile/shake.ts
|
|
6809
|
+
async function shake() {
|
|
6810
|
+
const browser = this;
|
|
6811
|
+
if (!browser.isMobile) {
|
|
6812
|
+
throw new Error("The `shake` command is only available for mobile platforms.");
|
|
6813
|
+
}
|
|
6814
|
+
if (!browser.isIOS) {
|
|
6815
|
+
throw new Error("The `shake` command is only available for iOS.");
|
|
6816
|
+
}
|
|
6817
|
+
try {
|
|
6818
|
+
return await browser.execute("mobile: shake", {});
|
|
6819
|
+
} catch (err) {
|
|
6820
|
+
if (!isUnknownMethodError(err)) {
|
|
6821
|
+
throw err;
|
|
6822
|
+
}
|
|
6823
|
+
logAppiumDeprecationWarning("mobile: shake", "/appium/device/shake");
|
|
6824
|
+
return browser.appiumShake();
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6827
|
+
|
|
6828
|
+
// src/commands/mobile/closeApp.ts
|
|
6829
|
+
async function closeApp(options) {
|
|
6830
|
+
const browser = this;
|
|
6831
|
+
if (!browser.isMobile) {
|
|
6832
|
+
throw new Error("The `closeApp` command is only available for mobile platforms.");
|
|
6833
|
+
}
|
|
6834
|
+
let terminateArgs;
|
|
6835
|
+
if (browser.isIOS) {
|
|
6836
|
+
const bundleId = options?.bundleId ?? (await browser.execute("mobile: activeAppInfo")).bundleId;
|
|
6837
|
+
terminateArgs = { bundleId };
|
|
6838
|
+
} else {
|
|
6839
|
+
const appId = options?.appId ?? await browser.getCurrentPackage();
|
|
6840
|
+
terminateArgs = { appId };
|
|
6841
|
+
}
|
|
6842
|
+
try {
|
|
6843
|
+
return await browser.execute("mobile: terminateApp", terminateArgs);
|
|
6844
|
+
} catch (err) {
|
|
6845
|
+
if (!isUnknownMethodError(err)) {
|
|
6846
|
+
throw err;
|
|
6847
|
+
}
|
|
6848
|
+
logAppiumDeprecationWarning("mobile: terminateApp", "/appium/app/close");
|
|
6849
|
+
return browser.appiumCloseApp();
|
|
6850
|
+
}
|
|
6851
|
+
}
|
|
6852
|
+
|
|
6853
|
+
// src/commands/mobile/getCurrentActivity.ts
|
|
6854
|
+
async function getCurrentActivity() {
|
|
6855
|
+
const browser = this;
|
|
6856
|
+
if (!browser.isMobile) {
|
|
6857
|
+
throw new Error("The `getCurrentActivity` command is only available for mobile platforms.");
|
|
6858
|
+
}
|
|
6859
|
+
if (!browser.isAndroid) {
|
|
6860
|
+
throw new Error("The `getCurrentActivity` command is only available for Android.");
|
|
6861
|
+
}
|
|
6862
|
+
try {
|
|
6863
|
+
return await browser.execute("mobile: getCurrentActivity", {});
|
|
6864
|
+
} catch (err) {
|
|
6865
|
+
if (!isUnknownMethodError(err)) {
|
|
6866
|
+
throw err;
|
|
6867
|
+
}
|
|
6868
|
+
logAppiumDeprecationWarning("mobile: getCurrentActivity", "/appium/device/current_activity");
|
|
6869
|
+
return browser.appiumGetCurrentActivity();
|
|
6870
|
+
}
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6873
|
+
// src/commands/mobile/getCurrentPackage.ts
|
|
6874
|
+
async function getCurrentPackage() {
|
|
6875
|
+
const browser = this;
|
|
6876
|
+
if (!browser.isMobile) {
|
|
6877
|
+
throw new Error("The `getCurrentPackage` command is only available for mobile platforms.");
|
|
6878
|
+
}
|
|
6879
|
+
if (!browser.isAndroid) {
|
|
6880
|
+
throw new Error("The `getCurrentPackage` command is only available for Android.");
|
|
6881
|
+
}
|
|
6882
|
+
try {
|
|
6883
|
+
return await browser.execute("mobile: getCurrentPackage", {});
|
|
6884
|
+
} catch (err) {
|
|
6885
|
+
if (!isUnknownMethodError(err)) {
|
|
6886
|
+
throw err;
|
|
6887
|
+
}
|
|
6888
|
+
logAppiumDeprecationWarning("mobile: getCurrentPackage", "/appium/device/current_package");
|
|
6889
|
+
return browser.appiumGetCurrentPackage();
|
|
6890
|
+
}
|
|
6891
|
+
}
|
|
6892
|
+
|
|
6893
|
+
// src/commands/mobile/getPerformanceData.ts
|
|
6894
|
+
async function getPerformanceData(packageName, dataType, dataReadTimeout) {
|
|
6895
|
+
const browser = this;
|
|
6896
|
+
if (!browser.isMobile) {
|
|
6897
|
+
throw new Error("The `getPerformanceData` command is only available for mobile platforms.");
|
|
6898
|
+
}
|
|
6899
|
+
if (!browser.isAndroid) {
|
|
6900
|
+
throw new Error("The `getPerformanceData` command is only available for Android.");
|
|
6901
|
+
}
|
|
6902
|
+
try {
|
|
6903
|
+
return await browser.execute("mobile: getPerformanceData", { packageName, dataType, dataReadTimeout });
|
|
6904
|
+
} catch (err) {
|
|
6905
|
+
if (!isUnknownMethodError(err)) {
|
|
6906
|
+
throw err;
|
|
6907
|
+
}
|
|
6908
|
+
logAppiumDeprecationWarning("mobile: getPerformanceData", "/appium/getPerformanceData");
|
|
6909
|
+
return browser.appiumGetPerformanceData(packageName, dataType, dataReadTimeout);
|
|
6910
|
+
}
|
|
6911
|
+
}
|
|
6912
|
+
|
|
6913
|
+
// src/commands/mobile/getPerformanceDataTypes.ts
|
|
6914
|
+
async function getPerformanceDataTypes() {
|
|
6915
|
+
const browser = this;
|
|
6916
|
+
if (!browser.isMobile) {
|
|
6917
|
+
throw new Error("The `getPerformanceDataTypes` command is only available for mobile platforms.");
|
|
6918
|
+
}
|
|
6919
|
+
if (!browser.isAndroid) {
|
|
6920
|
+
throw new Error("The `getPerformanceDataTypes` command is only available for Android.");
|
|
6921
|
+
}
|
|
6922
|
+
try {
|
|
6923
|
+
return await browser.execute("mobile: getPerformanceDataTypes", {});
|
|
6924
|
+
} catch (err) {
|
|
6925
|
+
if (!isUnknownMethodError(err)) {
|
|
6926
|
+
throw err;
|
|
6927
|
+
}
|
|
6928
|
+
logAppiumDeprecationWarning("mobile: getPerformanceDataTypes", "/appium/performanceData/types");
|
|
6929
|
+
return browser.appiumGetPerformanceDataTypes();
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
|
|
6933
|
+
// src/commands/mobile/getSystemBars.ts
|
|
6934
|
+
async function getSystemBars() {
|
|
6935
|
+
const browser = this;
|
|
6936
|
+
if (!browser.isMobile) {
|
|
6937
|
+
throw new Error("The `getSystemBars` command is only available for mobile platforms.");
|
|
6938
|
+
}
|
|
6939
|
+
if (!browser.isAndroid) {
|
|
6940
|
+
throw new Error("The `getSystemBars` command is only available for Android.");
|
|
6941
|
+
}
|
|
6942
|
+
try {
|
|
6943
|
+
return await browser.execute("mobile: getSystemBars", {});
|
|
6944
|
+
} catch (err) {
|
|
6945
|
+
if (!isUnknownMethodError(err)) {
|
|
6946
|
+
throw err;
|
|
6947
|
+
}
|
|
6948
|
+
logAppiumDeprecationWarning("mobile: getSystemBars", "/appium/device/system_bars");
|
|
6949
|
+
return browser.appiumGetSystemBars();
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
|
|
6953
|
+
// src/commands/mobile/getDisplayDensity.ts
|
|
6954
|
+
async function getDisplayDensity() {
|
|
6955
|
+
const browser = this;
|
|
6956
|
+
if (!browser.isMobile) {
|
|
6957
|
+
throw new Error("The `getDisplayDensity` command is only available for mobile platforms.");
|
|
6958
|
+
}
|
|
6959
|
+
if (!browser.isAndroid) {
|
|
6960
|
+
throw new Error("The `getDisplayDensity` command is only available for Android.");
|
|
6961
|
+
}
|
|
6962
|
+
try {
|
|
6963
|
+
return await browser.execute("mobile: getDisplayDensity", {});
|
|
6964
|
+
} catch (err) {
|
|
6965
|
+
if (!isUnknownMethodError(err)) {
|
|
6966
|
+
throw err;
|
|
6967
|
+
}
|
|
6968
|
+
logAppiumDeprecationWarning("mobile: getDisplayDensity", "/appium/device/display_density");
|
|
6969
|
+
return browser.appiumGetDisplayDensity();
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6972
|
+
|
|
6973
|
+
// src/commands/mobile/pressKeyCode.ts
|
|
6974
|
+
async function pressKeyCode(keycode, metastate, flags) {
|
|
6975
|
+
const browser = this;
|
|
6976
|
+
if (!browser.isMobile) {
|
|
6977
|
+
throw new Error("The `pressKeyCode` command is only available for mobile platforms.");
|
|
6978
|
+
}
|
|
6979
|
+
if (!browser.isAndroid) {
|
|
6980
|
+
throw new Error("The `pressKeyCode` command is only available for Android.");
|
|
6981
|
+
}
|
|
6982
|
+
try {
|
|
6983
|
+
return await browser.execute("mobile: pressKey", { keycode, metastate, flags });
|
|
6984
|
+
} catch (err) {
|
|
6985
|
+
if (!isUnknownMethodError(err)) {
|
|
6986
|
+
throw err;
|
|
6987
|
+
}
|
|
6988
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/press_keycode");
|
|
6989
|
+
return browser.appiumPressKeyCode(keycode, metastate, flags);
|
|
6990
|
+
}
|
|
6991
|
+
}
|
|
6992
|
+
|
|
6993
|
+
// src/commands/mobile/longPressKeyCode.ts
|
|
6994
|
+
async function longPressKeyCode(keycode, metastate, flags) {
|
|
6995
|
+
const browser = this;
|
|
6996
|
+
if (!browser.isMobile) {
|
|
6997
|
+
throw new Error("The `longPressKeyCode` command is only available for mobile platforms.");
|
|
6998
|
+
}
|
|
6999
|
+
if (!browser.isAndroid) {
|
|
7000
|
+
throw new Error("The `longPressKeyCode` command is only available for Android.");
|
|
7001
|
+
}
|
|
7002
|
+
try {
|
|
7003
|
+
return await browser.execute("mobile: pressKey", { keycode, metastate, flags, isLongPress: true });
|
|
7004
|
+
} catch (err) {
|
|
7005
|
+
if (!isUnknownMethodError(err)) {
|
|
7006
|
+
throw err;
|
|
7007
|
+
}
|
|
7008
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/long_press_keycode");
|
|
7009
|
+
return browser.appiumLongPressKeyCode(keycode, metastate, flags);
|
|
7010
|
+
}
|
|
7011
|
+
}
|
|
7012
|
+
|
|
7013
|
+
// src/commands/mobile/sendKeyEvent.ts
|
|
7014
|
+
async function sendKeyEvent(keycode, metastate) {
|
|
7015
|
+
const browser = this;
|
|
7016
|
+
if (!browser.isMobile) {
|
|
7017
|
+
throw new Error("The `sendKeyEvent` command is only available for mobile platforms.");
|
|
7018
|
+
}
|
|
7019
|
+
if (!browser.isAndroid) {
|
|
7020
|
+
throw new Error("The `sendKeyEvent` command is only available for Android.");
|
|
7021
|
+
}
|
|
7022
|
+
try {
|
|
7023
|
+
const args = { keycode: parseInt(keycode, 10) };
|
|
7024
|
+
if (metastate !== void 0) {
|
|
7025
|
+
args.metastate = parseInt(metastate, 10);
|
|
7026
|
+
}
|
|
7027
|
+
return await browser.execute("mobile: pressKey", args);
|
|
7028
|
+
} catch (err) {
|
|
7029
|
+
if (!isUnknownMethodError(err)) {
|
|
7030
|
+
throw err;
|
|
7031
|
+
}
|
|
7032
|
+
logAppiumDeprecationWarning("mobile: pressKey", "/appium/device/keyevent");
|
|
7033
|
+
return browser.appiumSendKeyEvent(keycode, metastate);
|
|
7034
|
+
}
|
|
7035
|
+
}
|
|
7036
|
+
|
|
7037
|
+
// src/commands/mobile/startActivity.ts
|
|
7038
|
+
async function startActivity(appPackageOrOptions, appActivity, appWaitPackage, appWaitActivity, intentAction, intentCategory, intentFlags, optionalIntentArguments, dontStopAppOnReset) {
|
|
7039
|
+
const browser = this;
|
|
7040
|
+
if (!browser.isMobile) {
|
|
7041
|
+
throw new Error("The `startActivity` command is only available for mobile platforms.");
|
|
7042
|
+
}
|
|
7043
|
+
if (!browser.isAndroid) {
|
|
7044
|
+
throw new Error("The `startActivity` command is only available for Android.");
|
|
7045
|
+
}
|
|
7046
|
+
const opts = typeof appPackageOrOptions === "object" ? appPackageOrOptions : {
|
|
7047
|
+
appPackage: appPackageOrOptions,
|
|
7048
|
+
appActivity,
|
|
7049
|
+
appWaitPackage,
|
|
7050
|
+
appWaitActivity,
|
|
7051
|
+
intentAction,
|
|
7052
|
+
intentCategory,
|
|
7053
|
+
intentFlags,
|
|
7054
|
+
optionalIntentArguments,
|
|
7055
|
+
dontStopAppOnReset
|
|
7056
|
+
};
|
|
7057
|
+
const mobileArgs = {
|
|
7058
|
+
component: `${opts.appPackage}/${opts.appActivity}`
|
|
7059
|
+
};
|
|
7060
|
+
if (opts.intentAction !== void 0) {
|
|
7061
|
+
mobileArgs.action = opts.intentAction;
|
|
7062
|
+
}
|
|
7063
|
+
if (opts.intentCategory !== void 0) {
|
|
7064
|
+
mobileArgs.categories = opts.intentCategory;
|
|
7065
|
+
}
|
|
7066
|
+
if (opts.intentFlags !== void 0) {
|
|
7067
|
+
mobileArgs.flags = opts.intentFlags;
|
|
7068
|
+
}
|
|
7069
|
+
if (opts.dontStopAppOnReset !== void 0) {
|
|
7070
|
+
mobileArgs.stop = opts.dontStopAppOnReset !== "true";
|
|
7071
|
+
}
|
|
7072
|
+
try {
|
|
7073
|
+
return await browser.execute("mobile: startActivity", mobileArgs);
|
|
7074
|
+
} catch (err) {
|
|
7075
|
+
if (!isUnknownMethodError(err)) {
|
|
7076
|
+
throw err;
|
|
7077
|
+
}
|
|
7078
|
+
logAppiumDeprecationWarning("mobile: startActivity", "/appium/device/start_activity");
|
|
7079
|
+
return browser.appiumStartActivity(
|
|
7080
|
+
opts.appPackage,
|
|
7081
|
+
opts.appActivity,
|
|
7082
|
+
opts.appWaitPackage,
|
|
7083
|
+
opts.appWaitActivity,
|
|
7084
|
+
opts.intentAction,
|
|
7085
|
+
opts.intentCategory,
|
|
7086
|
+
opts.intentFlags,
|
|
7087
|
+
opts.optionalIntentArguments,
|
|
7088
|
+
opts.dontStopAppOnReset
|
|
7089
|
+
);
|
|
7090
|
+
}
|
|
7091
|
+
}
|
|
7092
|
+
|
|
7093
|
+
// src/commands/mobile/openNotifications.ts
|
|
7094
|
+
async function openNotifications() {
|
|
7095
|
+
const browser = this;
|
|
7096
|
+
if (!browser.isMobile) {
|
|
7097
|
+
throw new Error("The `openNotifications` command is only available for mobile platforms.");
|
|
7098
|
+
}
|
|
7099
|
+
if (!browser.isAndroid) {
|
|
7100
|
+
throw new Error("The `openNotifications` command is only available for Android.");
|
|
7101
|
+
}
|
|
7102
|
+
try {
|
|
7103
|
+
return await browser.execute("mobile: openNotifications", {});
|
|
7104
|
+
} catch (err) {
|
|
7105
|
+
if (!isUnknownMethodError(err)) {
|
|
7106
|
+
throw err;
|
|
7107
|
+
}
|
|
7108
|
+
logAppiumDeprecationWarning("mobile: openNotifications", "/appium/device/open_notifications");
|
|
7109
|
+
return browser.appiumOpenNotifications();
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7113
|
+
// src/commands/mobile/toggleLocationServices.ts
|
|
7114
|
+
async function toggleLocationServices() {
|
|
7115
|
+
const browser = this;
|
|
7116
|
+
if (!browser.isMobile) {
|
|
7117
|
+
throw new Error("The `toggleLocationServices` command is only available for mobile platforms.");
|
|
7118
|
+
}
|
|
7119
|
+
if (!browser.isAndroid) {
|
|
7120
|
+
throw new Error("The `toggleLocationServices` command is only available for Android.");
|
|
7121
|
+
}
|
|
7122
|
+
try {
|
|
7123
|
+
return await browser.execute("mobile: toggleGps", {});
|
|
7124
|
+
} catch (err) {
|
|
7125
|
+
if (!isUnknownMethodError(err)) {
|
|
7126
|
+
throw err;
|
|
7127
|
+
}
|
|
7128
|
+
logAppiumDeprecationWarning("mobile: toggleGps", "/appium/device/toggle_location_services");
|
|
7129
|
+
return browser.appiumToggleLocationServices();
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
|
|
7133
|
+
// src/commands/mobile/toggleNetworkSpeed.ts
|
|
7134
|
+
async function toggleNetworkSpeed(netspeed) {
|
|
7135
|
+
const browser = this;
|
|
7136
|
+
if (!browser.isMobile) {
|
|
7137
|
+
throw new Error("The `toggleNetworkSpeed` command is only available for mobile platforms.");
|
|
7138
|
+
}
|
|
7139
|
+
if (!browser.isAndroid) {
|
|
7140
|
+
throw new Error("The `toggleNetworkSpeed` command is only available for Android.");
|
|
7141
|
+
}
|
|
7142
|
+
try {
|
|
7143
|
+
return await browser.execute("mobile: networkSpeed", { netspeed });
|
|
7144
|
+
} catch (err) {
|
|
7145
|
+
if (!isUnknownMethodError(err)) {
|
|
7146
|
+
throw err;
|
|
7147
|
+
}
|
|
7148
|
+
logAppiumDeprecationWarning("mobile: networkSpeed", "/appium/device/network_speed");
|
|
7149
|
+
return browser.appiumToggleNetworkSpeed(netspeed);
|
|
7150
|
+
}
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
// src/commands/mobile/gsmCall.ts
|
|
7154
|
+
async function gsmCall(phoneNumber, action2) {
|
|
7155
|
+
const browser = this;
|
|
7156
|
+
if (!browser.isMobile) {
|
|
7157
|
+
throw new Error("The `gsmCall` command is only available for mobile platforms.");
|
|
7158
|
+
}
|
|
7159
|
+
if (!browser.isAndroid) {
|
|
7160
|
+
throw new Error("The `gsmCall` command is only available for Android.");
|
|
7161
|
+
}
|
|
7162
|
+
try {
|
|
7163
|
+
return await browser.execute("mobile: gsmCall", { phoneNumber, action: action2 });
|
|
7164
|
+
} catch (err) {
|
|
7165
|
+
if (!isUnknownMethodError(err)) {
|
|
7166
|
+
throw err;
|
|
7167
|
+
}
|
|
7168
|
+
logAppiumDeprecationWarning("mobile: gsmCall", "/appium/device/gsm_call");
|
|
7169
|
+
return browser.appiumGsmCall(phoneNumber, action2);
|
|
7170
|
+
}
|
|
7171
|
+
}
|
|
7172
|
+
|
|
7173
|
+
// src/commands/mobile/gsmSignal.ts
|
|
7174
|
+
async function gsmSignal(signalStrength) {
|
|
7175
|
+
const browser = this;
|
|
7176
|
+
if (!browser.isMobile) {
|
|
7177
|
+
throw new Error("The `gsmSignal` command is only available for mobile platforms.");
|
|
7178
|
+
}
|
|
7179
|
+
if (!browser.isAndroid) {
|
|
7180
|
+
throw new Error("The `gsmSignal` command is only available for Android.");
|
|
7181
|
+
}
|
|
7182
|
+
try {
|
|
7183
|
+
return await browser.execute("mobile: gsmSignal", { signalStrength });
|
|
7184
|
+
} catch (err) {
|
|
7185
|
+
if (!isUnknownMethodError(err)) {
|
|
7186
|
+
throw err;
|
|
7187
|
+
}
|
|
7188
|
+
logAppiumDeprecationWarning("mobile: gsmSignal", "/appium/device/gsm_signal");
|
|
7189
|
+
return browser.appiumGsmSignal(String(signalStrength));
|
|
7190
|
+
}
|
|
7191
|
+
}
|
|
7192
|
+
|
|
7193
|
+
// src/commands/mobile/gsmVoice.ts
|
|
7194
|
+
async function gsmVoice(state) {
|
|
7195
|
+
const browser = this;
|
|
7196
|
+
if (!browser.isMobile) {
|
|
7197
|
+
throw new Error("The `gsmVoice` command is only available for mobile platforms.");
|
|
7198
|
+
}
|
|
7199
|
+
if (!browser.isAndroid) {
|
|
7200
|
+
throw new Error("The `gsmVoice` command is only available for Android.");
|
|
7201
|
+
}
|
|
7202
|
+
try {
|
|
7203
|
+
return await browser.execute("mobile: gsmVoice", { state });
|
|
7204
|
+
} catch (err) {
|
|
7205
|
+
if (!isUnknownMethodError(err)) {
|
|
7206
|
+
throw err;
|
|
7207
|
+
}
|
|
7208
|
+
logAppiumDeprecationWarning("mobile: gsmVoice", "/appium/device/gsm_voice");
|
|
7209
|
+
return browser.appiumGsmVoice(state);
|
|
7210
|
+
}
|
|
7211
|
+
}
|
|
7212
|
+
|
|
7213
|
+
// src/commands/mobile/sendSms.ts
|
|
7214
|
+
async function sendSms(phoneNumber, message) {
|
|
7215
|
+
const browser = this;
|
|
7216
|
+
if (!browser.isMobile) {
|
|
7217
|
+
throw new Error("The `sendSms` command is only available for mobile platforms.");
|
|
7218
|
+
}
|
|
7219
|
+
if (!browser.isAndroid) {
|
|
7220
|
+
throw new Error("The `sendSms` command is only available for Android.");
|
|
7221
|
+
}
|
|
7222
|
+
try {
|
|
7223
|
+
return await browser.execute("mobile: sendSms", { phoneNumber, message });
|
|
7224
|
+
} catch (err) {
|
|
7225
|
+
if (!isUnknownMethodError(err)) {
|
|
7226
|
+
throw err;
|
|
7227
|
+
}
|
|
7228
|
+
logAppiumDeprecationWarning("mobile: sendSms", "/appium/device/send_sms");
|
|
7229
|
+
return browser.appiumSendSms(phoneNumber, message);
|
|
7230
|
+
}
|
|
7231
|
+
}
|
|
7232
|
+
|
|
7233
|
+
// src/commands/mobile/fingerPrint.ts
|
|
7234
|
+
async function fingerPrint(fingerprintId) {
|
|
7235
|
+
const browser = this;
|
|
7236
|
+
if (!browser.isMobile) {
|
|
7237
|
+
throw new Error("The `fingerPrint` command is only available for mobile platforms.");
|
|
7238
|
+
}
|
|
7239
|
+
if (!browser.isAndroid) {
|
|
7240
|
+
throw new Error("The `fingerPrint` command is only available for Android. For iOS, use `touchId` instead.");
|
|
7241
|
+
}
|
|
7242
|
+
try {
|
|
7243
|
+
return await browser.execute("mobile: fingerprint", { fingerprintId });
|
|
7244
|
+
} catch (err) {
|
|
7245
|
+
if (!isUnknownMethodError(err)) {
|
|
7246
|
+
throw err;
|
|
7247
|
+
}
|
|
7248
|
+
logAppiumDeprecationWarning("mobile: fingerprint", "/appium/device/finger_print");
|
|
7249
|
+
return browser.appiumFingerPrint(fingerprintId);
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
|
|
7253
|
+
// src/commands/mobile/powerCapacity.ts
|
|
7254
|
+
async function powerCapacity(percent) {
|
|
7255
|
+
const browser = this;
|
|
7256
|
+
if (!browser.isMobile) {
|
|
7257
|
+
throw new Error("The `powerCapacity` command is only available for mobile platforms.");
|
|
7258
|
+
}
|
|
7259
|
+
if (!browser.isAndroid) {
|
|
7260
|
+
throw new Error("The `powerCapacity` command is only available for Android.");
|
|
7261
|
+
}
|
|
7262
|
+
try {
|
|
7263
|
+
return await browser.execute("mobile: powerCapacity", { percent });
|
|
7264
|
+
} catch (err) {
|
|
7265
|
+
if (!isUnknownMethodError(err)) {
|
|
7266
|
+
throw err;
|
|
7267
|
+
}
|
|
7268
|
+
logAppiumDeprecationWarning("mobile: powerCapacity", "/appium/device/power_capacity");
|
|
7269
|
+
return browser.appiumPowerCapacity(percent);
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
|
|
7273
|
+
// src/commands/mobile/powerAC.ts
|
|
7274
|
+
async function powerAC(state) {
|
|
7275
|
+
const browser = this;
|
|
7276
|
+
if (!browser.isMobile) {
|
|
7277
|
+
throw new Error("The `powerAC` command is only available for mobile platforms.");
|
|
7278
|
+
}
|
|
7279
|
+
if (!browser.isAndroid) {
|
|
7280
|
+
throw new Error("The `powerAC` command is only available for Android.");
|
|
7281
|
+
}
|
|
7282
|
+
try {
|
|
7283
|
+
return await browser.execute("mobile: powerAC", { state });
|
|
7284
|
+
} catch (err) {
|
|
7285
|
+
if (!isUnknownMethodError(err)) {
|
|
7286
|
+
throw err;
|
|
7287
|
+
}
|
|
7288
|
+
logAppiumDeprecationWarning("mobile: powerAC", "/appium/device/power_ac");
|
|
7289
|
+
return browser.appiumPowerAC(state);
|
|
7290
|
+
}
|
|
7291
|
+
}
|
|
7292
|
+
|
|
6483
7293
|
// src/commands/element.ts
|
|
6484
7294
|
var element_exports = {};
|
|
6485
7295
|
__export(element_exports, {
|
|
@@ -6568,9 +7378,9 @@ function clearValue() {
|
|
|
6568
7378
|
}
|
|
6569
7379
|
|
|
6570
7380
|
// src/commands/element/click.ts
|
|
6571
|
-
import
|
|
7381
|
+
import logger25 from "@wdio/logger";
|
|
6572
7382
|
import { getBrowserObject as getBrowserObject13 } from "@wdio/utils";
|
|
6573
|
-
var
|
|
7383
|
+
var log25 = logger25("webdriver");
|
|
6574
7384
|
function click(options) {
|
|
6575
7385
|
if (typeof options !== "undefined") {
|
|
6576
7386
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
@@ -6617,10 +7427,10 @@ async function actionClick(element, options) {
|
|
|
6617
7427
|
if (x || y) {
|
|
6618
7428
|
const { width, height } = await browser.getElementRect(element.elementId);
|
|
6619
7429
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
6620
|
-
|
|
7430
|
+
log25.warn("x would cause a out of bounds error as it goes outside of element");
|
|
6621
7431
|
}
|
|
6622
7432
|
if (y && y < -Math.floor(height / 2) || y && y > Math.floor(height / 2)) {
|
|
6623
|
-
|
|
7433
|
+
log25.warn("y would cause a out of bounds error as it goes outside of element");
|
|
6624
7434
|
}
|
|
6625
7435
|
}
|
|
6626
7436
|
const clickNested = async () => {
|
|
@@ -7164,18 +7974,18 @@ async function isStable() {
|
|
|
7164
7974
|
}
|
|
7165
7975
|
|
|
7166
7976
|
// src/commands/element/moveTo.ts
|
|
7167
|
-
import
|
|
7977
|
+
import logger26 from "@wdio/logger";
|
|
7168
7978
|
import { getBrowserObject as getBrowserObject27 } from "@wdio/utils";
|
|
7169
|
-
var
|
|
7979
|
+
var log26 = logger26("webdriver");
|
|
7170
7980
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
7171
7981
|
const browser = getBrowserObject27(this);
|
|
7172
7982
|
if (xOffset || yOffset) {
|
|
7173
7983
|
const { width, height } = await browser.getElementRect(this.elementId);
|
|
7174
7984
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
7175
|
-
|
|
7985
|
+
log26.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
7176
7986
|
}
|
|
7177
7987
|
if (yOffset && yOffset < -Math.floor(height / 2) || yOffset && yOffset > Math.floor(height / 2)) {
|
|
7178
|
-
|
|
7988
|
+
log26.warn("yOffset would cause a out of bounds error as it goes outside of element");
|
|
7179
7989
|
}
|
|
7180
7990
|
}
|
|
7181
7991
|
const moveToNested = async () => {
|
|
@@ -7261,10 +8071,10 @@ async function saveScreenshot3(filepath) {
|
|
|
7261
8071
|
}
|
|
7262
8072
|
|
|
7263
8073
|
// src/commands/element/scrollIntoView.ts
|
|
7264
|
-
import
|
|
8074
|
+
import logger27 from "@wdio/logger";
|
|
7265
8075
|
import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
|
|
7266
8076
|
import { getBrowserObject as getBrowserObject30 } from "@wdio/utils";
|
|
7267
|
-
var
|
|
8077
|
+
var log27 = logger27("webdriverio");
|
|
7268
8078
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
7269
8079
|
const browser = getBrowserObject30(this);
|
|
7270
8080
|
if (browser.isMobile) {
|
|
@@ -7317,7 +8127,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
7317
8127
|
deltaY = Math.round(deltaY - scrollY);
|
|
7318
8128
|
await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
7319
8129
|
} catch (err) {
|
|
7320
|
-
|
|
8130
|
+
log27.warn(
|
|
7321
8131
|
`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!
|
|
7322
8132
|
Re-attempting using \`Element.scrollIntoView\` via Web API.`
|
|
7323
8133
|
);
|
|
@@ -7476,7 +8286,7 @@ async function setValue(value, options) {
|
|
|
7476
8286
|
}
|
|
7477
8287
|
|
|
7478
8288
|
// src/commands/element/shadow$$.ts
|
|
7479
|
-
import
|
|
8289
|
+
import logger28 from "@wdio/logger";
|
|
7480
8290
|
import { getBrowserObject as getBrowserObject31 } from "@wdio/utils";
|
|
7481
8291
|
import { SHADOW_ELEMENT_KEY } from "webdriver";
|
|
7482
8292
|
import { shadowFnFactory } from "./scripts/shadowFnFactory.js";
|
|
@@ -7803,7 +8613,7 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
7803
8613
|
};
|
|
7804
8614
|
|
|
7805
8615
|
// src/commands/element/shadow$$.ts
|
|
7806
|
-
var
|
|
8616
|
+
var log28 = logger28("webdriverio");
|
|
7807
8617
|
async function shadow$$(selector) {
|
|
7808
8618
|
const browser = getBrowserObject31(this);
|
|
7809
8619
|
try {
|
|
@@ -7813,7 +8623,7 @@ async function shadow$$(selector) {
|
|
|
7813
8623
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
7814
8624
|
return enhanceElementsArray(elements, this, selector);
|
|
7815
8625
|
} catch (err) {
|
|
7816
|
-
|
|
8626
|
+
log28.warn(
|
|
7817
8627
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
7818
8628
|
Falling back to JavaScript shim.`
|
|
7819
8629
|
);
|
|
@@ -7822,11 +8632,11 @@ Falling back to JavaScript shim.`
|
|
|
7822
8632
|
}
|
|
7823
8633
|
|
|
7824
8634
|
// src/commands/element/shadow$.ts
|
|
7825
|
-
import
|
|
8635
|
+
import logger29 from "@wdio/logger";
|
|
7826
8636
|
import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
|
|
7827
8637
|
import { shadowFnFactory as shadowFnFactory2 } from "./scripts/shadowFnFactory.js";
|
|
7828
8638
|
import { getBrowserObject as getBrowserObject32 } from "@wdio/utils";
|
|
7829
|
-
var
|
|
8639
|
+
var log29 = logger29("webdriverio");
|
|
7830
8640
|
async function shadow$(selector) {
|
|
7831
8641
|
const browser = getBrowserObject32(this);
|
|
7832
8642
|
try {
|
|
@@ -7835,7 +8645,7 @@ async function shadow$(selector) {
|
|
|
7835
8645
|
const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
7836
8646
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
7837
8647
|
} catch (err) {
|
|
7838
|
-
|
|
8648
|
+
log29.warn(
|
|
7839
8649
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
7840
8650
|
Falling back to JavaScript shim.`
|
|
7841
8651
|
);
|
|
@@ -8254,7 +9064,7 @@ function querySelectorAllDeep(findMany, s, r) {
|
|
|
8254
9064
|
}
|
|
8255
9065
|
|
|
8256
9066
|
// src/utils/index.ts
|
|
8257
|
-
var
|
|
9067
|
+
var log30 = logger30("webdriverio");
|
|
8258
9068
|
var INVALID_SELECTOR_ERROR = "selector needs to be typeof `string` or `function`";
|
|
8259
9069
|
var IGNORED_COMMAND_FILE_EXPORTS = ["SESSION_MOCKS", "CDP_SESSIONS"];
|
|
8260
9070
|
var scopes = {
|
|
@@ -8426,7 +9236,7 @@ async function findDeepElement(selector) {
|
|
|
8426
9236
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8427
9237
|
return scopedNodes[0];
|
|
8428
9238
|
}, (err) => {
|
|
8429
|
-
|
|
9239
|
+
log30.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
8430
9240
|
return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) : browser.findElement(using, value);
|
|
8431
9241
|
});
|
|
8432
9242
|
return deepElementResult;
|
|
@@ -8465,7 +9275,7 @@ async function findDeepElements(selector) {
|
|
|
8465
9275
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8466
9276
|
return scopedNodes;
|
|
8467
9277
|
}, (err) => {
|
|
8468
|
-
|
|
9278
|
+
log30.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
8469
9279
|
return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) : browser.findElements(using, value);
|
|
8470
9280
|
});
|
|
8471
9281
|
return deepElementResult;
|
|
@@ -8599,7 +9409,7 @@ async function getElementRect(scope) {
|
|
|
8599
9409
|
if (rectJs && typeof rectJs[key] === "number") {
|
|
8600
9410
|
rect[key] = Math.floor(rectJs[key]);
|
|
8601
9411
|
} else {
|
|
8602
|
-
|
|
9412
|
+
log30.error("getElementRect", { rect, rectJs, key });
|
|
8603
9413
|
throw new Error("Failed to receive element rects via execute command");
|
|
8604
9414
|
}
|
|
8605
9415
|
});
|
|
@@ -9043,7 +9853,7 @@ var remote = async function(params, remoteModifier) {
|
|
|
9043
9853
|
const keysToKeep = Object.keys(environment.value.variables.WDIO_WORKER_ID ? params : DEFAULTS);
|
|
9044
9854
|
const config = validateConfig(WDIO_DEFAULTS, params, keysToKeep);
|
|
9045
9855
|
await enableFileLogging(config.outputDir);
|
|
9046
|
-
|
|
9856
|
+
logger31.setLogLevelsConfig(config.logLevels, config.logLevel);
|
|
9047
9857
|
const modifier = (client, options2) => {
|
|
9048
9858
|
Object.assign(options2, Object.entries(config).reduce((a, [k, v]) => typeof v === "undefined" ? a : { ...a, [k]: v }, {}));
|
|
9049
9859
|
if (typeof remoteModifier === "function") {
|