我们在appium做自动化时发现,有一些元素我们使用各种工具都是无法定位到,或者有的元素不是唯一识别标志,不管用哪种元素定位方法都定位不到,那遇到这种情况我们该怎么办呢?appium中webdriver提供了tap方法通过相对坐标来进行定位。
tap是模拟手指点击,一般页面上元素的语法有两个参数,第一个是positions,是list类型最多五个点,duration是持续时间,单位毫秒。
tap语法:
tap(self, positions, duration=None):
Taps on an particular place with up to five fingers, holding for a certain time
模拟手指点击(最多五个手指),可设置按住时间长度(毫秒)
:Args:
- positions - an array of tuples representing the x/y coordinates of the fingers to tap. Length can be up to five.
list类型,里面对象是元组,最多五个。如:[(