1 首先經過xpath獲取解鎖界面上九個點python
elements = d.xpath("//android.view.ViewGroup/android.widget.ImageView").all()
2 而後在經過center()方法獲取每一個點的中心座標android
a = elements[0].center() b = elements[1].center() c = elements[2].center() d = elements[3].center() e = elements[4].center() f = elements[5].center() g = elements[6].center() h = elements[7].center() i = elements[8].center()
3 經過Uiautomator2裏面有一個swipe方法,能夠經過傳入多個點的座標來實現解鎖九宮格git
d.swipe_points([a,b,c,d,e,f,g,h,i],0.02)
最後的0.02表明每一次滑動的時間,來個效果圖吧
github