public class BySelector
extends Object
| java.lang.Object | |
| ↳ | android.support.test.uiautomator.BySelector |
BySelector指定在调用 findObject(BySelector)期间匹配UI元素的标准。
Public methods |
|
|---|---|
BySelector |
checkable(boolean isCheckable) 设置搜索条件以匹配可检查或不可检查的元素。 |
BySelector |
checked(boolean isChecked) 设置搜索条件以匹配选中或取消选中的元素。 |
BySelector |
clazz(String packageName, String className) 设置匹配的类名称标准。 |
BySelector |
clazz(Class clazz) 设置匹配的类名称标准。 |
BySelector |
clazz(Pattern className) 设置匹配的类名称标准。 |
BySelector |
clazz(String className) 设置匹配的类名称标准。 |
BySelector |
clickable(boolean isClickable) 设置搜索条件以匹配可点击或不可点击的元素。 |
BySelector |
depth(int min, int max) 设置搜索条件以匹配深度范围内的元素。 |
BySelector |
depth(int exactDepth) 设置搜索条件以匹配特定深度的元素。 |
BySelector |
desc(String contentDescription) 设置匹配的内容描述标准。 |
BySelector |
desc(Pattern contentDescription) 设置匹配的内容描述标准。 |
BySelector |
descContains(String substring) 设置匹配的内容描述标准。 |
BySelector |
descEndsWith(String substring) 设置匹配的内容描述标准。 |
BySelector |
descStartsWith(String substring) 设置匹配的内容描述标准。 |
BySelector |
enabled(boolean isEnabled) 设置搜索条件以匹配启用或禁用的元素。 |
BySelector |
focusable(boolean isFocusable) 设置搜索条件以匹配可聚焦或不可聚焦的元素。 |
BySelector |
focused(boolean isFocused) 设置搜索条件以匹配聚焦或未聚焦的元素。 |
BySelector |
hasChild(BySelector childSelector) 添加用于匹配的子选择器条件。 |
BySelector |
hasDescendant(BySelector descendantSelector) 为匹配添加后代选择器条件。 |
BySelector |
hasDescendant(BySelector descendantSelector, int maxDepth) 为匹配添加后代选择器条件。 |
BySelector |
longClickable(boolean isLongClickable) 设置搜索条件以匹配可长时间点击或不可点击的元素。 |
BySelector |
maxDepth(int max) 设置搜索条件以匹配不超过特定深度的元素。 |
BySelector |
minDepth(int min) 设置搜索条件以匹配至少具有特定深度的元素。 |
BySelector |
pkg(Pattern applicationPackage) 设置匹配的包名称标准。 |
BySelector |
pkg(String applicationPackage) 设置匹配的应用程序包名称标准。 |
BySelector |
res(String resourceName) 设置匹配的资源名称标准。 |
BySelector |
res(String resourcePackage, String resourceId) 设置匹配的资源名称标准。 |
BySelector |
res(Pattern resourceName) 设置匹配的资源名称标准。 |
BySelector |
scrollable(boolean isScrollable) 设置搜索条件以匹配可滚动或不可滚动的元素。 |
BySelector |
selected(boolean isSelected) 设置搜索条件以匹配选中或未选中的元素。 |
BySelector |
text(Pattern textValue) 设置匹配的文本值标准。 |
BySelector |
text(String textValue) 设置匹配的文本值标准。 |
BySelector |
textContains(String substring) 设置匹配的文本值标准。 |
BySelector |
textEndsWith(String substring) 设置匹配的文本值标准。 |
BySelector |
textStartsWith(String substring) 设置匹配的文本值标准。 |
String |
toString() 返回此 |
Inherited methods |
|
|---|---|
java.lang.Object
|
|
BySelector checkable (boolean isCheckable)
设置搜索条件以匹配可检查或不可检查的元素。
| Parameters | |
|---|---|
isCheckable |
boolean: Whether to match elements that are checkable or elements that are not checkable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector checked (boolean isChecked)
设置搜索条件以匹配选中或取消选中的元素。
| Parameters | |
|---|---|
isChecked |
boolean: Whether to match elements that are checked or elements that are unchecked. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector clazz (String packageName, String className)
设置匹配的类名称标准。 如果UI元素的包名和类名与packageName和className参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
packageName |
String: The package value to match. |
className |
String: The class name value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector clazz (Class clazz)
设置匹配的类名称标准。 如果UI元素的类名称匹配clazz并且符合此选择器的所有其他条件,则UI元素将被视为匹配clazz 。
| Parameters | |
|---|---|
clazz |
Class: The class to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector |
BySelector clazz (Pattern className)
设置匹配的类名称标准。 如果UI元素的完整类名匹配className Pattern并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
className |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector clazz (String className)
设置匹配的类名称标准。 如果UI元素的类名与className参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。 如果className以className开头,则假定它位于android.widget包中。
| Parameters | |
|---|---|
className |
String: The full class name value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector clickable (boolean isClickable)
设置搜索条件以匹配可点击或不可点击的元素。
| Parameters | |
|---|---|
isClickable |
boolean: Whether to match elements that are clickable or elements that are not clickable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector depth (int min, int max)
设置搜索条件以匹配深度范围内的元素。
| Parameters | |
|---|---|
min |
int
|
max |
int
|
| Returns | |
|---|---|
BySelector |
|
BySelector depth (int exactDepth)
设置搜索条件以匹配特定深度的元素。
| Parameters | |
|---|---|
exactDepth |
int
|
| Returns | |
|---|---|
BySelector |
|
BySelector desc (String contentDescription)
设置匹配的内容描述标准。 如果UI元素的内容描述与contentDescription参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配。
| Parameters | |
|---|---|
contentDescription |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector desc (Pattern contentDescription)
设置匹配的内容描述标准。 如果UI元素的内容描述符合contentDescription Pattern并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
contentDescription |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector descContains (String substring)
设置匹配的内容描述标准。 如果UI元素的内容描述包含substring参数并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector descEndsWith (String substring)
设置匹配的内容描述标准。 如果UI元素的内容描述以substring参数结尾并且符合此选择器的所有其他条件,则UI元素将被视为匹配。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector descStartsWith (String substring)
设置匹配的内容描述标准。 如果UI元素的内容描述以substring参数开始,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector enabled (boolean isEnabled)
设置搜索条件以匹配启用或禁用的元素。
| Parameters | |
|---|---|
isEnabled |
boolean: Whether to match elements that are enabled or elements that are disabled. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector focusable (boolean isFocusable)
设置搜索条件以匹配可聚焦或不可聚焦的元素。
| Parameters | |
|---|---|
isFocusable |
boolean: Whether to match elements that are focusable or elements that are not focusable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector focused (boolean isFocused)
设置搜索条件以匹配聚焦或未聚焦的元素。
| Parameters | |
|---|---|
isFocused |
boolean: Whether to match elements that are focused or elements that are unfocused. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector hasChild (BySelector childSelector)
添加用于匹配的子选择器条件。 如果UI元素具有与childSelector匹配的子元素(直接后代)并且符合该选择器的所有其他条件,则UI元素将被视为匹配。 如果指定了多次,则必须为所有childSelector找到匹配childSelector 。
| Parameters | |
|---|---|
childSelector |
BySelector: The selector used to find a matching child element. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector hasDescendant (BySelector descendantSelector)
为匹配添加后代选择器条件。 如果UI元素具有匹配descendantSelector的后代元素并且符合该选择器的所有其他条件,则UI元素将被视为匹配。 如果指定了多次,则必须为所有descendantSelector找到匹配descendantSelector 。
| Parameters | |
|---|---|
descendantSelector |
BySelector: The selector used to find a matching descendant element. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector hasDescendant (BySelector descendantSelector, int maxDepth)
为匹配添加后代选择器条件。 如果UI元素具有与descendantSelector相匹配的后代元素,并且符合该选择器的所有其他条件,则UI元素将被视为匹配。 如果指定了多次,则必须为所有descendantSelector找到匹配descendantSelector 。
| Parameters | |
|---|---|
descendantSelector |
BySelector: The selector used to find a matching descendant element. |
maxDepth |
int: The maximum depth under the element to search the descendant. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector longClickable (boolean isLongClickable)
设置搜索条件以匹配可长时间点击或不可点击的元素。
| Parameters | |
|---|---|
isLongClickable |
boolean: Whether to match elements that are long clickable or elements that are not long clickable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector pkg (Pattern applicationPackage)
设置匹配的包名称标准。 如果UI元素的应用程序包名称与applicationPackage Pattern匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
applicationPackage |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector pkg (String applicationPackage)
设置匹配的应用程序包名称标准。 如果UI元素的应用程序包名称与applicationPackage参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
applicationPackage |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector res (String resourceName)
设置匹配的资源名称标准。 如果UI元素的资源名称与resourceName参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
resourceName |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector res (String resourcePackage, String resourceId)
设置匹配的资源名称标准。 如果UI元素的资源包和资源ID完全匹配resourcePackage和resourceId参数并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
resourcePackage |
String: The resource package value to match. |
resourceId |
String: The resouce-id value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector res (Pattern resourceName)
设置匹配的资源名称标准。 如果UI元素的资源名称与resourceName Pattern匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
resourceName |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector scrollable (boolean isScrollable)
设置搜索条件以匹配可滚动或不可滚动的元素。
| Parameters | |
|---|---|
isScrollable |
boolean: Whether to match elements that are scrollable or elements that are not scrollable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector selected (boolean isSelected)
设置搜索条件以匹配选中或未选中的元素。
| Parameters | |
|---|---|
isSelected |
boolean: Whether to match elements that are selected or elements that are not selected. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector text (Pattern textValue)
设置匹配的文本值标准。 如果UI元素的文本值匹配textValue Pattern并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
textValue |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector text (String textValue)
设置匹配的文本值标准。 如果UI元素的文本值与textValue参数完全匹配,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
textValue |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector textContains (String substring)
设置匹配的文本值标准。 如果UI元素的文本值包含substring参数并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector textEndsWith (String substring)
设置匹配的文本值标准。 如果UI元素的文本值以substring参数结尾,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
BySelector textStartsWith (String substring)
设置匹配的文本值标准。 如果UI元素的文本值以substring参数开头,并且符合此选择器的所有其他条件,则UI元素将被视为匹配项。
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector. |
String toString ()
返回此BySelector的String表示BySelector 。 格式是“BySelector [<KEY> ='<VALUE> ...]”。 每个标准被列为一个键值对,其中键是所有大写表示的标准名称(例如CLAZZ,RES等)。
| Returns | |
|---|---|
String |
|