• uiautomator


    uiautomator方法定位app元素: 
    appium在android端是调用其底层的UIAutomator2自动化测试框架去驱动自 
    动化,在定位元素的时候,可以借助UIAutomator2的语法来实现定位。在代码 
    实现上提供的API是find_element_by_android_uiautomator。 
    1、根据text定位: 
    find_element_by_android_uiautomator('text("值")') 
    find_element_by_android_uiautomator('new UiSelector().text("值")') 
    text定位相关函数: 
    textContains:模糊匹配文本 
    textStartsWith:以某个文本开头来匹配 
    textMatches:正则匹配
     
    uiautomator方法定位app元素: 
    2、根据resourceId定位: 
    find_element_by_android_uiautomator('resourceId("值")') 
    find_element_by_android_uiautomator('new UiSelector().resourceId("值")') 
    3、根据className定位: 关键字 className 
    4、根据contenet-des定位: 关键字 description 
    5、组合定位(类名和文本): 
    new UiSelector().className("类名").text("值") 
    其它组合定位方式类推
     
    uiautomator方法定位app元素: 
    6、根据元素关系定位: 
    1)后代元素定位 
    使用条件:子元素属性不定,不唯一,只能通过父元素来定位 
    new UiSelector().resourceId("值").childSelector(className("值").instance(数字)) 
    其中childSelector可以传入resourceId、description等方法 
    instance表示匹配的结果所有元素里面的第几个元素,从0开始计数 
    2)兄弟元素定位 
    通过子元素找到父元素,然后通过父元素再去找兄弟元素 
    new UiSelector().resourceId("值").fromParent(text("值")) 
    fromParent()表示从元素的父元素下查找
     
    回忆滋润坚持
  • 相关阅读:
    POJ 3672 水题......
    POJ 3279 枚举?
    STL
    241. Different Ways to Add Parentheses
    282. Expression Add Operators
    169. Majority Element
    Weekly Contest 121
    927. Three Equal Parts
    910. Smallest Range II
    921. Minimum Add to Make Parentheses Valid
  • 原文地址:https://www.cnblogs.com/james5d/p/14165775.html
Copyright © 2020-2023  润新知