webview

Webview识别原理

appium会启动chromedriver /Users/seveniruby/projects/chromedriver/2.20/chromedriver --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
app或者浏览器,底层使用的是android的webview组件,webview组件有一个debug特性,可以在启动的时候,写入一个domain socket记录, webview_devtools_remote_3548
adb -P 5037 -s emulator-5554 shell cat /proc/net/unix 找到对应的webview调试入口
adb forward tcp:$port localabstract:webview_devtools_remote_$pid
curl http://localhost:7770/json/version
curl http://localhost:7770/json

自动寻找webview并分析

list_webview ()
{
    port=$1;
    adb shell cat /proc/net/unix | grep -a webview | awk -F_ '{print $NF}' | tr -d '
' | while read pid; do
        port=$((port+=1));
        adb forward tcp:$port localabstract:webview_devtools_remote_$pid;
        curl http://localhost:$port/json/version;
        curl http://localhost:$port/json;
    done
}
list_webview 7770

真机为了提高性能,默认不开启webview的debug属性,需要研发在webview的组件上调用debug开关
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews?hl=zh-cn

原文地址:https://www.cnblogs.com/an5456/p/12616664.html