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

Public functions

java-static BySelector
checkable(isCheckable: Boolean)

Constructs a new BySelector and sets the checkable criteria.

java-static BySelector
checked(isChecked: Boolean)

Constructs a new BySelector and sets the checked criteria.

java-static BySelector
clazz(className: Pattern)

Constructs a new BySelector and sets the class name criteria.

java-static BySelector
clazz(className: String)

Constructs a new BySelector and sets the class name criteria.

java-static BySelector
clazz(clazz: Class)

Constructs a new BySelector and sets the class name criteria.

java-static BySelector
clazz(packageName: String, className: String)

Constructs a new BySelector and sets the class name criteria.

java-static BySelector
clickable(isClickable: Boolean)

Constructs a new BySelector and sets the clickable criteria.

java-static BySelector
copy(original: BySelector)

Constructs a new BySelector and copies the criteria from original.

java-static BySelector
depth(depth: Int)

Constructs a new BySelector and sets the depth criteria.

java-static BySelector
desc(contentDescription: Pattern)

Constructs a new BySelector and sets the content description criteria.

java-static BySelector
desc(contentDescription: String)

Constructs a new BySelector and sets the content description criteria.

java-static BySelector
descContains(substring: String)

Constructs a new BySelector and sets the content description criteria.

java-static BySelector

Constructs a new BySelector and sets the content description criteria.

java-static BySelector

Constructs a new BySelector and sets the content description criteria.

java-static BySelector
@RequiresApi(value = 30)
displayId(displayId: Int)

Constructs a new BySelector and sets the display ID criteria.

java-static BySelector
enabled(isEnabled: Boolean)

Constructs a new BySelector and sets the enabled criteria.

java-static BySelector
focusable(isFocusable: Boolean)

Constructs a new BySelector and sets the focusable criteria.

java-static BySelector
focused(isFocused: Boolean)

Constructs a new BySelector and sets the focused criteria.

java-static BySelector
hasAncestor(ancestorSelector: BySelector)

Constructs a new BySelector and adds an ancestor selector criteria.

java-static BySelector
hasAncestor(
    ancestorSelector: BySelector,
    maxAncestorDistance: @IntRange(from = 1) Int
)

Constructs a new BySelector and adds an ancestor selector criteria.

java-static BySelector
hasChild(childSelector: BySelector)

Constructs a new BySelector and adds a child selector criteria.

java-static BySelector
hasDescendant(descendantSelector: BySelector)

Constructs a new BySelector and adds a descendant selector criteria.

java-static BySelector
hasDescendant(descendantSelector: BySelector, maxDepth: Int)

Constructs a new BySelector and adds a descendant selector criteria.

java-static BySelector
hasParent(parentSelector: BySelector)

Constructs a new BySelector and adds a parent selector criteria.

java-static BySelector
@RequiresApi(value = 26)
hint(hint: String)

Constructs a new BySelector and sets the hint value criteria.

java-static BySelector
@RequiresApi(value = 26)
hint(regex: Pattern)

Constructs a new BySelector and sets the hint value criteria.

java-static BySelector
@RequiresApi(value = 26)
hintContains(substring: String)

Constructs a new BySelector and sets the hint value criteria.

java-static BySelector
@RequiresApi(value = 26)
hintEndsWith(suffix: String)

Constructs a new BySelector and sets the hint value criteria.

java-static BySelector
@RequiresApi(value = 26)
hintStartsWith(prefix: String)

Constructs a new BySelector and sets the hint value criteria.

java-static BySelector
longClickable(isLongClickable: Boolean)

Constructs a new BySelector and sets the long clickable criteria.

java-static BySelector
pkg(applicationPackage: Pattern)

Constructs a new BySelector and sets the application package name criteria.

java-static BySelector
pkg(applicationPackage: String)

Constructs a new BySelector and sets the application package name criteria.

java-static BySelector
res(resourceName: Pattern)

Constructs a new BySelector and sets the resource id criteria.

java-static BySelector
res(resourceName: String)

Constructs a new BySelector and sets the resource name criteria.

java-static BySelector
res(resourcePackage: String, resourceId: String)

Constructs a new BySelector and sets the resource name criteria.

