UiAutomator2—By、BySelector

UiAutomator2—By、BySelector

By和BySelector所实现的功能相同,API也基本上相同,By是对BySelector的简化,官网是这样解释的:

By is a utility class which enables the creation of BySelectors in a concise manner.

Its primary function is to provide static factory methods for constructing BySelectors using a shortened syntax. For example, you would use findObject(By.text(“foo”)) rather than findObject(new BySelector().text(“foo”)) to select UI elements with the text value “foo”.

大意为:By是BySelector的一个实用类,By的主要功能是提供静态方法并使用简单的语法去构建BySelector进而进行控件的筛选。例如:
当你寻找一个text为foo的控件时,BySelector的写法为:

findObject(new BySelector().text(“foo”))

而By则可以对之进行简化,可以写为:

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值