当前位置:首页 >> 中药养生 >> 干货|app智能化测试之Appium WebView 技术原理

干货|app智能化测试之Appium WebView 技术原理

发布时间:2023-03-04

ium Server 请注意通过发挥作用查找到的所有 WebView 和可视 Context,如下:

[debug] [AndroidDriver] Found webviews: ["WEBVIEW_cn.goapk.market",

"WEBVIEW_io.appium.android.apis"]

[debug] [AndroidDriver] Available contexts: ["NATIVE_APP",

"WEBVIEW_cn.goapk.market","WEBVIEW_io.appium.android.apis"]

然后 Appium Server 更加进一步连接起来 ChromeDriver,由于我们没有设 ChromeDriver 的UDP,所以 Appium Server 默认竣工 8000 UDP与 WebView 通信。Appium Server 通过 ChromeDriver 与 app WebView 通信。

[debug] [AndroidDriver] Connecting to chrome-backed webview context

'WEBVIEW_io.appium.android.apis'

[debug] [AndroidDriver] A port was not given, using random port: 8000

然后,Appium 再行杀掉 ChromeDriver 这个发挥作用,修整 adb 等价UDP数据,如下:

[debug] [Chromedriver] Killing any old chromedrivers, running:

pkill -15 -f "/usr/local/lib/node_modules/appium/node_modules/

_appium-chromedriver@3.1.3@appium-chromedriver/chromedriver/mac/

chromedriver.*便是port=8000"

[Chromedriver] No old chromedrivers seemed to exist

[debug] [Chromedriver] Cleaning any old adb forwarded port socket

connections

[debug] [ADB] List forwarding ports

[debug] [ADB] Running '/Users/xxx/profile/android-sdk_r24.4.1-macosx

/android-sdk-macosx/platform-tools/adb' with args: ["-P",5037,"-s","192.168.56.101:5555","forward","便是list"]

到这步是真正重启 ChromeDriver 服务,成立起 Appium Server 与 ChromeDriver 彼此之间的通信。

[Chromedriver] Spawning chromedriver with: /usr/local/lib/

node_modules/appium/node_modules/_appium-chromedriver@3.1.3@

appium-chromedriver/chromedriver/mac/chromedriver 便是url-base=wd/hub

便是port=8000 便是adb-port=5037 便是verbose

成立连接起来之后,Appium Server 再行提示 ChromeDriver 版本号。

[debug] [Chromedriver] Chromedriver version: '2.33.506106'

ChromeDriver 墨水激活笔记,开始传输表达式。

[debug] [Chromedriver] [STDOUT] Starting ChromeDriver 2.33.506106

(8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 8000

[debug] [Chromedriver] [STDOUT] Only local connections are allowed.

[debug] [JSONWP Proxy] Proxying [GET /status] to [GET

] with no body

[debug] [JSONWP Proxy] Got response with status 200:

"{"sessionId":"","status":0,"value":{"build":{"version

":"alpha"},"os":{"arch":"x86_64","name":"Mac OS X",

"version":"10.12.6"}}}"

[debug] [JSONWP Proxy] Proxying [POST /session] to [POST

] with body: {"

desiredCapabilities":{"chromeOptions":{"androidPackage":

"io.appium.android.apis","androidUseRunningApp":true,"androidDeviceSerial":"192.168.56.101:5555"}}}

通过 ps 号令请注意手机的发挥作用此表,从之前查找 WebView。

[Chromedriver] [STDERR] [0.349][DEBUG]:

Sending adb command:

host:transport:192.168.56.101:5555|shell:ps && ps -A

通过发挥作用此表给予 WebView 的发挥作用号,Appium 根据这些信息系统设计 WebView。

Chromedriver] [STDERR] [0.365][DEBUG]:

Sending adb command:

host-serial:192.168.56.101:5555:forward:tcp:12531;

localabstract:webview_devtools_remote_26060

