在通过命令 driver.getContextHandles()
获取contexts时,server端的日志显示如下,没有appbrand的进程:
[debug] [W3C] Calling AppiumDriver.getContexts() with args: ["cd82f81a-2f2f-4153-8a62-ce68b2b2d8d6"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Running 'D:\\android-sdk\\platform-tools\\adb.exe -P 5037 -s a18968ee7d04 shell cat /proc/net/unix'
[debug] [AndroidDriver] WEBVIEW_10223 mapped to pid 10223
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Running 'D:\\android-sdk\\platform-tools\\adb.exe -P 5037 -s a18968ee7d04 shell ps'
[debug] [AndroidDriver] WEBVIEW_10714 mapped to pid 10714
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Running 'D:\\android-sdk\\platform-tools\\adb.exe -P 5037 -s a18968ee7d04 shell ps'
[debug] [AndroidDriver] Parsed pid: '10223' pkg: 'com.tencent.mm' from
[debug] [AndroidDriver] USER PID PPID VSIZE RSS WCHAN PC NAME
[debug] [AndroidDriver] u0_a159 10223 619 2039416 204100 SyS_epoll_ 0000000000 S com.tencent.mm
[debug] [AndroidDriver] Returning process name: 'com.tencent.mm'
[debug] [AndroidDriver] Parsed pid: '10714' pkg: 'com.tencent.mm:tools' from
[debug] [AndroidDriver] USER PID PPID VSIZE RSS WCHAN PC NAME
[debug] [AndroidDriver] u0_a159 10714 619 1998956 144340 SyS_epoll_ 0000000000 S com.tencent.mm:tools
[debug] [AndroidDriver] Returning process name: 'com.tencent.mm:tools'
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.tencent.mm","WEBVIEW_com.tencent.mm:tools"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.tencent.mm","WEBVIEW_com.tencent.mm:tools"]
[debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_com.tencent.mm","WEBVIEW_com.tencent.mm:tools"]
而手动通过adb命令执行,显示如下,赫然显示着appbrand:
λ adb -P 5037 -s a18968ee7d04 shell ps | findstr tencent.mm
u0_a159 10223 619 2037756 196284 SyS_epoll_ 0000000000 S com.tencent.mm
u0_a159 10301 619 1470284 67732 SyS_epoll_ 0000000000 S com.tencent.mm:exdevice
u0_a159 10379 619 1484904 74408 SyS_epoll_ 0000000000 S com.tencent.mm:push
u0_a159 10529 619 2208668 207552 SyS_epoll_ 0000000000 S com.tencent.mm:appbrand0
u0_a159 10714 619 1987940 143148 SyS_epoll_ 0000000000 S com.tencent.mm:tools
u0_a159 10798 619 1485728 66468 SyS_epoll_ 0000000000 S com.tencent.mm:sandbox
导致在client端的脚本里总是获取不到小程序的context。
记得之前听思寒老师的公开课上说过,appium在使用adb命令的时候有个bug,难道就是我现在遇到的这个么?
求助思寒老师 @seveniruby ,给个解决的思路呀