实现思路:
1.获取九宫格patterview的起始坐标x、y
2.获取九宫格patterview的宽度(width)、高度(height)
3.九宫格的九个格子大约平均把patterview的长、宽平均分成了4个等分,宽度间隔为width/4、高度间隔为height/4
4.第一个格子的坐标为(x+width/4, y+height/4)
5.每次滑动的时候,就相当于横坐标(纵坐标)的变化量△x为width/4(height/4)
6.使用TouchAction、moveTo方法实现滑动即可
实现代码:
def test_cKabao(self):
self.driver.find_element_by_id('cn.xxxx.xxxx.android:id/xxxx_tv_card_package').click()
time.sleep(1)
patterview = self.driver.find_element_by_id('cn.xxxx.xxxx.android:id/xxxx_card_pw_patterview') #获取九宫格控件
x = patterview.location.get('x') #九宫格的起始坐标x
y = patterview.location.get('y') #九宫格的起始坐标y