java-static BySelector
scrollable(isScrollable: Boolean)

Constructs a new BySelector and sets the scrollable criteria.

java-static BySelector
selected(isSelected: Boolean)

Constructs a new BySelector and sets the selected criteria.

java-static BySelector
text(regex: Pattern)

Constructs a new BySelector and sets the text value criteria.

java-static BySelector
text(text: String)

Constructs a new BySelector and sets the text value criteria.

java-static BySelector
textContains(substring: String)

Constructs a new BySelector and sets the text value criteria.

java-static BySelector

Constructs a new BySelector and sets the text value criteria.

java-static BySelector

Constructs a new BySelector and sets the text value criteria.

Public functions

checkable

Added in 2.2.0
java-static fun checkable(isCheckable: Boolean): BySelector

Constructs a new BySelector and sets the checkable criteria.

See also
checkable

BySelector.checkable(boolean)

checked

Added in 2.2.0
java-static fun checked(isChecked: Boolean): BySelector

Constructs a new BySelector and sets the checked criteria.

See also
checked

BySelector.checked(boolean)

clazz

Added in 2.2.0
java-static fun clazz(className: Pattern): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(Pattern)

clazz

Added in 2.2.0
java-static fun clazz(className: String): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(String)

clazz

Added in 2.2.0
java-static fun clazz(clazz: Class): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(Class)

clazz

Added in 2.2.0
java-static fun clazz(packageName: String, className: String): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(String, String)

clickable

Added in 2.2.0
java-static fun clickable(isClickable: Boolean): BySelector

Constructs a new BySelector and sets the clickable criteria.

See also
clickable

BySelector.clickable(boolean)

copy

Added in 2.2.0
java-static fun copy(original: BySelector): BySelector

Constructs a new BySelector and copies the criteria from original.

depth

Added in 2.2.0
java-static fun depth(depth: Int): BySelector

Constructs a new BySelector and sets the depth criteria.

desc

Added in 2.2.0
java-static fun desc(contentDescription: Pattern): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
desc

BySelector.desc(Pattern)

desc

