C/C++教程

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()

 

这篇关于appium中的Multiaction(多点触控)的用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!