其他分享
首页 > 其他分享> > appium中的Multiaction(多点触控)的用法

appium中的Multiaction(多点触控)的用法

作者:互联网

# coding: utf-8

from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

"""两个手指操作屏幕"""


def pinch(driver):
    """
    两个手指向内滑
    @param driver:
    @return:
    """
    action1 = TouchAction(driver)
    action2 = TouchAction(driver)
    pinch_action = MultiAction(driver)

    x = driver.get_window_size()['width']
    y = driver.get_window_size()['height']

    action1.press(x=x * 0.8, y=y * 0.5).wait(500).move_to(x=x * 0.6, y=y * 0.5).wait(500).release()
    action2.press(x=x * 0.2, y=y * 0.5).wait(500).move_to(x=x * 0.4, y=y * 0.5).wait(500).release()

    pinch_action.add(action1, action2)
    print('start pinch...')
    pinch_action.perform()


def zoom(driver):
    """
    两个手指向外滑
    @param driver:
    @return:
    """
    action1 = TouchAction(driver)
    action2 = TouchAction(driver)
    zoom_action = MultiAction(driver)

    x = driver.get_window_size()['width']
    y = driver.get_window_size()['height']

    action1.press(x=x * 0.4, y=y * 0.5).wait(500).move_to(x=x * 0.2, y=y * 0.5).wait(500).release()
    action2.press(x=x * 0.6, y=y * 0.5).wait(500).move_to(x=x * 0.8, y=y * 0.5).wait(500).release()

    zoom_action.add(action1, action2)
    print("start zoom...")
    zoom_action.perform()

 

标签:action1,appium,driver,0.5,Multiaction,触控,action,500,wait
来源: https://www.cnblogs.com/xioawu-blog/p/16079814.html