github文档: github.com/appium/appi… (地址已经不存在了)
举例:
#导入包
from appium.webdriver.common.touch_action import TouchAction
#一、通过坐标点进行滑动操作(不建议使用坐标点)
action = TouchAction(self.driver)
action.press(x=300,y=1300).wait(200).move_to(x=300,y=300).release().perform()
time.sleep(10)
#二、先通过get_window_rect方法获取手机的宽和高,再进行滑动
width = self.driver.get_window_rect()['width']
height = self.driver.get_window_rect()['height']
action.press(x=width*0.5,y=width*0.85).wait(200).move_to(x=width*0.5,y=height*0.15).release().perform()
time.sleep(10)
#三、先通过get_window_size方法获取手机的宽和高,再进行滑动
width = self.driver.get_window_size()['width']
height = self.driver.get_window_size()['height']
action.press(x=width*0.5,y=height*0.85).wait(200).move_to(x=width*0.5,y=height*0.15).release().perform()
time.sleep(10)