def swipe(self, start_x, start_y, end_x, end_y, duration=None):
"""Swipe from one point to another point, for an optional duration.
Args:
start_x (int): x-coordinate at which to start
start_y (int): y-coordinate at which to start
end_x (int): x-coordinate at which to stop
end_y (int): y-coordinate at which to stop
duration (:obj:`int`, optional): time to take the swipe, in ms.
Usage:
driver.swipe(100, 100, 100, 400)
Returns:
`appium.webdriver.webelement.WebElement`
</span><span style="color: #800000;">"""</span></pre>
if name==‘main’: driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub’, desired_caps) x = driver.get_window_size()[“width”] y = driver.get_window_size()[“height”] #向左滑动 driver.swipe(x0.9,y0.5,x0.1,y0.5,duration=2000)
在 Appium 中提供 swipe() 方法来模拟用户滑动屏幕。 swipe() 实现过程 是先通过在屏幕上标记两个坐标,然后再从开始坐标移动到结束坐标。 先看下 swipe 方法定义: def swipe(self, start_x, start_y, end_x, end_y, duration=None): """Swipe from one point to another point, for an optiona...