講一下定位手機app上元素時定位父節點、兄弟節點的方法android
這裏就講這兩種了,也是比較經常使用的兩種方法,其餘的方法你們查看博客的其餘章節app
實例:ide
咱們如今要定位到RelativeLayout[0,1285][1080,1465]下的LinearLayout下的第二個元素code
1、 經過兄弟節點來定位get
使用方法:
following-sibling:: 找到當前節點的後面一個節點,也就是弟弟節點
preceding-sibling:: 找到當前節點的前面的一個節點,也就是哥哥節點博客
這裏我使用這句來找咱們須要定位的那個元素:it
Xpaht= //android.widdget.TextView[@text=」年化收益率(歷史)」]/following-sibling::android.widget.RelativeLayout/android.widget.LinearLayout[0]/android.widget.LinearLayout[1]
2、 經過父節點來定位class
使用方法:
Parent:: 或者 .. 找到當前節點的父節點方法
這裏使用父節點的方法來定位咱們須要找的那個元素:Xpath=//android.widget.TextView[@text=」年化收益率(歷史)」]/parent::android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout[0]/android.widget.LinearLayout[1]
di
最後的那句能夠用..來代替parent::