python自动化滑动解锁_python九宫格滑动解锁

实现思路:

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 //获取九宫格的宽度、高度 width = patterview.size.get('width') #九宫格的宽度 height = patterview.size.get('height') #九宫格的高度 # print(x, y, width, height) xstep = width/4 #宽度间隔 ystep = height/4 #高度间隔 #九宫格第一个格子的坐标(即是九宫格的起始坐标) xStartPoint = x + xstep yStartPoint = y + ystep //使用TouchAction方法实现滑动解锁 TouchAction(self.driver).press(x=xStartPoint, y=yStartPoint).wait(1000).move_to(x=0, y=ystep).wait(1000).move_to(x=0, y=ystep).wait(1000).move_to(x=xstep, y=0).release().perform() time.sleep(5) RelativeLayout = self.driver.find_element_by_class_name('android.widget.RelativeLayout') RelativeLayout.find_element_by_id('cn.xxxx.xxxx.android:id/xxxx_base_iv_back').click() # self.driver.find_element_by_id('cn.xxxx.xxxx.android:id/xxxx_base_iv_back') print('test_cKabao 测试成功') time.sleep(3)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值