本文主要是介绍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则可以对之进行简化,可以写为:
这篇关于UiAutomator2—By、BySelector的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!