提示WebView

WebView 控件会被等价为原生控件,类型为 View,其之前的文本内容可会变成 content-desc(Android 6.0)或者 text(Android 9.0)。

弹出从那时起 APP,比如说号令可以提示 Android 系统内的 WebView 发挥作用:

Hogwarts $ adb shell cat /proc/net/unix | grep webview

0000000000000000: 00000002 00000000 00010000 0001 01 12863 /dev/socket/webview_zygote

0000000000000000: 00000002 00000000 00010000 0001 01 24703 @webview_devtools_remote_1758

0000000000000000: 00000003 00000000 00000000 0001 03 24672 /dev/socket/webview_zygote

里面的号令之前,凡是名字在后有 @ 的都是套接字。套接字(Socket)是对网路之前不同主机上的应用发挥作用彼此之间透过双向通信的端点的表象。

比如说号令提示这个发挥作用对应的应用:

Hogwarts $ adb shell ps |grep 1758

u0_a67 1758 211 1600592 333680 futex_wait_queue_me f016fbb9 S com.xueqiu.android

提示到是从那时起 APP 的 WebView 发挥作用。检验时,Appium Server 就为了让这个UDP实现与 WebView 的通信。

Context切换

由于反之亦然系统设计套接字无法,所以用到 adb forward 将它重定向到本地UDP。

adb forward tcp:$port localabstract:webview_devtools_remote_$pid

例如:用到本地 7777 UDP

Hogwarts $ adb forward tcp:7777 localabstract:webview_devtools_remote_1758

可以发送 http 立即实现无关系统设计,比如说给予 WebView 部件版本(也可以反之亦然在浏览器之前到访 ),号令如下:

Hogwarts $ curl

{

"Android-Package": "com.xueqiu.android",

"Browser": "Chrome/74.0.3729.186",

"Protocol-Version": "1.3",

"User-Agent": "Mozilla/5.0 (Linux; Android 8.1.0; Google Pixel_1 Build/OPM6.171019.030.E1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.186 Mobile Safari/537.36",

"V8-Version": "7.4.288.28",

"WebKit-Version": "537.36 (@99fc61ba7ee9c511608e5ea11edc2622ba3b8e3f)",

"webSocketDebuggerUrl": "ws://localhost:7777/devtools/browser"

}

Chrome 的 devtools 协定是远程复用协定()

可以反之亦然给予 devtoolsFrontendUrl 提示复用的远程重定向的首页详细资料。

[

{

"description": "{"attached":true,"empty":false,"height":1605,"screenX":0,"screenY":189,"visible":true,"width":1080}",

"devtoolsFrontendUrl": "_rev/@99fc61ba7ee9c511608e5ea11edc2622ba3b8e3f/inspector.html?ws=127.0.0.1:7777/devtools/page/06840BED58C1415235EFC9817FFD472E",

"faviconUrl": "",

"id": "06840BED58C1415235EFC9817FFD472E",

"title": "天下太平证券 Speed开户",

"type": "page",

"url": "_from=tab",

"webSocketDebuggerUrl": "ws://127.0.0.1:7777/devtools/page/06840BED58C1415235EFC9817FFD472E"

},

...

然后到访Chrome的复用首页 chrome://inspect/#devices,就可以给予到首页锕系元素信息,从而完成对锕系元素的定位。

appium WebView技术开发原理就再行谈到这,大家有什么问题或异议都可以在下方留言板给我哦!

⬇️ 粘贴“下方链接”,提升检验核心竞争能力!

>>更加多技术开发文章分享和免费资料领取 给予更加多无关资料,请掺入微信 ceshiren001

_id=qrcode&from=souhu×tamp=1650849410

一吃辣就拉肚子是什么原因
类风湿性关节炎吃什么可以缓解
成都哪家医院治包皮过长好
苏州看白癜风去哪看
珍珠明目滴眼液禁忌
标签:
友情链接: