zoukankan      html  css  js  c++  java
  • 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()表示从元素的父元素下查找
     
    回忆滋润坚持
  • 相关阅读:
    跃迁方法论 Continuous practice
    EPI online zoom session 面试算法基础知识直播分享
    台州 OJ 2648 小希的迷宫
    洛谷 P1074 靶形数独
    洛谷 P1433 DP 状态压缩
    台州 OJ FatMouse and Cheese 深搜 记忆化搜索
    台州 OJ 2676 Tree of Tree 树状 DP
    台州 OJ 2537 Charlie's Change 多重背包 二进制优化 路径记录
    台州 OJ 2378 Tug of War
    台州 OJ 2850 Key Task BFS
  • 原文地址:https://www.cnblogs.com/james5d/p/14165775.html
Copyright © 2011-2022 走看看