spana-test 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -12
- package/dist/accessibility-audit-RS3VIWRT.js +140 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +1 -0
- package/dist/agent/index.d.ts +8 -26
- package/dist/agent/index.js +12 -15
- package/dist/{allure-PTTVORQ6.js → allure-RNMEYTXS.js} +42 -2
- package/dist/allure-RNMEYTXS.js.map +1 -0
- package/dist/{android-PAPJJWVN.js → android-GFW6OXPQ.js} +16 -2
- package/dist/appium-server-66GVUL24.js +119 -0
- package/dist/appium-server-66GVUL24.js.map +1 -0
- package/dist/baseline-manager-5TIUCNP5.js +38 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +1 -0
- package/dist/chunk-3J4NG7JU.js +80 -0
- package/dist/chunk-3J4NG7JU.js.map +1 -0
- package/dist/{chunk-MRH7SK52.js → chunk-3TRMQCUT.js} +3 -2
- package/dist/chunk-3TRMQCUT.js.map +1 -0
- package/dist/chunk-5245YBLL.js +127 -0
- package/dist/chunk-5245YBLL.js.map +1 -0
- package/dist/{chunk-L7MFJF46.js → chunk-7VOWF42B.js} +29 -5
- package/dist/chunk-7VOWF42B.js.map +1 -0
- package/dist/{chunk-GZK22EIE.js → chunk-EWIR2GVV.js} +54 -1
- package/dist/chunk-EWIR2GVV.js.map +1 -0
- package/dist/{chunk-P7JQRLP4.js → chunk-FJAJ4YNC.js} +14 -2
- package/dist/chunk-FJAJ4YNC.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +24 -0
- package/dist/chunk-IHVZKQQW.js.map +1 -0
- package/dist/{chunk-S4R4OR7T.js → chunk-KYPLYRKW.js} +67 -72
- package/dist/chunk-KYPLYRKW.js.map +1 -0
- package/dist/{chunk-YBZCOQXJ.js → chunk-LC3QJIHY.js} +196 -67
- package/dist/chunk-LC3QJIHY.js.map +1 -0
- package/dist/{chunk-WQ4GXUUE.js → chunk-MCT4DYDK.js} +353 -84
- package/dist/chunk-MCT4DYDK.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +28 -0
- package/dist/chunk-OBCFACUW.js.map +1 -0
- package/dist/{chunk-AEKDFFPJ.js → chunk-PZYZ4O6D.js} +16 -5
- package/dist/chunk-PZYZ4O6D.js.map +1 -0
- package/dist/{chunk-SFBRFB2N.js → chunk-S5JNNDXS.js} +62 -12
- package/dist/chunk-S5JNNDXS.js.map +1 -0
- package/dist/{chunk-VNYF5BHX.js → chunk-X2TJP7LB.js} +1 -3
- package/dist/{chunk-S2XNAKSO.js → chunk-YAV6KBSW.js} +564 -333
- package/dist/chunk-YAV6KBSW.js.map +1 -0
- package/dist/{chunk-3YR4GUGE.js → chunk-YGHDMA6D.js} +65 -70
- package/dist/chunk-YGHDMA6D.js.map +1 -0
- package/dist/cli.js +40 -25
- package/dist/cli.js.map +1 -1
- package/dist/{compiler-74VGKZO6.js → compiler-X6WTFMYF.js} +15 -7
- package/dist/compiler-X6WTFMYF.js.map +1 -0
- package/dist/config-loader-QM72GKEL.js +9 -0
- package/dist/{console-XWKUTP3D.js → console-7UW7VROK.js} +71 -1
- package/dist/console-7UW7VROK.js.map +1 -0
- package/dist/{discover-KZKXHZZA.js → discover-CAQY6EG6.js} +5 -4
- package/dist/doctor-command-YGQPO7GH.js +71 -0
- package/dist/doctor-command-YGQPO7GH.js.map +1 -0
- package/dist/flow-thjUxXXx.d.ts +168 -0
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-GE6Q4DCG.js → html-F3X3XPSX.js} +78 -7
- package/dist/html-F3X3XPSX.js.map +1 -0
- package/dist/index.d.ts +4 -8
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{init-command-GVMRXIMY.js → init-command-U66XCM66.js} +19 -34
- package/dist/init-command-U66XCM66.js.map +1 -0
- package/dist/init-flow-command-PR7J5FBM.js +37 -0
- package/dist/init-flow-command-PR7J5FBM.js.map +1 -0
- package/dist/{installer-YZJ4DV3F.js → installer-PVBSX7UC.js} +3 -4
- package/dist/{ios-ZW6XVNLG.js → ios-JPK43TFZ.js} +11 -4
- package/dist/json-JMRPUVY2.js +20 -0
- package/dist/json-JMRPUVY2.js.map +1 -0
- package/dist/machine-6H25TRTU.js +16 -0
- package/dist/{provider-A57C3MU6.js → provider-YIPU5K42.js} +2 -2
- package/dist/{runner-UXNHVVGG.js → runner-6HK62Q7B.js} +2 -2
- package/dist/screenshot-compare-JFHH2WR4.js +75 -0
- package/dist/screenshot-compare-JFHH2WR4.js.map +1 -0
- package/dist/{server-W7OA3DDN.js → server-PZBRGU7P.js} +362 -55
- package/dist/server-PZBRGU7P.js.map +1 -0
- package/dist/session-2MZVGYAC.js +17 -0
- package/dist/{coordinator-BbUjvvnX.d.ts → storybook-pBOPe_1D.d.ts} +101 -33
- package/dist/{studio-command-6VHTHDUK.js → studio-command-YDWQOMRX.js} +2 -2
- package/dist/{test-command-AHMOZLV4.js → test-command-B2VLWGDK.js} +945 -565
- package/dist/test-command-B2VLWGDK.js.map +1 -0
- package/dist/{validator-35624P7S.js → validator-HZ2A3NEI.js} +3 -6
- package/dist/validator-HZ2A3NEI.js.map +1 -0
- package/package.json +6 -1
- package/studio-dist/assets/index-C-Io44gy.js +193 -0
- package/studio-dist/assets/index-DfM9lK4p.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/allure-PTTVORQ6.js.map +0 -1
- package/dist/chunk-3YR4GUGE.js.map +0 -1
- package/dist/chunk-AEKDFFPJ.js.map +0 -1
- package/dist/chunk-BF37W5EG.js +0 -125
- package/dist/chunk-BF37W5EG.js.map +0 -1
- package/dist/chunk-EXLUY7KT.js +0 -21
- package/dist/chunk-EXLUY7KT.js.map +0 -1
- package/dist/chunk-FNDOEMOL.js +0 -62
- package/dist/chunk-FNDOEMOL.js.map +0 -1
- package/dist/chunk-GZK22EIE.js.map +0 -1
- package/dist/chunk-HWFDXIXR.js +0 -183
- package/dist/chunk-HWFDXIXR.js.map +0 -1
- package/dist/chunk-IJIASIX5.js +0 -314
- package/dist/chunk-IJIASIX5.js.map +0 -1
- package/dist/chunk-L7MFJF46.js.map +0 -1
- package/dist/chunk-MRH7SK52.js.map +0 -1
- package/dist/chunk-P7JQRLP4.js.map +0 -1
- package/dist/chunk-S2XNAKSO.js.map +0 -1
- package/dist/chunk-S4R4OR7T.js.map +0 -1
- package/dist/chunk-SFBRFB2N.js.map +0 -1
- package/dist/chunk-WBU34APM.js +0 -38
- package/dist/chunk-WBU34APM.js.map +0 -1
- package/dist/chunk-WQ4GXUUE.js.map +0 -1
- package/dist/chunk-YBZCOQXJ.js.map +0 -1
- package/dist/compiler-74VGKZO6.js.map +0 -1
- package/dist/config-loader-BJJ3IJJ7.js +0 -9
- package/dist/console-XWKUTP3D.js.map +0 -1
- package/dist/doctor-command-T2UX5RV5.js +0 -732
- package/dist/doctor-command-T2UX5RV5.js.map +0 -1
- package/dist/flow-BUC9Mf8W.d.ts +0 -128
- package/dist/html-GE6Q4DCG.js.map +0 -1
- package/dist/init-command-GVMRXIMY.js.map +0 -1
- package/dist/init-flow-command-R76AXF4Z.js +0 -34
- package/dist/init-flow-command-R76AXF4Z.js.map +0 -1
- package/dist/json-KS67BZYU.js +0 -39
- package/dist/json-KS67BZYU.js.map +0 -1
- package/dist/server-W7OA3DDN.js.map +0 -1
- package/dist/session-TMNOKYLG.js +0 -17
- package/dist/test-command-AHMOZLV4.js.map +0 -1
- package/studio-dist/assets/index-DC6DIXfl.js +0 -188
- package/studio-dist/assets/index-DDKsnBwD.css +0 -1
- /package/dist/{android-PAPJJWVN.js.map → android-GFW6OXPQ.js.map} +0 -0
- /package/dist/{chunk-VNYF5BHX.js.map → chunk-X2TJP7LB.js.map} +0 -0
- /package/dist/{config-loader-BJJ3IJJ7.js.map → config-loader-QM72GKEL.js.map} +0 -0
- /package/dist/{discover-KZKXHZZA.js.map → discover-CAQY6EG6.js.map} +0 -0
- /package/dist/{installer-YZJ4DV3F.js.map → installer-PVBSX7UC.js.map} +0 -0
- /package/dist/{ios-ZW6XVNLG.js.map → ios-JPK43TFZ.js.map} +0 -0
- /package/dist/{provider-A57C3MU6.js.map → machine-6H25TRTU.js.map} +0 -0
- /package/dist/{runner-UXNHVVGG.js.map → provider-YIPU5K42.js.map} +0 -0
- /package/dist/{session-TMNOKYLG.js.map → runner-6HK62Q7B.js.map} +0 -0
- /package/dist/{validator-35624P7S.js.map → session-2MZVGYAC.js.map} +0 -0
- /package/dist/{studio-command-6VHTHDUK.js.map → studio-command-YDWQOMRX.js.map} +0 -0
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DriverError,
|
|
3
|
-
splitGraphemes
|
|
4
|
-
} from "./chunk-S2XNAKSO.js";
|
|
5
1
|
import {
|
|
6
2
|
adbClearApp,
|
|
7
3
|
adbForceStop,
|
|
4
|
+
adbForward,
|
|
5
|
+
adbInstall,
|
|
8
6
|
adbLaunchApp,
|
|
9
|
-
adbOpenLink
|
|
10
|
-
|
|
7
|
+
adbOpenLink,
|
|
8
|
+
adbResetNetwork,
|
|
9
|
+
adbSetAirplaneMode,
|
|
10
|
+
adbSetCustomNetwork,
|
|
11
|
+
adbSetData,
|
|
12
|
+
adbSetNetworkProfile,
|
|
13
|
+
adbSetWifi,
|
|
14
|
+
adbShell,
|
|
15
|
+
findADB
|
|
16
|
+
} from "./chunk-EWIR2GVV.js";
|
|
11
17
|
import {
|
|
12
18
|
installedUrlSchemesOnSimulator,
|
|
13
19
|
launchOnSimulator,
|
|
14
20
|
launchWithUrlOnSimulator,
|
|
21
|
+
pfctlResetNetwork,
|
|
22
|
+
pfctlSetOffline,
|
|
23
|
+
pfctlSetThrottle,
|
|
15
24
|
resetSimulatorKeychain,
|
|
16
25
|
terminateOnSimulator
|
|
17
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-S5JNNDXS.js";
|
|
27
|
+
import {
|
|
28
|
+
allocatePort,
|
|
29
|
+
releasePort
|
|
30
|
+
} from "./chunk-OBCFACUW.js";
|
|
31
|
+
import {
|
|
32
|
+
DriverError,
|
|
33
|
+
hasLaunchDeviceState,
|
|
34
|
+
splitGraphemes
|
|
35
|
+
} from "./chunk-YAV6KBSW.js";
|
|
18
36
|
|
|
19
37
|
// src/drivers/playwright.ts
|
|
20
38
|
import { readFile, writeFile } from "fs/promises";
|
|
@@ -24,6 +42,29 @@ import {
|
|
|
24
42
|
firefox,
|
|
25
43
|
webkit
|
|
26
44
|
} from "playwright-core";
|
|
45
|
+
|
|
46
|
+
// src/drivers/network-profiles.ts
|
|
47
|
+
var PROFILES = {
|
|
48
|
+
wifi: { offline: false, latencyMs: 2, downloadThroughputKbps: 3e4, uploadThroughputKbps: 15e3 },
|
|
49
|
+
"4g": { offline: false, latencyMs: 20, downloadThroughputKbps: 2e4, uploadThroughputKbps: 1e4 },
|
|
50
|
+
"3g": { offline: false, latencyMs: 100, downloadThroughputKbps: 1500, uploadThroughputKbps: 750 },
|
|
51
|
+
"2g": { offline: false, latencyMs: 300, downloadThroughputKbps: 280, uploadThroughputKbps: 256 },
|
|
52
|
+
edge: { offline: false, latencyMs: 400, downloadThroughputKbps: 240, uploadThroughputKbps: 200 },
|
|
53
|
+
offline: { offline: true, latencyMs: 0, downloadThroughputKbps: 0, uploadThroughputKbps: 0 }
|
|
54
|
+
};
|
|
55
|
+
function resolveNetworkConditions(conditions) {
|
|
56
|
+
if (conditions.profile) {
|
|
57
|
+
return { ...PROFILES[conditions.profile] };
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
offline: conditions.offline ?? false,
|
|
61
|
+
latencyMs: conditions.latencyMs ?? 0,
|
|
62
|
+
downloadThroughputKbps: conditions.downloadThroughputKbps ?? -1,
|
|
63
|
+
uploadThroughputKbps: conditions.uploadThroughputKbps ?? -1
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/drivers/playwright.ts
|
|
27
68
|
var browserLaunchers = {
|
|
28
69
|
chromium,
|
|
29
70
|
firefox,
|
|
@@ -67,14 +108,11 @@ function buildMockResponse(response) {
|
|
|
67
108
|
};
|
|
68
109
|
}
|
|
69
110
|
function toBytesPerSecond(kbps) {
|
|
70
|
-
if (kbps
|
|
111
|
+
if (kbps < 0) {
|
|
71
112
|
return -1;
|
|
72
113
|
}
|
|
73
114
|
return Math.max(Math.round(kbps * 1024 / 8), 0);
|
|
74
115
|
}
|
|
75
|
-
function requiresChromiumThrottling(conditions) {
|
|
76
|
-
return conditions.latencyMs !== void 0 || conditions.downloadThroughputKbps !== void 0 || conditions.uploadThroughputKbps !== void 0;
|
|
77
|
-
}
|
|
78
116
|
function currentPageUrl(page) {
|
|
79
117
|
try {
|
|
80
118
|
return page.url();
|
|
@@ -173,8 +211,8 @@ function makePlaywrightDriver(config) {
|
|
|
173
211
|
if (queued) {
|
|
174
212
|
return Promise.resolve(queued);
|
|
175
213
|
}
|
|
176
|
-
return new Promise((
|
|
177
|
-
downloadWaiters.push({ resolve, reject });
|
|
214
|
+
return new Promise((resolve2, reject) => {
|
|
215
|
+
downloadWaiters.push({ resolve: resolve2, reject });
|
|
178
216
|
});
|
|
179
217
|
};
|
|
180
218
|
const defaultSizes = {
|
|
@@ -351,23 +389,25 @@ function makePlaywrightDriver(config) {
|
|
|
351
389
|
await page.evaluate(CLEAR_STORAGE_SCRIPT);
|
|
352
390
|
};
|
|
353
391
|
const applyNetworkConditions = async () => {
|
|
354
|
-
|
|
392
|
+
const resolved = resolveNetworkConditions(currentNetworkConditions);
|
|
393
|
+
const needsThrottling = resolved.latencyMs > 0 || resolved.downloadThroughputKbps >= 0 || resolved.uploadThroughputKbps >= 0;
|
|
394
|
+
if (browserName !== "chromium" && needsThrottling) {
|
|
355
395
|
throw new DriverError({
|
|
356
396
|
message: "setNetworkConditions() latency and throughput controls are only supported with the chromium browser. Use offline mode only for firefox or webkit."
|
|
357
397
|
});
|
|
358
398
|
}
|
|
359
|
-
await context.setOffline(
|
|
360
|
-
const shouldUseCDP = browserName === "chromium" && (
|
|
399
|
+
await context.setOffline(resolved.offline);
|
|
400
|
+
const shouldUseCDP = browserName === "chromium" && (needsThrottling || cdpSession !== void 0);
|
|
361
401
|
if (!shouldUseCDP) {
|
|
362
402
|
return;
|
|
363
403
|
}
|
|
364
404
|
const session = cdpSession ?? (cdpSession = await context.newCDPSession(page));
|
|
365
405
|
await session.send("Network.enable");
|
|
366
406
|
await session.send("Network.emulateNetworkConditions", {
|
|
367
|
-
offline:
|
|
368
|
-
latency:
|
|
369
|
-
downloadThroughput: toBytesPerSecond(
|
|
370
|
-
uploadThroughput: toBytesPerSecond(
|
|
407
|
+
offline: resolved.offline,
|
|
408
|
+
latency: resolved.latencyMs,
|
|
409
|
+
downloadThroughput: toBytesPerSecond(resolved.downloadThroughputKbps),
|
|
410
|
+
uploadThroughput: toBytesPerSecond(resolved.uploadThroughputKbps)
|
|
371
411
|
});
|
|
372
412
|
};
|
|
373
413
|
const applyRouteDefinition = async (definition) => {
|
|
@@ -482,7 +522,10 @@ function makePlaywrightDriver(config) {
|
|
|
482
522
|
function walk(el) {
|
|
483
523
|
var rect = el.getBoundingClientRect();
|
|
484
524
|
var style = window.getComputedStyle(el);
|
|
525
|
+
var viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
526
|
+
var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
485
527
|
var isVisible = style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
528
|
+
var intersectsViewport = rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
486
529
|
return {
|
|
487
530
|
tag: el.tagName.toLowerCase(),
|
|
488
531
|
id: el.getAttribute("data-testid") || el.getAttribute("testID") || undefined,
|
|
@@ -494,7 +537,7 @@ function makePlaywrightDriver(config) {
|
|
|
494
537
|
role: el.getAttribute("role") || undefined,
|
|
495
538
|
bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
496
539
|
enabled: !el.hasAttribute("disabled"),
|
|
497
|
-
visible: isVisible && rect.width > 0 && rect.height > 0,
|
|
540
|
+
visible: isVisible && rect.width > 0 && rect.height > 0 && intersectsViewport,
|
|
498
541
|
clickable: el.tagName === "BUTTON" || el.tagName === "A" || el.tagName === "INPUT" || el.tagName === "SELECT" || el.tagName === "TEXTAREA" || el.getAttribute("role") === "button" || el.onclick !== null,
|
|
499
542
|
attributes: (function() { var a = {}; for (var i = 0; i < el.attributes.length; i++) { var attr = el.attributes[i]; a[attr.name] = attr.value; } return Object.keys(a).length > 0 ? a : undefined; })(),
|
|
500
543
|
children: Array.from(el.children).map(walk),
|
|
@@ -511,12 +554,18 @@ function makePlaywrightDriver(config) {
|
|
|
511
554
|
try: async () => {
|
|
512
555
|
await page.mouse.click(x, y);
|
|
513
556
|
await page.evaluate(`
|
|
514
|
-
(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
el.
|
|
557
|
+
new Promise(resolve => {
|
|
558
|
+
function tryFocus() {
|
|
559
|
+
var el = document.elementFromPoint(${x}, ${y});
|
|
560
|
+
if (el && (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT")) {
|
|
561
|
+
el.focus();
|
|
562
|
+
}
|
|
518
563
|
}
|
|
519
|
-
|
|
564
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
565
|
+
tryFocus();
|
|
566
|
+
setTimeout(() => { tryFocus(); resolve(); }, 16);
|
|
567
|
+
}));
|
|
568
|
+
})
|
|
520
569
|
`);
|
|
521
570
|
},
|
|
522
571
|
catch: (e) => new DriverError({ message: `Failed to tap at (${x}, ${y}): ${e}` })
|
|
@@ -536,14 +585,38 @@ function makePlaywrightDriver(config) {
|
|
|
536
585
|
}),
|
|
537
586
|
swipe: (startX, startY, endX, endY, duration) => Effect.tryPromise({
|
|
538
587
|
try: async () => {
|
|
539
|
-
await page.
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
588
|
+
await page.evaluate(`
|
|
589
|
+
(function() {
|
|
590
|
+
function isScrollable(el) {
|
|
591
|
+
if (!el) return false;
|
|
592
|
+
var style = window.getComputedStyle(el);
|
|
593
|
+
var canScrollY = /(auto|scroll)/.test(style.overflowY) && el.scrollHeight > el.clientHeight;
|
|
594
|
+
var canScrollX = /(auto|scroll)/.test(style.overflowX) && el.scrollWidth > el.clientWidth;
|
|
595
|
+
return canScrollY || canScrollX;
|
|
596
|
+
}
|
|
597
|
+
function findScrollable(el) {
|
|
598
|
+
var current = el;
|
|
599
|
+
while (current && current !== document.body) {
|
|
600
|
+
if (isScrollable(current)) return current;
|
|
601
|
+
current = current.parentElement;
|
|
602
|
+
}
|
|
603
|
+
return document.scrollingElement || document.documentElement || document.body;
|
|
604
|
+
}
|
|
605
|
+
var target = document.elementFromPoint(${startX}, ${startY});
|
|
606
|
+
var scroller = findScrollable(target);
|
|
607
|
+
var left = ${startX - endX};
|
|
608
|
+
var top = ${startY - endY};
|
|
609
|
+
if (scroller && typeof scroller.scrollBy === "function") {
|
|
610
|
+
scroller.scrollBy({ left: left, top: top, behavior: "auto" });
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (scroller) {
|
|
614
|
+
scroller.scrollLeft += left;
|
|
615
|
+
scroller.scrollTop += top;
|
|
616
|
+
}
|
|
617
|
+
})()
|
|
618
|
+
`);
|
|
619
|
+
await new Promise((resolve2) => setTimeout(resolve2, duration));
|
|
547
620
|
},
|
|
548
621
|
catch: (e) => new DriverError({ message: `Failed to swipe: ${e}` })
|
|
549
622
|
}),
|
|
@@ -584,6 +657,11 @@ function makePlaywrightDriver(config) {
|
|
|
584
657
|
if (opts?.clearState) {
|
|
585
658
|
await clearStorage();
|
|
586
659
|
}
|
|
660
|
+
if (hasLaunchDeviceState(opts?.deviceState)) {
|
|
661
|
+
console.warn(
|
|
662
|
+
"deviceState launch overrides are ignored in web mode. Use browser-specific emulation when execution.web adds that support."
|
|
663
|
+
);
|
|
664
|
+
}
|
|
587
665
|
await page.goto(targetUrl);
|
|
588
666
|
updateHarPage(page);
|
|
589
667
|
debugLog("launchApp", targetUrl);
|
|
@@ -1242,15 +1320,20 @@ function createUiAutomator2Driver(host, port, serial, packageName) {
|
|
|
1242
1320
|
if (opts?.clearKeychain) {
|
|
1243
1321
|
console.warn("clearKeychain is not supported on Android, skipping.");
|
|
1244
1322
|
}
|
|
1323
|
+
if (hasLaunchDeviceState(opts?.deviceState)) {
|
|
1324
|
+
console.warn(
|
|
1325
|
+
"deviceState launch overrides are not supported in local Android mode yet. Use Appium Android mode for language/locale/timeZone session defaults."
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1245
1328
|
if (opts?.deepLink) {
|
|
1246
1329
|
adbOpenLink(serial, opts.deepLink, bundleId);
|
|
1247
|
-
await new Promise((
|
|
1330
|
+
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
1248
1331
|
} else {
|
|
1249
1332
|
adbForceStop(serial, bundleId);
|
|
1250
1333
|
if (opts?.launchArguments && Object.keys(opts.launchArguments).length > 0) {
|
|
1251
1334
|
const { execFileSync } = await import("child_process");
|
|
1252
|
-
const { findADB } = await import("./android-
|
|
1253
|
-
const adb =
|
|
1335
|
+
const { findADB: findADB2 } = await import("./android-GFW6OXPQ.js");
|
|
1336
|
+
const adb = findADB2();
|
|
1254
1337
|
if (!adb) throw new Error("adb not found");
|
|
1255
1338
|
const startArgs = [
|
|
1256
1339
|
"-s",
|
|
@@ -1272,7 +1355,7 @@ function createUiAutomator2Driver(host, port, serial, packageName) {
|
|
|
1272
1355
|
adbLaunchApp(serial, bundleId);
|
|
1273
1356
|
}
|
|
1274
1357
|
}
|
|
1275
|
-
await new Promise((
|
|
1358
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
1276
1359
|
},
|
|
1277
1360
|
catch: (e) => new DriverError({ message: `Launch app failed: ${e}` })
|
|
1278
1361
|
}),
|
|
@@ -1301,7 +1384,7 @@ function createUiAutomator2Driver(host, port, serial, packageName) {
|
|
|
1301
1384
|
openLink: (url) => Effect2.tryPromise({
|
|
1302
1385
|
try: async () => {
|
|
1303
1386
|
adbOpenLink(serial, url, packageName);
|
|
1304
|
-
await new Promise((
|
|
1387
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
1305
1388
|
},
|
|
1306
1389
|
catch: (e) => new DriverError({ message: `Open link failed: ${e}` })
|
|
1307
1390
|
}),
|
|
@@ -1328,6 +1411,56 @@ function createUiAutomator2Driver(host, port, serial, packageName) {
|
|
|
1328
1411
|
setContext: (contextId) => Effect2.tryPromise({
|
|
1329
1412
|
try: () => client.setContext(contextId),
|
|
1330
1413
|
catch: (e) => new DriverError({ message: `setContext failed: ${e}` })
|
|
1414
|
+
}),
|
|
1415
|
+
// -----------------------------------------------------------------------
|
|
1416
|
+
// Network conditions
|
|
1417
|
+
// -----------------------------------------------------------------------
|
|
1418
|
+
setNetworkConditions: (conditions) => Effect2.tryPromise({
|
|
1419
|
+
try: async () => {
|
|
1420
|
+
const isEmulator = serial.startsWith("emulator-");
|
|
1421
|
+
const resolved = resolveNetworkConditions(conditions);
|
|
1422
|
+
const hasThrottling = conditions.profile !== void 0 || conditions.latencyMs !== void 0 || conditions.downloadThroughputKbps !== void 0 || conditions.uploadThroughputKbps !== void 0;
|
|
1423
|
+
if (!resolved.offline && !hasThrottling) {
|
|
1424
|
+
if (isEmulator) {
|
|
1425
|
+
adbResetNetwork(serial);
|
|
1426
|
+
} else {
|
|
1427
|
+
adbSetAirplaneMode(serial, false);
|
|
1428
|
+
}
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (resolved.offline) {
|
|
1432
|
+
if (isEmulator) {
|
|
1433
|
+
adbSetWifi(serial, false);
|
|
1434
|
+
adbSetData(serial, false);
|
|
1435
|
+
} else {
|
|
1436
|
+
adbSetAirplaneMode(serial, true);
|
|
1437
|
+
}
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
if (hasThrottling) {
|
|
1441
|
+
if (!isEmulator) {
|
|
1442
|
+
throw new DriverError({
|
|
1443
|
+
message: "Network throttling is not supported on physical Android devices. Use an emulator or a cloud provider."
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
adbSetWifi(serial, true);
|
|
1447
|
+
adbSetData(serial, true);
|
|
1448
|
+
if (conditions.profile) {
|
|
1449
|
+
adbSetNetworkProfile(serial, conditions.profile);
|
|
1450
|
+
} else {
|
|
1451
|
+
adbSetCustomNetwork(
|
|
1452
|
+
serial,
|
|
1453
|
+
resolved.downloadThroughputKbps,
|
|
1454
|
+
resolved.uploadThroughputKbps,
|
|
1455
|
+
resolved.latencyMs
|
|
1456
|
+
);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
},
|
|
1460
|
+
catch: (e) => {
|
|
1461
|
+
if (e instanceof DriverError) return e;
|
|
1462
|
+
return new DriverError({ message: `setNetworkConditions failed: ${e}` });
|
|
1463
|
+
}
|
|
1331
1464
|
})
|
|
1332
1465
|
};
|
|
1333
1466
|
return service;
|
|
@@ -1456,6 +1589,13 @@ var WDAClient = class {
|
|
|
1456
1589
|
waitForIdleTimeout: 0
|
|
1457
1590
|
});
|
|
1458
1591
|
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Sets the maximum depth for UI hierarchy snapshots.
|
|
1594
|
+
* Higher values (e.g. 100) are required for deeply nested React Native apps.
|
|
1595
|
+
*/
|
|
1596
|
+
async setSnapshotMaxDepth(depth) {
|
|
1597
|
+
await this.updateSettings({ snapshotMaxDepth: depth });
|
|
1598
|
+
}
|
|
1459
1599
|
// ---------------------------------------------------------------------------
|
|
1460
1600
|
// Screen queries
|
|
1461
1601
|
// ---------------------------------------------------------------------------
|
|
@@ -1504,7 +1644,7 @@ var WDAClient = class {
|
|
|
1504
1644
|
}
|
|
1505
1645
|
];
|
|
1506
1646
|
await this.request("POST", this.sessionPath("/actions"), { actions: singleTap });
|
|
1507
|
-
await new Promise((
|
|
1647
|
+
await new Promise((resolve2) => setTimeout(resolve2, 200));
|
|
1508
1648
|
await this.request("POST", this.sessionPath("/actions"), { actions: singleTap });
|
|
1509
1649
|
}
|
|
1510
1650
|
/**
|
|
@@ -1736,7 +1876,7 @@ function msToSec(ms) {
|
|
|
1736
1876
|
return ms / 1e3;
|
|
1737
1877
|
}
|
|
1738
1878
|
function sleep(ms) {
|
|
1739
|
-
return new Promise((
|
|
1879
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
1740
1880
|
}
|
|
1741
1881
|
function replaceUrlScheme(url, scheme) {
|
|
1742
1882
|
const match = url.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):(\/\/.*)$/);
|
|
@@ -1747,7 +1887,7 @@ function isSessionError(error) {
|
|
|
1747
1887
|
const msg = String(error).toLowerCase();
|
|
1748
1888
|
return msg.includes("session does not exist") || msg.includes("unable to connect") || msg.includes("no active session") || msg.includes("invalid session") || /status[:\s]*404/.test(msg);
|
|
1749
1889
|
}
|
|
1750
|
-
function createWDADriver(host, port, bundleId, simulatorUdid) {
|
|
1890
|
+
function createWDADriver(host, port, bundleId, simulatorUdid, snapshotMaxDepth = 100) {
|
|
1751
1891
|
return Effect3.gen(function* () {
|
|
1752
1892
|
const client = new WDAClient(host, port);
|
|
1753
1893
|
const createSessionWithRetry = async (targetBundleId) => {
|
|
@@ -1853,6 +1993,10 @@ function createWDADriver(host, port, bundleId, simulatorUdid) {
|
|
|
1853
1993
|
try: () => client.disableQuiescence(),
|
|
1854
1994
|
catch: (e) => new DriverError({ message: `Failed to disable quiescence: ${e}` })
|
|
1855
1995
|
});
|
|
1996
|
+
yield* Effect3.tryPromise({
|
|
1997
|
+
try: () => client.setSnapshotMaxDepth(snapshotMaxDepth),
|
|
1998
|
+
catch: (e) => new DriverError({ message: `Failed to set snapshot depth: ${e}` })
|
|
1999
|
+
});
|
|
1856
2000
|
const service = {
|
|
1857
2001
|
// -----------------------------------------------------------------------
|
|
1858
2002
|
// Hierarchy
|
|
@@ -1969,8 +2113,8 @@ function createWDADriver(host, port, bundleId, simulatorUdid) {
|
|
|
1969
2113
|
if (opts?.clearState && simulatorUdid) {
|
|
1970
2114
|
terminateOnSimulator(simulatorUdid, appBundleId);
|
|
1971
2115
|
try {
|
|
1972
|
-
const { execSync } = await import("child_process");
|
|
1973
|
-
|
|
2116
|
+
const { execSync: execSync2 } = await import("child_process");
|
|
2117
|
+
execSync2(`xcrun simctl privacy ${simulatorUdid} reset all ${appBundleId}`, {
|
|
1974
2118
|
stdio: "ignore"
|
|
1975
2119
|
});
|
|
1976
2120
|
} catch {
|
|
@@ -1981,6 +2125,11 @@ function createWDADriver(host, port, bundleId, simulatorUdid) {
|
|
|
1981
2125
|
} else if (opts?.clearKeychain) {
|
|
1982
2126
|
console.warn("clearKeychain is only supported on iOS simulators, skipping.");
|
|
1983
2127
|
}
|
|
2128
|
+
if (hasLaunchDeviceState(opts?.deviceState) || opts?.launchArguments && Object.keys(opts.launchArguments).length > 0) {
|
|
2129
|
+
console.warn(
|
|
2130
|
+
"launchArguments and deviceState are not supported in local iOS WDA mode yet. Use Appium iOS mode when you need launch-time localization, timezone, or custom process arguments."
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
1984
2133
|
if (simulatorUdid) {
|
|
1985
2134
|
if (opts?.deepLink) {
|
|
1986
2135
|
await openSimulatorUrl(opts.deepLink, appBundleId);
|
|
@@ -2081,40 +2230,50 @@ function createWDADriver(host, port, bundleId, simulatorUdid) {
|
|
|
2081
2230
|
new DriverError({
|
|
2082
2231
|
message: "WebView context switching requires Appium mode. Use --driver appium with an Appium server that supports XCUITest."
|
|
2083
2232
|
})
|
|
2084
|
-
)
|
|
2233
|
+
),
|
|
2234
|
+
// -----------------------------------------------------------------------
|
|
2235
|
+
// Network simulation
|
|
2236
|
+
// -----------------------------------------------------------------------
|
|
2237
|
+
setNetworkConditions: (conditions) => Effect3.tryPromise({
|
|
2238
|
+
try: async () => {
|
|
2239
|
+
if (!simulatorUdid) {
|
|
2240
|
+
throw new DriverError({
|
|
2241
|
+
message: "Network simulation is not supported on physical iOS devices. Use a cloud provider (BrowserStack, SauceLabs) for network profiles."
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
const hasProfile = !!conditions.profile;
|
|
2245
|
+
const hasOffline = conditions.offline !== void 0;
|
|
2246
|
+
const hasCustom = conditions.latencyMs !== void 0 || conditions.downloadThroughputKbps !== void 0 || conditions.uploadThroughputKbps !== void 0;
|
|
2247
|
+
if (!hasProfile && !hasOffline && !hasCustom) {
|
|
2248
|
+
pfctlResetNetwork();
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
if (hasOffline && conditions.offline) {
|
|
2252
|
+
pfctlSetOffline(true);
|
|
2253
|
+
return;
|
|
2254
|
+
}
|
|
2255
|
+
if (hasProfile || hasCustom) {
|
|
2256
|
+
const resolved = resolveNetworkConditions(conditions);
|
|
2257
|
+
if (resolved.offline) {
|
|
2258
|
+
pfctlSetOffline(true);
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
const throughput = resolved.downloadThroughputKbps === -1 ? 0 : resolved.downloadThroughputKbps;
|
|
2262
|
+
pfctlSetThrottle(throughput, resolved.latencyMs);
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
pfctlSetOffline(false);
|
|
2266
|
+
},
|
|
2267
|
+
catch: (e) => {
|
|
2268
|
+
if (e instanceof DriverError) return e;
|
|
2269
|
+
return new DriverError({ message: `Set network conditions failed: ${e}` });
|
|
2270
|
+
}
|
|
2271
|
+
})
|
|
2085
2272
|
};
|
|
2086
2273
|
return service;
|
|
2087
2274
|
});
|
|
2088
2275
|
}
|
|
2089
2276
|
|
|
2090
|
-
// src/drivers/playwright-parser.ts
|
|
2091
|
-
function rawNodeToElement(node) {
|
|
2092
|
-
const children = node.children && node.children.length > 0 ? node.children.map(rawNodeToElement) : void 0;
|
|
2093
|
-
return {
|
|
2094
|
-
...node.id !== void 0 ? { id: node.id } : {},
|
|
2095
|
-
...node.text !== void 0 ? { text: node.text } : {},
|
|
2096
|
-
...node.value !== void 0 ? { value: node.value } : {},
|
|
2097
|
-
...node.accessibilityLabel !== void 0 ? { accessibilityLabel: node.accessibilityLabel } : {},
|
|
2098
|
-
// Use role as elementType when present, otherwise fall back to HTML tag name
|
|
2099
|
-
...node.role !== void 0 ? { elementType: node.role } : node.tag !== void 0 ? { elementType: node.tag } : {},
|
|
2100
|
-
bounds: {
|
|
2101
|
-
x: node.bounds.x,
|
|
2102
|
-
y: node.bounds.y,
|
|
2103
|
-
width: node.bounds.width,
|
|
2104
|
-
height: node.bounds.height
|
|
2105
|
-
},
|
|
2106
|
-
...node.enabled !== void 0 ? { enabled: node.enabled } : {},
|
|
2107
|
-
...node.visible !== void 0 ? { visible: node.visible } : {},
|
|
2108
|
-
...node.clickable !== void 0 ? { clickable: node.clickable } : {},
|
|
2109
|
-
...node.attributes !== void 0 ? { attributes: node.attributes } : {},
|
|
2110
|
-
...children !== void 0 ? { children } : {}
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
2113
|
-
function parseWebHierarchy(json) {
|
|
2114
|
-
const raw = JSON.parse(json);
|
|
2115
|
-
return rawNodeToElement(raw);
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
2277
|
// src/drivers/common/xml-tokenizer.ts
|
|
2119
2278
|
function parseAttributes(tagContent) {
|
|
2120
2279
|
const attrs = {};
|
|
@@ -2258,7 +2417,7 @@ function prepareAndroidNode(node) {
|
|
|
2258
2417
|
prepareAndroidNode(child);
|
|
2259
2418
|
}
|
|
2260
2419
|
}
|
|
2261
|
-
function
|
|
2420
|
+
function rawNodeToElement(node) {
|
|
2262
2421
|
const a = node.attrs;
|
|
2263
2422
|
const rawId = a["resource-id"] ?? "";
|
|
2264
2423
|
const id = rawId ? stripResourceIdPrefix(rawId) : void 0;
|
|
@@ -2276,7 +2435,7 @@ function rawNodeToElement2(node) {
|
|
|
2276
2435
|
for (const [key, val] of Object.entries(a)) {
|
|
2277
2436
|
if (key !== "bounds") attributes[key] = val;
|
|
2278
2437
|
}
|
|
2279
|
-
const children = node.children.length > 0 ? node.children.map(
|
|
2438
|
+
const children = node.children.length > 0 ? node.children.map(rawNodeToElement) : void 0;
|
|
2280
2439
|
return {
|
|
2281
2440
|
...id !== void 0 ? { id } : {},
|
|
2282
2441
|
...text !== void 0 ? { text } : {},
|
|
@@ -2300,12 +2459,12 @@ function parseAndroidHierarchy(xml) {
|
|
|
2300
2459
|
throw new Error("parseAndroidHierarchy: no root elements found in hierarchy");
|
|
2301
2460
|
}
|
|
2302
2461
|
if (roots.length === 1) {
|
|
2303
|
-
return
|
|
2462
|
+
return rawNodeToElement(roots[0]);
|
|
2304
2463
|
}
|
|
2305
2464
|
return {
|
|
2306
2465
|
elementType: "hierarchy",
|
|
2307
2466
|
bounds: { x: 0, y: 0, width: 0, height: 0 },
|
|
2308
|
-
children: roots.map(
|
|
2467
|
+
children: roots.map(rawNodeToElement)
|
|
2309
2468
|
};
|
|
2310
2469
|
}
|
|
2311
2470
|
|
|
@@ -2336,7 +2495,7 @@ function prepareIOSNode(node) {
|
|
|
2336
2495
|
prepareIOSNode(child);
|
|
2337
2496
|
}
|
|
2338
2497
|
}
|
|
2339
|
-
function
|
|
2498
|
+
function rawNodeToElement2(node) {
|
|
2340
2499
|
const a = node.attrs;
|
|
2341
2500
|
const elementType = node.tagName || void 0;
|
|
2342
2501
|
const id = a["name"] || void 0;
|
|
@@ -2357,7 +2516,7 @@ function rawNodeToElement3(node) {
|
|
|
2357
2516
|
for (const [key, val] of Object.entries(a)) {
|
|
2358
2517
|
attributes[key] = val;
|
|
2359
2518
|
}
|
|
2360
|
-
const children = node.children.length > 0 ? node.children.map(
|
|
2519
|
+
const children = node.children.length > 0 ? node.children.map(rawNodeToElement2) : void 0;
|
|
2361
2520
|
return {
|
|
2362
2521
|
...id !== void 0 ? { id } : {},
|
|
2363
2522
|
...text !== void 0 ? { text } : {},
|
|
@@ -2382,21 +2541,131 @@ function parseIOSHierarchy(xml) {
|
|
|
2382
2541
|
throw new Error("parseIOSHierarchy: no elements found in page source");
|
|
2383
2542
|
}
|
|
2384
2543
|
if (roots.length === 1) {
|
|
2385
|
-
return
|
|
2544
|
+
return rawNodeToElement2(roots[0]);
|
|
2386
2545
|
}
|
|
2387
2546
|
return {
|
|
2388
2547
|
elementType: "AppiumAUT",
|
|
2389
2548
|
bounds: { x: 0, y: 0, width: 0, height: 0 },
|
|
2390
|
-
children: roots.map(
|
|
2549
|
+
children: roots.map(rawNodeToElement2)
|
|
2391
2550
|
};
|
|
2392
2551
|
}
|
|
2393
2552
|
|
|
2553
|
+
// src/drivers/uiautomator2/installer.ts
|
|
2554
|
+
import { execSync } from "child_process";
|
|
2555
|
+
import { existsSync, readdirSync } from "fs";
|
|
2556
|
+
import { createRequire } from "module";
|
|
2557
|
+
import { dirname, resolve, join } from "path";
|
|
2558
|
+
import { fileURLToPath } from "url";
|
|
2559
|
+
var __dirname2 = fileURLToPath(new URL(".", import.meta.url));
|
|
2560
|
+
var require2 = createRequire(import.meta.url);
|
|
2561
|
+
function resolveOptionalPackageDir(packageName, subpath) {
|
|
2562
|
+
try {
|
|
2563
|
+
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
2564
|
+
return resolve(dirname(packageJsonPath), subpath);
|
|
2565
|
+
} catch {
|
|
2566
|
+
return null;
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
function findUiAutomator2APK() {
|
|
2570
|
+
const appiumServerApks = resolveOptionalPackageDir("appium-uiautomator2-server", "apks");
|
|
2571
|
+
const projectDrivers = resolve(process.cwd(), "drivers/android");
|
|
2572
|
+
const provDrivers = resolve(__dirname2, "../../../../drivers/android");
|
|
2573
|
+
const maestroRunnerDrivers = resolve(
|
|
2574
|
+
__dirname2,
|
|
2575
|
+
"../../../../../../maestro-runner/drivers/android"
|
|
2576
|
+
);
|
|
2577
|
+
for (const dir of [projectDrivers, provDrivers, maestroRunnerDrivers, appiumServerApks]) {
|
|
2578
|
+
if (!dir) continue;
|
|
2579
|
+
if (!existsSync(dir)) continue;
|
|
2580
|
+
const files = readdirSync(dir);
|
|
2581
|
+
const serverApk = files.find(
|
|
2582
|
+
(f) => f.startsWith("appium-uiautomator2-server") && !f.includes("androidTest") && f.endsWith(".apk")
|
|
2583
|
+
);
|
|
2584
|
+
const testApk = files.find((f) => f.includes("androidTest") && f.endsWith(".apk"));
|
|
2585
|
+
if (serverApk && testApk) {
|
|
2586
|
+
return { serverApk: join(dir, serverApk), testApk: join(dir, testApk) };
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return null;
|
|
2590
|
+
}
|
|
2591
|
+
function installUiAutomator2(serial) {
|
|
2592
|
+
const apks = findUiAutomator2APK();
|
|
2593
|
+
if (!apks) {
|
|
2594
|
+
throw new Error(
|
|
2595
|
+
"UiAutomator2 server APK not found. Install appium-uiautomator2-server or place APKs in drivers/android/"
|
|
2596
|
+
);
|
|
2597
|
+
}
|
|
2598
|
+
console.log(`Installing UiAutomator2 server on ${serial}...`);
|
|
2599
|
+
adbInstall(serial, apks.serverApk);
|
|
2600
|
+
adbInstall(serial, apks.testApk);
|
|
2601
|
+
console.log("UiAutomator2 server installed.");
|
|
2602
|
+
}
|
|
2603
|
+
function isUiAutomator2Installed(serial) {
|
|
2604
|
+
try {
|
|
2605
|
+
const output = adbShell(serial, "pm list packages io.appium.uiautomator2.server");
|
|
2606
|
+
return output.includes("io.appium.uiautomator2.server");
|
|
2607
|
+
} catch {
|
|
2608
|
+
return false;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
function startUiAutomator2Server(serial) {
|
|
2612
|
+
const adb = findADB();
|
|
2613
|
+
if (!adb) throw new Error("adb not found");
|
|
2614
|
+
try {
|
|
2615
|
+
execSync(
|
|
2616
|
+
`${adb} -s ${serial} shell am instrument -w -e disableAnalytics true io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner &`,
|
|
2617
|
+
{ stdio: "ignore", timeout: 5e3 }
|
|
2618
|
+
);
|
|
2619
|
+
} catch {
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
async function setupUiAutomator2(serial, hostPort) {
|
|
2623
|
+
const port = hostPort ?? allocatePort(8200);
|
|
2624
|
+
if (!isUiAutomator2Installed(serial)) {
|
|
2625
|
+
installUiAutomator2(serial);
|
|
2626
|
+
}
|
|
2627
|
+
const adb = findADB();
|
|
2628
|
+
if (adb) {
|
|
2629
|
+
try {
|
|
2630
|
+
execSync(`${adb} -s ${serial} forward --remove tcp:${port}`, { stdio: "ignore" });
|
|
2631
|
+
} catch {
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
startUiAutomator2Server(serial);
|
|
2635
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
2636
|
+
const devicePort = 6790;
|
|
2637
|
+
adbForward(serial, port, devicePort);
|
|
2638
|
+
const maxRetries = 10;
|
|
2639
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
2640
|
+
try {
|
|
2641
|
+
const res = await fetch(`http://localhost:${port}/status`);
|
|
2642
|
+
if (res.ok) {
|
|
2643
|
+
console.log(`UiAutomator2 server ready on port ${port}`);
|
|
2644
|
+
const cleanup = () => {
|
|
2645
|
+
try {
|
|
2646
|
+
if (adb)
|
|
2647
|
+
execSync(`${adb} -s ${serial} forward --remove tcp:${port}`, { stdio: "ignore" });
|
|
2648
|
+
} catch {
|
|
2649
|
+
}
|
|
2650
|
+
releasePort(port);
|
|
2651
|
+
};
|
|
2652
|
+
return { host: "localhost", port, cleanup };
|
|
2653
|
+
}
|
|
2654
|
+
} catch {
|
|
2655
|
+
}
|
|
2656
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
2657
|
+
}
|
|
2658
|
+
releasePort(port);
|
|
2659
|
+
throw new Error(`UiAutomator2 server did not start within ${maxRetries} seconds`);
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2394
2662
|
export {
|
|
2663
|
+
resolveNetworkConditions,
|
|
2395
2664
|
makePlaywrightDriver,
|
|
2396
2665
|
createUiAutomator2Driver,
|
|
2397
2666
|
createWDADriver,
|
|
2398
|
-
parseWebHierarchy,
|
|
2399
2667
|
parseAndroidHierarchy,
|
|
2400
|
-
parseIOSHierarchy
|
|
2668
|
+
parseIOSHierarchy,
|
|
2669
|
+
setupUiAutomator2
|
|
2401
2670
|
};
|
|
2402
|
-
//# sourceMappingURL=chunk-
|
|
2671
|
+
//# sourceMappingURL=chunk-MCT4DYDK.js.map
|