jiucai09 发表于 2022-11-4 01:32:51

请问EC有函数是获取一个区域的节点信息吗?

本人现在碰到一个App,很奇葩.一个可以上下滚动页面的界面里,无论是滚到页面的底部还是页面的最上面或者页面的中间都能获取到节点信息
在页面最上面的时候获取到的信息

let node = text("今日签到").getOneNodeInfo(1000)
if (node) {
    logw("有");
} else {
    logw("没有");
}
logw(JSON.stringify(text("今日签到").getOneNodeInfo(1000)))
logw(text("今日签到").getNodeInfo(1000))【远程设备】(js/main.js#55 )有【远程设备】(js/main.js#59 ){"bounds":{"top":1519,"bottom":1520,"left":114,"right":232},"visibleBounds":{"top":1519,"bottom":1520,"left":114,"right":232},"childCount":0,"clz":"android.view.View","pkg":"com.taobao.live","text":"今日签到","checkable":false,"checked":false,"clickable":false,"enabled":true,"focusable":false,"focused":false,"longClickable":false,"scrollable":false,"selected":false,"nid":"android.view.accessibility.AccessibilityNodeInfo@60abd","parentId":"android.view.accessibility.AccessibilityNodeInfo@6088f","index":1,"depth":26,"visible":true,"drawingOrder":0,"editable":false,"password":false,"multiLine":false,"dismissable":false}【远程设备】(js/main.js#60 )
很奇葩,visble属性永远都是true
因为想写成适配各种不同分辨率手机的,所以冒出来一个想法,
能否固定一个范围,在一个手机屏幕上固定的范围内搜索想要的节点信息

下面是页面里最下面的获取信息,本人手机是720*1520分辨率,这个页面在我手机上差不多一比一的上下滚动要滚两次半才到底部
let node = text("今日签到").getOneNodeInfo(1000)

【远程设备】(js/main.js#55 )有【远程设备】(js/main.js#59 ){"bounds":{"top":55,"bottom":57,"left":114,"right":232},"visibleBounds":{"top":55,"bottom":57,"left":114,"right":232},"childCount":0,"clz":"android.view.View","pkg":"com.taobao.live","text":"今日签到","checkable":false,"checked":false,"clickable":false,"enabled":true,"focusable":false,"focused":false,"longClickable":false,"scrollable":false,"selected":false,"nid":"android.view.accessibility.AccessibilityNodeInfo@60abd","parentId":"android.view.accessibility.AccessibilityNodeInfo@6088f","index":1,"depth":26,"visible":true,"drawingOrder":0,"editable":false,"password":false,"multiLine":false,"dismissable":false}【远程设备】(js/main.js#60 )


如果说用的是下面这种找到就直接点击   根本就点不到今日签到,点了也会有logd(true),但是问题点的不是今日签到啊!
let node = text("今日签到").getOneNodeInfo(1000)
if (node) {
    logw("有");
    node.click()
} else {
    logw("没有");
}



Mr_老鬼 发表于 2022-11-4 02:27:07

bounds属性给范围即可

jiucai09 发表于 2022-11-5 15:39:02

麻烦多给点提示,怎么给范围,相差一个半的屏幕,获取到的bounds属性,最上面能正确看得见的{"top":1519,"bottom":1520,"left":114,"right":232}
隔开一个半的屏幕,节点早就不见了,还能获取到范围{"top":55,"bottom":57,"left":114,"right":232},就算以这个范围去点击也是点击不对应的节点啊

Mr_老冷 发表于 2022-11-5 17:02:04

jiucai09 发表于 2022-11-5 15:39
麻烦多给点提示,怎么给范围,相差一个半的屏幕,获取到的bounds属性,最上面能正确看得见的{"top":1519,"botto ...

这是节点展示问题,很多动态加载的网页,比如小程序容易这样,你需要通过别的参数,比如visible等来做额外限制

jiucai09 发表于 2022-11-5 18:59:30

只要在一个页面里,无论是否在屏幕上显示,最上面最底下都是visible(true),所以头疼啊,看不见的也是true,哪怕做个滑动的操作也要是在判断能看得见啊,我认为是可行的方案,a,bounds在720*1520内就识别成可见可执行点击
页: [1]
查看完整版本: 请问EC有函数是获取一个区域的节点信息吗?