uiautomator2.0 xpath拼接算法:
1.节点没有id desc text的,且如果class在同level子节点下,且本node前的节点中并唯一,按照class+【索引】(非属性index,有可能不一样)依次进行递归拼接,如
//android.widget.RelativeLayout[2]/android.widget.HorizontalScrollView[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]
2.节点没有id desc text的,如果class在同level子节点下,且本node前的节点中并不唯一,那么采用class+【同级node前节点出现次数】进行递归拼接
3.在递归的过程中,如果存在全局唯一的 id desc text,那么终止递归,采用李 //*[@resource-id=+【id】作为开始节点,如果同时存在属性id desc text 那么优先级id > desc > text
//*[@resource-id="com.jingdong.app.mall:id/i2"]/android.widget.RelativeLayout[1]
//*[@content-desc="NewAppcenter"]/androidx.recyclerview.widget.RecyclerView[1]
//*[@text="遮瑕膏"]
4.如果递归过程中节点存在全局唯一的class,可以以//class结束递归
//android.widget.HorizontalScrollView/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]
|