欢迎光临散文网 会员登陆 & 注册

App自动化测试(四)uiautomator定位元素

2022-07-16 21:35 作者:限量版范儿  | 我要投稿

uiautomator定位

  • 优点:uiautomator是Android工作引擎,速度快

  • 缺点:书写复杂,容易出错

driver.find_element_by_android_uiautomator("表达式").click()

  • newUiSelector().resourceId('id')

  • newUiSelector().className('clasename')

  • newUiSelector().description('content-desc')

  • newUiSelector().text('text')

  • newUiSelector().textContains('text')

  • newUiSelector().textStartWith('text')

  • newUiSelector().textMatches('正则表达式')

  • 组合定位

    • newUiSelector().resourceId('id').text('text')

    • newUiSelector().className('clasename').text('text')

  • 父子关系 childSelector

    • newUiSelector().resourceId('id').childSelector(text("text"))

  • 兄弟关系 fromParent

    • newUiSelector().resourceId('id').fromParent(text("text"))

  • 滚动查找元素
    driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrllIntoView(new UiSelector().text("文本").instance(0));')

来源:https://www.dianjilingqu.com/434208.html

App自动化测试(四)uiautomator定位元素的评论 (共 条)

分享到微博请遵守国家法律