首页 > 解决方案 > 如何使用 Python 在 Appium 测试中滚动/滑动?

问题描述

我正在尝试从英尺滚动/滑动到 m。在我的 Appium 中使用 Python 测试。英尺的可访问性 ID 是ft.,公制是m.

这是我试图用来执行此操作的代码片段,但ft.没有切换到m.

WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ACCESSIBILITY_ID, "ft.")))
start = driver.find_element_by_accessibility_id("ft.")
time.sleep(1)
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ACCESSIBILITY_ID, "m.")))
end = driver.find_element_by_accessibility_id("m.")
time.sleep(1)
TouchAction(driver).press(start).move_to(end).release().perform()

在此处输入图像描述

我怎样才能将其更改为 m.?(在下图中我玩过滑动但我不能依赖坐标)

标签: python-3.xappiumpython-appium

解决方案


尝试这个

for each in range(1, 2):
            driver.swipe(500, 1700, 500, 1000, 400)

根据所需的滑动更改 for 循环的值


推荐阅读