一、滑动功能的封装。
def get_size(): size=driver.get_window_size() x=size[‘width‘] y=size[‘height‘] return x,ydef swipe_left(): #从右向左滑动 x1=get_size()[0]*0.85 y1=get_size()[1]*0.5 x2=get_size()[0]*0.15 sleep(3) driver.swipe(x1,y1,x2,y1)def swipe_right(): #从左向右滑动 x1=get_size()[0]*0.15 y1=get_size()[1]*0.5 x2=get_size()[0]*0.85 sleep(3) driver.swipe(x1,y1,x2,y1)def swipe_up(): #从下向上滑动 x1=get_size()[0]*0.5 y1=get_size()[1]*0.85 y2=get_size()[1]*0.15 sleep(3) driver.swipe(x1,y1,x1,y2)def swipe_down(): #从上向下滑动 x1=get_size()[0]*0.5 y1=get_size()[1]*0.15 y2=get_size()[1]*0.85 sleep(3) driver.swipe(x1,y1,x1,y2)def swipe_on(direction): if direction ==‘up‘: swipe_up() elif direction ==‘down‘: swipe_down() elif direction ==‘left‘: swipe_left() else: swipe_right()swipe_on(‘up‘) #调用什么方法传什么值
原文地址:https://www.cnblogs.com/gaotiansai/p/10312046.html
时间: 2024-10-15 23:38:49