appium 中的手势操作

一、滑动

 driver.swipe(size["width"]*0.5, size["height"]*0.99, size["width"]*0.5, size["height"]*0.5, duration=200)

press手势,move_to,release之间无需等待

size = driver.get_window_size()
ta = TouchAction(driver)
width = size['width']
height = size['height']
ta.press(x=width*0.5, y=height*0.9).wait(100).\
    move_to(x=width*0.5, y=height*0.3).\
    release()
ta.perform()

二、九宫格

三、列表滑动

# 列表滑动
old = None
new = driver.page_source
i = 0
while new != old:
    try:
        print('查找----{}'.format(i))
        driver.find_element_by_android_uiautomator('new UiSelector().descriptionContains("做你自己,我一直暗暗对自己说。 ")')
    except:
        driver.swipe(size["width"] * 0.5, size["height"] * 0.9, size["width"] * 0.5, size["height"] * 0.3,
                     duration=200)
        time.sleep(3)
        old = new
        new = driver.page_source
        print('继续查找----{}'.format(i))
    else:
        print('找到了安全测试----{}'.format(i))
        break
    i = i + 1

四、放大缩小

from appium.webdriver.common.multi_action import MultiAction

size = driver.get_window_size()
width = size['width']
height = size['height']
a = TouchAction(driver)
# 中心点向左下角滑动
a.press(x=width*0.5, y=height*0.5).wait(100).\
    move_to(x=width*0.1, y=height*0.9).\
    release()
b = TouchAction(driver)
# 中心点向右上角滑动
b.press(x=width*0.5, y=height*0.5).wait(100).\
    move_to(x=width*0.9, y=height*0.1).\
    release()
c = MultiAction(driver)
c.add(a,b)
c.perform()

五、tap

posted @ 2020-11-20 16:52  一二三开花  阅读(206)  评论(0编辑  收藏  举报