By
public class By
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".
Summary
Nested types |
|---|
public class By.WindowThis nested class is used to create a |
Public methods |
|
|---|---|
static @NonNull BySelector |
checkable(boolean isCheckable)Constructs a new |
static @NonNull BySelector |
checked(boolean isChecked)Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
clickable(boolean isClickable)Constructs a new |
static @NonNull BySelector |
copy(@NonNull BySelector original)Constructs a new |
static @NonNull BySelector |
depth(int depth)Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
descContains(@NonNull String substring)Constructs a new |
static @NonNull BySelector |
descEndsWith(@NonNull String suffix)Constructs a new |
static @NonNull BySelector |
descStartsWith(@NonNull String prefix)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 30)Constructs a new |
static @NonNull BySelector |
enabled(boolean isEnabled)Constructs a new |
static @NonNull BySelector |
focusable(boolean isFocusable)Constructs a new |
static @NonNull BySelector |
focused(boolean isFocused)Constructs a new |
static @NonNull BySelector |
hasAncestor(@NonNull BySelector ancestorSelector)Constructs a new |
static @NonNull BySelector |
hasAncestor(Constructs a new |
static @NonNull BySelector |
hasChild(@NonNull BySelector childSelector)Constructs a new |
static @NonNull BySelector |
hasDescendant(@NonNull BySelector descendantSelector)Constructs a new |
static @NonNull BySelector |
hasDescendant(@NonNull BySelector descendantSelector, int maxDepth)Constructs a new |
static @NonNull BySelector |
hasParent(@NonNull BySelector parentSelector)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 26)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 26)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 26)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 26)Constructs a new |
static @NonNull BySelector |
@RequiresApi(value = 26)Constructs a new |
static @NonNull BySelector |
longClickable(boolean isLongClickable)Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
scrollable(boolean isScrollable)Constructs a new |
static @NonNull BySelector |
selected(boolean isSelected)Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
Constructs a new |
static @NonNull BySelector |
textContains(@NonNull String substring)Constructs a new |
static @NonNull BySelector |
textEndsWith(@NonNull String suffix)Constructs a new |
static @NonNull BySelector |
textStartsWith(@NonNull String prefix)Constructs a new |
Public methods
checkable
public static @NonNull BySelector checkable(boolean isCheckable)
Constructs a new BySelector and sets the checkable criteria.
| See also | |
|---|---|
checkable |
BySelector.checkable(boolean) |
checked
public static @NonNull BySelector checked(boolean isChecked)
Constructs a new BySelector and sets the checked criteria.
| See also | |
|---|---|
checked |
BySelector.checked(boolean) |
clazz
public static @NonNull BySelector clazz(@NonNull Pattern className)
Constructs a new BySelector and sets the class name criteria.
| See also | |
|---|---|
clazz |
BySelector.clazz(Pattern) |
clazz
public static @NonNull BySelector clazz(@NonNull String className)
Constructs a new BySelector and sets the class name criteria.
| See also | |
|---|---|
clazz |
BySelector.clazz(String) |
clazz
public static @NonNull BySelector clazz(@NonNull Class clazz)
Constructs a new BySelector and sets the class name criteria.
| See also | |
|---|---|
clazz |
BySelector.clazz(Class) |
clazz
public static @NonNull BySelector clazz(@NonNull String packageName, @NonNull String className)
Constructs a new BySelector and sets the class name criteria.
| See also | |
|---|---|
clazz |
BySelector.clazz(String, String) |
clickable
public static @NonNull BySelector clickable(boolean isClickable)
Constructs a new BySelector and sets the clickable criteria.
| See also | |
|---|---|
clickable |
BySelector.clickable(boolean) |
copy
public static @NonNull BySelector copy(@NonNull BySelector original)
Constructs a new BySelector and copies the criteria from original.
depth
public static @NonNull BySelector depth(int depth)
Constructs a new BySelector and sets the depth criteria.
desc
public static @NonNull BySelector desc(@NonNull Pattern contentDescription)
Constructs a new BySelector and sets the content description criteria.
| See also | |
|---|---|
desc |
BySelector.desc(Pattern) |
desc
public static @NonNull BySelector desc(@NonNull String contentDescription)
Constructs a new BySelector and sets the content description criteria.
| See also | |
|---|---|
desc |
BySelector.desc(String) |
descContains
public static @NonNull BySelector descContains(@NonNull String substring)
Constructs a new BySelector and sets the content description criteria.
| See also | |
|---|---|
descContains |
BySelector.descContains(String) |
descEndsWith
public static @NonNull BySelector descEndsWith(@NonNull String suffix)
Constructs a new BySelector and sets the content description criteria.
| See also | |
|---|---|
descEndsWith |
BySelector.descEndsWith(String) |
descStartsWith
public static @NonNull BySelector descStartsWith(@NonNull String prefix)
Constructs a new BySelector and sets the content description criteria.
| See also | |
|---|---|
descStartsWith |
BySelector.descStartsWith(String) |
displayId
@RequiresApi(value = 30)
public static @NonNull BySelector displayId(int displayId)
Constructs a new BySelector and sets the display ID criteria.
| See also | |
|---|---|
displayId |
BySelector.displayId(int) |
enabled
public static @NonNull BySelector enabled(boolean isEnabled)
Constructs a new BySelector and sets the enabled criteria.
| See also | |
|---|---|
enabled |
BySelector.enabled(boolean) |
focusable
public static @NonNull BySelector focusable(boolean isFocusable)
Constructs a new BySelector and sets the focusable criteria.
| See also | |
|---|---|
focusable |
BySelector.focusable(boolean) |
focused
public static @NonNull BySelector focused(boolean isFocused)
Constructs a new BySelector and sets the focused criteria.
| See also | |
|---|---|
focused |
BySelector.focused(boolean) |
hasAncestor
public static @NonNull BySelector hasAncestor(@NonNull BySelector ancestorSelector)
Constructs a new BySelector and adds an ancestor selector criteria.
| See also | |
|---|---|
hasAncestor |
BySelector.hasAncestor(BySelector) |
hasAncestor
public static @NonNull BySelector hasAncestor(
@NonNull BySelector ancestorSelector,
@IntRange(from = 1) int maxAncestorDistance
)
Constructs a new BySelector and adds an ancestor selector criteria.
| See also | |
|---|---|
hasAncestor |
BySelector.hasAncestor(BySelector, int) |
hasChild
public static @NonNull BySelector hasChild(@NonNull BySelector childSelector)
Constructs a new BySelector and adds a child selector criteria.
| See also | |
|---|---|
hasChild |
BySelector.hasChild(BySelector) |
hasDescendant
public static @NonNull BySelector hasDescendant(@NonNull BySelector descendantSelector)
Constructs a new BySelector and adds a descendant selector criteria.
| See also | |
|---|---|
hasDescendant |
BySelector.hasDescendant(BySelector) |
hasDescendant
public static @NonNull BySelector hasDescendant(@NonNull BySelector descendantSelector, int maxDepth)
Constructs a new BySelector and adds a descendant selector criteria.
| See also | |
|---|---|
hasDescendant |
BySelector.hasDescendant(BySelector, int) |
hasParent
public static @NonNull BySelector hasParent(@NonNull BySelector parentSelector)
Constructs a new BySelector and adds a parent selector criteria.
| See also | |
|---|---|
hasParent |
BySelector.hasParent(BySelector) |
hint
@RequiresApi(value = 26)
public static @NonNull BySelector hint(@NonNull String hint)
Constructs a new BySelector and sets the hint value criteria.
| See also | |
|---|---|
hint |
BySelector.hint(String) |
hint
@RequiresApi(value = 26)
public static @NonNull BySelector hint(@NonNull Pattern regex)
Constructs a new BySelector and sets the hint value criteria.
| See also | |
|---|---|
hint |
BySelector.hint(Pattern) |
hintContains
@RequiresApi(value = 26)
public static @NonNull BySelector hintContains(@NonNull String substring)
Constructs a new BySelector and sets the hint value criteria.
| See also | |
|---|---|
hintContains |
BySelector.hintContains(String) |
hintEndsWith
@RequiresApi(value = 26)
public static @NonNull BySelector hintEndsWith(@NonNull String suffix)
Constructs a new BySelector and sets the hint value criteria.
| See also | |
|---|---|
hintEndsWith |
BySelector.hintEndsWith(String) |
hintStartsWith
@RequiresApi(value = 26)
public static @NonNull BySelector hintStartsWith(@NonNull String prefix)
Constructs a new BySelector and sets the hint value criteria.
| See also | |
|---|---|
hintStartsWith |
BySelector.hintStartsWith(String) |
longClickable
public static @NonNull BySelector longClickable(boolean isLongClickable)
Constructs a new BySelector and sets the long clickable criteria.
| See also | |
|---|---|
longClickable |
BySelector.longClickable(boolean) |
pkg
public static @NonNull BySelector pkg(@NonNull Pattern applicationPackage)
Constructs a new BySelector and sets the application package name criteria.
| See also | |
|---|---|
pkg |
BySelector.pkg(Pattern) |
pkg
public static @NonNull BySelector pkg(@NonNull String applicationPackage)
Constructs a new BySelector and sets the application package name criteria.
| See also | |
|---|---|
pkg |
BySelector.pkg(String) |
res
public static @NonNull BySelector res(@NonNull Pattern resourceName)
Constructs a new BySelector and sets the resource id criteria.
| See also | |
|---|---|
res |
BySelector.res(Pattern) |
res
public static @NonNull BySelector res(@NonNull String resourceName)
Constructs a new BySelector and sets the resource name criteria.
| See also | |
|---|---|
res |
BySelector.res(String) |
res
public static @NonNull BySelector res(@NonNull String resourcePackage, @NonNull String resourceId)
Constructs a new BySelector and sets the resource name criteria.
| See also | |
|---|---|
res |
BySelector.res(String, String) |
scrollable
public static @NonNull BySelector scrollable(boolean isScrollable)
Constructs a new BySelector and sets the scrollable criteria.
| See also | |
|---|---|
scrollable |
BySelector.scrollable(boolean) |
selected
public static @NonNull BySelector selected(boolean isSelected)
Constructs a new BySelector and sets the selected criteria.
| See also | |
|---|---|
selected |
BySelector.selected(boolean) |
text
public static @NonNull BySelector text(@NonNull Pattern regex)
Constructs a new BySelector and sets the text value criteria.
| See also | |
|---|---|
text |
BySelector.text(Pattern) |
text
public static @NonNull BySelector text(@NonNull String text)
Constructs a new BySelector and sets the text value criteria.
| See also | |
|---|---|
text |
BySelector.text(String) |
textContains
public static @NonNull BySelector textContains(@NonNull String substring)
Constructs a new BySelector and sets the text value criteria.
| See also | |
|---|---|
textContains |
BySelector.textContains(String) |
textEndsWith
public static @NonNull BySelector textEndsWith(@NonNull String suffix)
Constructs a new BySelector and sets the text value criteria.
| See also | |
|---|---|
textEndsWith |
BySelector.textEndsWith(String) |
textStartsWith
public static @NonNull BySelector textStartsWith(@NonNull String prefix)
Constructs a new BySelector and sets the text value criteria.
| See also | |
|---|---|
textStartsWith |
BySelector.textStartsWith(String) |