Added in 2.2.0
java-static fun desc(contentDescription: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
desc

BySelector.desc(String)

descContains

Added in 2.2.0
java-static fun descContains(substring: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descContains

BySelector.descContains(String)

descEndsWith

Added in 2.2.0
java-static fun descEndsWith(suffix: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descEndsWith

BySelector.descEndsWith(String)

descStartsWith

Added in 2.2.0
java-static fun descStartsWith(prefix: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descStartsWith

BySelector.descStartsWith(String)

displayId

Added in 2.3.0
@RequiresApi(value = 30)
java-static fun displayId(displayId: Int): BySelector

Constructs a new BySelector and sets the display ID criteria.

See also
displayId

BySelector.displayId(int)

enabled

Added in 2.2.0
java-static fun enabled(isEnabled: Boolean): BySelector

Constructs a new BySelector and sets the enabled criteria.

See also
enabled

BySelector.enabled(boolean)

focusable

Added in 2.2.0
java-static fun focusable(isFocusable: Boolean): BySelector

Constructs a new BySelector and sets the focusable criteria.

See also
focusable

BySelector.focusable(boolean)

focused

Added in 2.2.0
java-static fun focused(isFocused: Boolean): BySelector

Constructs a new BySelector and sets the focused criteria.

See also
focused

BySelector.focused(boolean)

hasAncestor

Added in 2.3.0
java-static fun hasAncestor(ancestorSelector: BySelector): BySelector

Constructs a new BySelector and adds an ancestor selector criteria.

See also
hasAncestor

BySelector.hasAncestor(BySelector)

hasAncestor

Added in 2.3.0
java-static fun hasAncestor(
    ancestorSelector: BySelector,
    maxAncestorDistance: @IntRange(from = 1) Int
): BySelector

Constructs a new BySelector and adds an ancestor selector criteria.

See also
hasAncestor

BySelector.hasAncestor(BySelector, int)

hasChild

Added in 2.2.0
java-static fun hasChild(childSelector: BySelector): BySelector

Constructs a new BySelector and adds a child selector criteria.

See also
hasChild

BySelector.hasChild(BySelector)

hasDescendant

Added in 2.2.0
java-static fun hasDescendant(descendantSelector: BySelector): BySelector

Constructs a new BySelector and adds a descendant selector criteria.

See also
hasDescendant

BySelector.hasDescendant(BySelector)

hasDescendant

Added in 2.2.0
java-static fun hasDescendant(descendantSelector: BySelector, maxDepth: Int): BySelector

Constructs a new BySelector and adds a descendant selector criteria.

See also
hasDescendant

BySelector.hasDescendant(BySelector, int)

hasParent

Added in 2.3.0
java-static fun hasParent(parentSelector: BySelector): BySelector

Constructs a new BySelector and adds a parent selector criteria.

See also
hasParent

BySelector.hasParent(BySelector)

hint

Added in 2.3.0
@RequiresApi(value = 26)
java-static fun hint(hint: String): BySelector

Constructs a new BySelector and sets the hint value criteria.

See also
hint

BySelector.hint(String)

hint

Added in 2.3.0
@RequiresApi(value = 26)
java-static fun hint(regex: Pattern): BySelector

Constructs a new BySelector and sets the hint value criteria.

See also
hint

BySelector.hint(Pattern)

hintContains

Added in 2.3.0
@RequiresApi(value = 26)
java-static fun hintContains(substring: String): BySelector

Constructs a new BySelector and sets the hint value criteria.

See also
hintContains

BySelector.hintContains(String)

hintEndsWith

Added in 2.3.0
@RequiresApi(value = 26)
java-static fun hintEndsWith(suffix: String): BySelector

Constructs a new BySelector and sets the hint value criteria.

See also
hintEndsWith

BySelector.hintEndsWith(String)

hintStartsWith

Added in 2.3.0
@RequiresApi(value = 26)
java-static fun hintStartsWith(prefix: String): BySelector

Constructs a new BySelector and sets the hint value criteria.

See also
hintStartsWith

BySelector.hintStartsWith(String)

longClickable

Added in 2.2.0
java-static fun longClickable(isLongClickable: Boolean): BySelector

Constructs a new BySelector and sets the long clickable criteria.

See also
longClickable

BySelector.longClickable(boolean)

pkg

Added in 2.2.0
java-static fun pkg(applicationPackage: Pattern): BySelector

Constructs a new BySelector and sets the application package name criteria.

See also
pkg

BySelector.pkg(Pattern)

pkg

Added in 2.2.0
java-static fun pkg(applicationPackage: String): BySelector

Constructs a new BySelector and sets the application package name criteria.

See also
pkg

BySelector.pkg(String)

res

Added in 2.2.0
java-static fun res(resourceName: Pattern): BySelector

Constructs a new BySelector and sets the resource id criteria.

See also
res

BySelector.res(Pattern)

res

Added in 2.2.0
java-static fun res(resourceName: String): BySelector

Constructs a new BySelector and sets the resource name criteria.

See also
res

BySelector.res(String)

res

Added in 2.2.0
java-static fun res(resourcePackage: String, resourceId: String): BySelector

Constructs a new BySelector and sets the resource name criteria.

See also
res

BySelector.res(String, String)

scrollable

Added in 2.2.0
java-static fun scrollable(isScrollable: Boolean): BySelector

Constructs a new BySelector and sets the scrollable criteria.

See also
scrollable

BySelector.scrollable(boolean)

selected

Added in 2.2.0
java-static fun selected(isSelected: Boolean): BySelector

Constructs a new BySelector and sets the selected criteria.

See also
selected

BySelector.selected(boolean)

text

Added in 2.2.0
java-static fun text(regex: Pattern): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
text

BySelector.text(Pattern)

text

Added in 2.2.0
java-static fun text(text: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
text

BySelector.text(String)

textContains

Added in 2.2.0
java-static fun textContains(substring: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textContains

BySelector.textContains(String)

textEndsWith

Added in 2.2.0
java-static fun textEndsWith(suffix: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textEndsWith

BySelector.textEndsWith(String)

textStartsWith

Added in 2.2.0
java-static fun textStartsWith(prefix: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textStartsWith

BySelector.textStartsWith(String)