zoukankan      html  css  js  c++  java
  • Appium -选择、操作元素3

    UI Automator API定位

    id 、class name、acessibility id、xpath底层都是通过UI Automator API定位,UI Automator测试框架提供了一组API来构建UI测试

    利用UI Automator API控制测试设备,UI Automator测试框架非常适合编写黑盒自动化测试

    API就是库的编程接口 application programming interface

    Uiselector类就是用来选择的web元素的

    根据class name 和text属性

    code = 'new UiSelector().text("我的").className("android.widget.TextView")'
    ele = driver.find_element_by_android_uiautomator(code)
    根据resource id 属性
    根据childSelector和instance方法
    new UiSelector().resourceid("io.manong.developerdaily:id/tab_bar")
    childSelector(new UiSelector().className("android.widget.TextView").instance(3))

    textContains textStartsWith textMatches方法

    操作界面
    滑动
    Appium Webdriver的swipe方法(坐标和duration)
    直接查看,估算操作坐标
    先获取元素坐标,再分析操作坐标(更健壮)
    location = ele.location
    size1 =ele.size
    操作不可见元素
    先滑动到其可见
    再操作该元素
    获取全屏幕尺寸
    screenSize = driver.get_window_size()
    screenW = screenSize['width']
    screenH = screenSize['height']



  • 相关阅读:
    Linux命令之乐--nmap
    shell脚本学习总结09--分支与循环结构
    shell脚本学习总结08--比较与测试
    Linux命令之乐--test
    Linux命令之乐--read
    shell脚本学习总结06--数学计算
    Linux命令之乐--time
    Linux命令之乐--expr
    Linux命令之乐--seq
    Linux命令之乐--rename
  • 原文地址:https://www.cnblogs.com/hyzhang/p/10685430.html
Copyright © 2011-2022 走看看