@xiaoxuxu 小程序的控件怎么定位
@adfghzhang 请问如何定位小程序 webview 里面控件的
chromedevtool inspect 出的能直接用么
@TheRoadNotTaken 能定位是说小程序么
@hukui51770 xtest 是记录点击页面的位置,然后回放,用例是这样的
sleep(1000)
clickpx(0.2517,0.9344, clicktime, TimeMarker(CaseN))
--null
sleep(1000)
clickpx(0.6285,0.5458, clicktime, TimeMarker(CaseN))
我用的是 nexus 6 android 7.0 xtest 还没适配,低版本是好的,可以定位小程序的 控件
tap(-2, 'WX-VIEW', '搜 索', '@0%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.LinearLayout%2:android.widget.FrameLayout%1:android.widget.LinearLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.FrameLayout%1:android.widget.AbsoluteLayout//BODY/WX-VIEW[1]/WX-VIEW[1]/WX-VIEW[2]/WX-VIEW[1]/WX-VIEW[6]/WX-VIEW[1]|70',0.4323,0.6288, 20, TimeMarker(CaseN), 'com.tencent.mm.plugin.appbrand.ui.AppBrandUI')
#11 楼 @xiaoxuxu 注意格式,应该是 self.driver.switch_to.context->‘WEBVIEW_com.tencent.mm:appbrand0‘
#12 楼 @zhangjunjie
原因大概是 getsource 看到 body 是空的
,所以 xpath 什么也找不到,你这种方式是无效的
@seveniruby
楼主的例子能成功执行?还是只是提供一个思路
美团外卖首页,getsource ,也是
我试了这么多,source 的数据都是
形式的,这样的话不能支持自动化,还是我的方式错了小程序的 androidProcess 不是 WEBVIEW_com.tencent.mm:tools ,要设置对应的 com.tencent.mm:appbrand0 com.tencent.mm:appbrand1 等,和每次打开小程序的循序有关,再切换上下文,提示 [debug] [Chromedriver] Changed state to 'online' 才真的进入的 WEBVIEW。
但是我找元素时候报错了
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"s
elector\":\"//*[text()='机票']\"}\n (Session info: webview=37.0.0.0)\n (Driver info: chromedriver=
2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
我切换成功
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no b
ody
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"
build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.
1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with
body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"args":[],"androidProcess":"com.tencent.mm:appbrand0","extensions":[],"androidDeviceSerial"
:"ZX1G4294SH"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled
":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.26.436362 (5476ec6bf7ccbada1734a0c
dec7d570bb042aa30)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTou
chScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":fals
e,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapS
napshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"37.0.0.0","webStorageE
nabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/9a81663a-b01d-4846-90e0-779e160c4644/context 200 5078 ms - 76、
但是找元素时候提示这个
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"s
elector\":\"//*[text()='机票']\"}\n (Session info: webview=37.0.0.0)\n (Driver info: chromedriver=
2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
原因大概知道了,去哪儿出行页面显示很丰富,但是 getsource 看到 body 是空的
,所以 xpath 什么也找不到
**
我切换成功
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no b
ody
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"
build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.
1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with
body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"args":[],"androidProcess":"com.tencent.mm:appbrand0","extensions":[],"androidDeviceSerial"
:"ZX1G4294SH"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled
":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.26.436362 (5476ec6bf7ccbada1734a0c
dec7d570bb042aa30)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTou
chScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":fals
e,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapS
napshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"37.0.0.0","webStorageE
nabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/9a81663a-b01d-4846-90e0-779e160c4644/context 200 5078 ms - 76、
但是找元素时候提示这个
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"s
elector\":\"//*[text()='机票']\"}\n (Session info: webview=37.0.0.0)\n (Driver info: chromedriver=
2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
我切换成功
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no b
ody
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"
build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.
1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with
body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"args":[],"androidProcess":"com.tencent.mm:appbrand0","extensions":[],"androidDeviceSerial"
:"ZX1G4294SH"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled
":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.26.436362 (5476ec6bf7ccbada1734a0c
dec7d570bb042aa30)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTou
chScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":fals
e,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapS
napshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"37.0.0.0","webStorageE
nabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/9a81663a-b01d-4846-90e0-779e160c4644/context 200 5078 ms - 76、
但是找元素时候提示这个
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"s
elector\":\"//*[text()='机票']\"}\n (Session info: webview=37.0.0.0)\n (Driver info: chromedriver=
2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
原因大概知道了,去哪儿出行页面显示很丰富,但是 getsource 看到 body 是空的
😂 😂 😂 😂 😂 😂 😂 😂 ,所以 xpath 什么也找不到
出现 #36 楼一样的报错,有知道怎么解决么 用的模拟器 iphone7 iOS10.2 xcode8.2
研究研究
过去快一天了,好水
开源地址我帮贴一下 https://github.com/jayway/JsonPath
Appium 如果使用纯 java 实现自动化,可以结合 java 单元测试框架集成,不是没有,是需要整合。
而且 robotframework 已经有 AppiumLibrary,调研时候不能漏掉
看到这句话我能感觉到局限性很大很大,“定位控件时,统一采用元素 ID 进行定位”
看大神帖子,能学到很多
收藏讨论区
这么好的合集怎么回复这么少