# 获得机器屏幕大小x,y def getSize(dr): x = dr.get_window_size()['width'] y = dr.get_window_size()['height'] return (x, y) # 屏幕向上滑动 def swipeUp(dr,t): l = getSize(dr) x1 = int(l[0] * 0.5) # x坐标 y1 = int(l[1] * 0.75) # 起始y坐标 y2 = int(l[1] * 0.25) # 终点y坐标 dr.swipe(x1, y1, x1, y2, t) # 屏幕向下滑动 def swipeDown(dr,t): l = getSize(dr) x1 = int(l[0] * 0.5) # x坐标 y1 = int(l[1] * 0.25) # 起始y坐标 y2 = int(l[1] * 0.75) # 终点y坐标 dr.swipe(x1, y1, x1, y2, t) # 屏幕向左滑动 def swipLeft(dr,t): l = getSize(dr) x1 = int(l[0] * 0.75) y1 = int(l[1] * 0.5) x2 = int(l[0] * 0.05) dr.swipe(x1, y1, x2, y1, t) # 屏幕向右滑动 def swipRight(dr,t): l = getSize(dr) x1 = int(l[0] * 0.05) y1 = int(l[1] * 0.5) x2 = int(l[0] * 0.75) dr.swipe(x1, y1, x2, y1, t) if __name__ == '__main__': pass # # 调用向左滑动 # swipLeft(1000) # sleep(3) # # 调用向右滑动 # swipRight(1000) # 调用向上滑动 # swipeUp(1000) # 调用向下滑动 # swipeDown(1000) # while True: # # 滑动前获取pagesource # beforeswipe = self.driver.page_source # swipe.swipeUp(self.driver, 1000) # time.sleep(2) # # 滑动后获取pagesource # afterswipe = self.driver.page_source # # 判断是否滑动成功 # if (beforeswipe == afterswipe): # # 判断是否滑动到底部 # if (u'提交' in afterswipe): # self.driver.find_element_by_name('提交').click() # break # else: # self.assertFalse(False, u'没有滑动成功!') # else: # print() # # -------------------------- # # to do
所有评论(0)