简体   繁体   中英

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. Accessibility id for feet is ft. and for metric is m.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM