简体   繁体   English

如何使用 Python 在 Appium 测试中滚动/滑动?

[英]How to scroll/swipe in Appium tests using Python?

I am trying to scroll / swipe from ft. to m.我正在尝试从英尺滚动/滑动到米。 in my Appium with Python test.在我的 Appium 中用 Python 测试。 Accessibility id for feet is ft. and for metric is m.英尺的可访问性 ID 是ft. ,公制的可访问性 ID 是m.

Here is the code snippet I am trying to use to do this but the ft. doesn't switch to 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()

在此处输入图片说明

How can I change it to m.?我怎样才能把它改成m.? (In the picture below I have played with the swipe but I can't be dependent on the coordinates) (在下面的图片中,我玩过滑动但我不能依赖坐标)

Try this尝试这个

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

Change the value on for loop according to to the swipes required根据所需的滑动更改 for 循环上的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用python和appium滚动到未出现在视图中的元素 - How to scroll to an element that does not appear in the view using python and appium 如何通过 Python 客户端使用 Appium 滚动 Android 应用程序 - How to scroll Android app with Appium by Python Client 是否可以使用Appium Python和AWS Device Farm为离子应用程序(在iOS和Android上运行)创建自动化测试? - Is it possible to create automation tests for ionic app(working on iOS and Android) using Appium Python and AWS Device Farm? 如何在 python 中使用 selenium 在 div 中“向上滚动”? - How to “scroll up” in div using selenium in python? 如何在 python 中使用 selenium chromedriver 水平滚动 - How to scroll horizontally using selenium chromedriver in python 如何在python中使用硒滚动元素 - How to scroll in an element using selenium in python 如何使用 Selenium Python 滚动到 div 的底部 - How to scroll to bottom of div using Selenium Python 如何使用Appium / Python在真实设备上启动应用程序? - How to start an application on real device with Appium/Python? 如何断开互联网与appium Python的连接 - How to disconnect Internet from appium Python 如何在 Python 中以编程方式启动 appium 服务器 - How to start appium server programmatically in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM