BySelector
public
class
BySelector
extends Object
| java.lang.Object | |
| ↳ | android.support.test.uiautomator.BySelector |
A BySelector specifies criteria for matching UI elements during a call to
findObject(BySelector).
Summary
Public methods | |
|---|---|
BySelector
|
checkable(boolean isCheckable)
Sets the search criteria to match elements that are checkable or not checkable. |
BySelector
|
checked(boolean isChecked)
Sets the search criteria to match elements that are checked or unchecked. |
BySelector
|
clazz(String packageName, String className)
Sets the class name criteria for matching. |
BySelector
|
clazz(Class clazz)
Sets the class name criteria for matching. |
BySelector
|
clazz(Pattern className)
Sets the class name criteria for matching. |
BySelector
|
clazz(String className)
Sets the class name criteria for matching. |
BySelector
|
clickable(boolean isClickable)
Sets the search criteria to match elements that are clickable or not clickable. |
BySelector
|
depth(int min, int max)
Sets the search criteria to match elements that are in a range of depths. |
BySelector
|
depth(int exactDepth)
Sets the search criteria to match elements that are at a certain depth. |
BySelector
|
desc(String contentDescription)
Sets the content description criteria for matching. |
BySelector
|
desc(Pattern contentDescription)
Sets the content description criteria for matching. |
BySelector
|
descContains(String substring)
Sets the content description criteria for matching. |
BySelector
|
descEndsWith(String substring)
Sets the content description criteria for matching. |
BySelector
|
descStartsWith(String substring)
Sets the content description criteria for matching. |
BySelector
|
enabled(boolean isEnabled)
Sets the search criteria to match elements that are enabled or disabled. |
BySelector
|
focusable(boolean isFocusable)
Sets the search criteria to match elements that are focusable or not focusable. |
BySelector
|
focused(boolean isFocused)
Sets the search criteria to match elements that are focused or unfocused. |
BySelector
|
hasChild(BySelector childSelector)
Adds a child selector criteria for matching. |
BySelector
|
hasDescendant(BySelector descendantSelector)
Adds a descendant selector criteria for matching. |
BySelector
|
hasDescendant(BySelector descendantSelector, int maxDepth)
Adds a descendant selector criteria for matching. |
BySelector
|
longClickable(boolean isLongClickable)
Sets the search criteria to match elements that are long clickable or not long clickable. |
BySelector
|
maxDepth(int max)
Sets the search criteria to match elements that are no more than a certain depth. |
BySelector
|
minDepth(int min)
Sets the search criteria to match elements that are at least a certain depth. |
BySelector
|
pkg(Pattern applicationPackage)
Sets the package name criteria for matching. |
BySelector
|
pkg(String applicationPackage)
Sets the application package name criteria for matching. |
BySelector
|
res(String resourceName)
Sets the resource name criteria for matching. |
BySelector
|
res(String resourcePackage, String resourceId)
Sets the resource name criteria for matching. |
BySelector
|
res(Pattern resourceName)
Sets the resource name criteria for matching. |
BySelector
|
scrollable(boolean isScrollable)
Sets the search criteria to match elements that are scrollable or not scrollable. |
BySelector
|
selected(boolean isSelected)
Sets the search criteria to match elements that are selected or not selected. |
BySelector
|
text(Pattern textValue)
Sets the text value criteria for matching. |
BySelector
|
text(String textValue)
Sets the text value criteria for matching. |
BySelector
|
textContains(String substring)
Sets the text value criteria for matching. |
BySelector
|
textEndsWith(String substring)
Sets the text value criteria for matching. |
BySelector
|
textStartsWith(String substring)
Sets the text value criteria for matching. |
String
|
toString()
Returns a |
Inherited methods | |
|---|---|
java.lang.Object
| |
Public methods
checkable
BySelector checkable (boolean isCheckable)
Sets the search criteria to match elements that are checkable or not checkable.
| Parameters | |
|---|---|
isCheckable |
boolean: Whether to match elements that are checkable or elements that are not
checkable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
checked
BySelector checked (boolean isChecked)
Sets the search criteria to match elements that are checked or unchecked.
| Parameters | |
|---|---|
isChecked |
boolean: Whether to match elements that are checked or elements that are unchecked. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
clazz
BySelector clazz (String packageName, String className)
Sets the class name criteria for matching. A UI element will be considered a match if its
package and class name exactly match the packageName and className parameters
and all other criteria for this selector are met.
| Parameters | |
|---|---|
packageName |
String: The package value to match. |
className |
String: The class name value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
clazz
BySelector clazz (Class clazz)
Sets the class name criteria for matching. A UI element will be considered a match if its
class name matches clazz and all other criteria for this selector are met.
| Parameters | |
|---|---|
clazz |
Class: The class to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector
|
clazz
BySelector clazz (Pattern className)
Sets the class name criteria for matching. A UI element will be considered a match if its
full class name matches the className Pattern and all other criteria for this
selector are met.
| Parameters | |
|---|---|
className |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
clazz
BySelector clazz (String className)
Sets the class name criteria for matching. A UI element will be considered a match if its
class name exactly matches the className parameter and all other criteria for
this selector are met. If className starts with a period, it is assumed to be in the
android.widget package.
| Parameters | |
|---|---|
className |
String: The full class name value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
clickable
BySelector clickable (boolean isClickable)
Sets the search criteria to match elements that are clickable or not clickable.
| Parameters | |
|---|---|
isClickable |
boolean: Whether to match elements that are clickable or elements that are not
clickable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
depth
BySelector depth (int min, int max)
Sets the search criteria to match elements that are in a range of depths.
| Parameters | |
|---|---|
min |
int |
max |
int |
| Returns | |
|---|---|
BySelector |
|
depth
BySelector depth (int exactDepth)
Sets the search criteria to match elements that are at a certain depth.
| Parameters | |
|---|---|
exactDepth |
int |
| Returns | |
|---|---|
BySelector |
|
desc
BySelector desc (String contentDescription)
Sets the content description criteria for matching. A UI element will be considered a match
if its content description exactly matches the contentDescription parameter and all
other criteria for this selector are met.
| Parameters | |
|---|---|
contentDescription |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
desc
BySelector desc (Pattern contentDescription)
Sets the content description criteria for matching. A UI element will be considered a match
if its content description matches the contentDescription Pattern and all
other criteria for this selector are met.
| Parameters | |
|---|---|
contentDescription |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
descContains
BySelector descContains (String substring)
Sets the content description criteria for matching. A UI element will be considered a match
if its content description contains the substring parameter and all other criteria
for this selector are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
descEndsWith
BySelector descEndsWith (String substring)
Sets the content description criteria for matching. A UI element will be considered a match
if its content description ends with the substring parameter and all other criteria
for this selector are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
descStartsWith
BySelector descStartsWith (String substring)
Sets the content description criteria for matching. A UI element will be considered a match
if its content description starts with the substring parameter and all other criteria
for this selector are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
enabled
BySelector enabled (boolean isEnabled)
Sets the search criteria to match elements that are enabled or disabled.
| Parameters | |
|---|---|
isEnabled |
boolean: Whether to match elements that are enabled or elements that are disabled. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
focusable
BySelector focusable (boolean isFocusable)
Sets the search criteria to match elements that are focusable or not focusable.
| Parameters | |
|---|---|
isFocusable |
boolean: Whether to match elements that are focusable or elements that are not
focusable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
focused
BySelector focused (boolean isFocused)
Sets the search criteria to match elements that are focused or unfocused.
| Parameters | |
|---|---|
isFocused |
boolean: Whether to match elements that are focused or elements that are unfocused. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
hasChild
BySelector hasChild (BySelector childSelector)
Adds a child selector criteria for matching. A UI element will be considered a match if it
has a child element (direct descendant) which matches the childSelector and all
other criteria for this selector are met. If specified more than once, matches must be found
for all childSelectors.
| Parameters | |
|---|---|
childSelector |
BySelector: The selector used to find a matching child element. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
hasDescendant
BySelector hasDescendant (BySelector descendantSelector)
Adds a descendant selector criteria for matching. A UI element will be considered a match if
it has a descendant element which matches the descendantSelector and all other
criteria for this selector are met. If specified more than once, matches must be found for
all descendantSelectors.
| Parameters | |
|---|---|
descendantSelector |
BySelector: The selector used to find a matching descendant element. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
hasDescendant
BySelector hasDescendant (BySelector descendantSelector, int maxDepth)
Adds a descendant selector criteria for matching. A UI element will be considered a match if
it has a descendant element which matches the descendantSelector and all other
criteria for this selector are met. If specified more than once, matches must be found for
all descendantSelectors.
| 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.
|
longClickable
BySelector longClickable (boolean isLongClickable)
Sets the search criteria to match elements that are long clickable or not long clickable.
| 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.
|
maxDepth
BySelector maxDepth (int max)
Sets the search criteria to match elements that are no more than a certain depth.
| Parameters | |
|---|---|
max |
int |
| Returns | |
|---|---|
BySelector |
|
minDepth
BySelector minDepth (int min)
Sets the search criteria to match elements that are at least a certain depth.
| Parameters | |
|---|---|
min |
int |
| Returns | |
|---|---|
BySelector |
|
pkg
BySelector pkg (Pattern applicationPackage)
Sets the package name criteria for matching. A UI element will be considered a match if its
application package name matches the applicationPackage Pattern and all other
criteria for this selector are met.
| Parameters | |
|---|---|
applicationPackage |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
pkg
BySelector pkg (String applicationPackage)
Sets the application package name criteria for matching. A UI element will be considered a
match if its application package name exactly matches the applicationPackage
parameter and all other criteria for this selector are met.
| Parameters | |
|---|---|
applicationPackage |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
res
BySelector res (String resourceName)
Sets the resource name criteria for matching. A UI element will be considered a match if its
resource name exactly matches the resourceName parameter and all other criteria for
this selector are met.
| Parameters | |
|---|---|
resourceName |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
res
BySelector res (String resourcePackage, String resourceId)
Sets the resource name criteria for matching. A UI element will be considered a match if its
resource package and resource id exactly match the resourcePackage and
resourceId parameters and all other criteria for this selector are met.
| Parameters | |
|---|---|
resourcePackage |
String: The resource package value to match. |
resourceId |
String: The resouce-id value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
res
BySelector res (Pattern resourceName)
Sets the resource name criteria for matching. A UI element will be considered a match if its
resource name matches the resourceName Pattern and all other criteria for
this selector are met.
| Parameters | |
|---|---|
resourceName |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
scrollable
BySelector scrollable (boolean isScrollable)
Sets the search criteria to match elements that are scrollable or not scrollable.
| Parameters | |
|---|---|
isScrollable |
boolean: Whether to match elements that are scrollable or elements that are not
scrollable. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
selected
BySelector selected (boolean isSelected)
Sets the search criteria to match elements that are selected or not selected.
| Parameters | |
|---|---|
isSelected |
boolean: Whether to match elements that are selected or elements that are not
selected. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
text
BySelector text (Pattern textValue)
Sets the text value criteria for matching. A UI element will be considered a match if its
text value matches the textValue Pattern and all other criteria for this
selector are met.
| Parameters | |
|---|---|
textValue |
Pattern: The Pattern to be used for matching. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
text
BySelector text (String textValue)
Sets the text value criteria for matching. A UI element will be considered a match if its
text value exactly matches the textValue parameter and all other criteria for this
selector are met.
| Parameters | |
|---|---|
textValue |
String: The exact value to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
textContains
BySelector textContains (String substring)
Sets the text value criteria for matching. A UI element will be considered a match if its
text value contains the substring parameter and all other criteria for this selector
are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
textEndsWith
BySelector textEndsWith (String substring)
Sets the text value criteria for matching. A UI element will be considered a match if its
text value ends with the substring parameter and all other criteria for this selector
are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
textStartsWith
BySelector textStartsWith (String substring)
Sets the text value criteria for matching. A UI element will be considered a match if its
text value starts with the substring parameter and all other criteria for this
selector are met.
| Parameters | |
|---|---|
substring |
String: The substring to match. |
| Returns | |
|---|---|
BySelector |
A reference to this BySelector.
|
toString
String toString ()
Returns a String representation of this BySelector. The format is
"BySelector [<KEY>='<VALUE> ... ]". Each criteria is listed as a key-value pair
where the key is the name of the criteria expressed in all caps (e.g. CLAZZ, RES, etc).
| Returns | |
|---|---|
String |
|
Interfaces
Classes
Enums
Exceptions