Tap 模拟手势点击坐标

前言:有时候元素怎么都定位不到,没办法就只能坐标定位了,不过这个坐标定位不准确,换个手机就可能定位不到了,这是一个下下策的定位方式。

tap用法

1.tap是模拟手指点击页面上元素
语法有两个参数,第一个是positions,是list类型最多五个点,duration是持续时间,单位毫秒

tap(self, positions, duration=None):

    Taps on an particular place with up to five fingers, holding for a certain time
    
    模拟手指点击(最多五个手指),可设置按住时间长度(毫秒)
    
    :Args:
    
    - positions - list类型,里面对象是元组,最多五个。如:[(100, 20), (100, 60)]
    
    - duration - 持续时间,单位毫秒,如:500
    
    :Usage:
    
    driver.tap([(100, 20), (100, 60), (100, 100)], 500)

坐标定位

#coding= utf-8
from appium import webdriver
desired_caps = {
                'platformName':"Android",
                'deviceName':"R8V5T15930002010",
                'platformVersion':"5.0.1",
                'appPackage':"com.yuedan",
                'appActivity':"com.yuedan.ui.Activity_Splash",
                }
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

# 点登录
driver.tap([(781,1513),(1022,1648)], 500)
原文地址:https://www.cnblogs.com/guo2733/p/10619535.html