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

java-static fun checkable(isCheckable: Boolean): BySelector

Constructs a new BySelector and sets the checkable criteria.

See also
checkable

BySelector.checkable(boolean)

checked

java-static fun checked(isChecked: Boolean): BySelector

Constructs a new BySelector and sets the checked criteria.

See also
checked

BySelector.checked(boolean)

clazz

java-static fun clazz(className: Pattern): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(Pattern)

clazz

java-static fun clazz(className: String): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(String)

clazz

java-static fun clazz(clazz: Class): BySelector

Constructs a new BySelector and sets the class name criteria.

See also
clazz

BySelector.clazz(Class)

clazz

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

java-static fun clickable(isClickable: Boolean): BySelector

Constructs a new BySelector and sets the clickable criteria.

See also
clickable

BySelector.clickable(boolean)

copy

java-static fun copy(original: BySelector): BySelector

Constructs a new BySelector and copies the criteria from original.

depth

java-static fun depth(depth: Int): BySelector

Constructs a new BySelector and sets the depth criteria.

desc

java-static fun desc(contentDescription: Pattern): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
desc

BySelector.desc(Pattern)

desc

java-static fun desc(contentDescription: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
desc

BySelector.desc(String)

descContains

java-static fun descContains(substring: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descContains

BySelector.descContains(String)

descEndsWith

java-static fun descEndsWith(suffix: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descEndsWith

BySelector.descEndsWith(String)

descStartsWith

java-static fun descStartsWith(prefix: String): BySelector

Constructs a new BySelector and sets the content description criteria.

See also
descStartsWith

BySelector.descStartsWith(String)

displayId

@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

java-static fun enabled(isEnabled: Boolean): BySelector

Constructs a new BySelector and sets the enabled criteria.

See also
enabled

BySelector.enabled(boolean)

focusable

java-static fun focusable(isFocusable: Boolean): BySelector

Constructs a new BySelector and sets the focusable criteria.

See also
focusable

BySelector.focusable(boolean)

focused

java-static fun focused(isFocused: Boolean): BySelector

Constructs a new BySelector and sets the focused criteria.

See also
focused

BySelector.focused(boolean)

hasAncestor

java-static fun hasAncestor(ancestorSelector: BySelector): BySelector

Constructs a new BySelector and adds an ancestor selector criteria.

See also
hasAncestor

BySelector.hasAncestor(BySelector)

hasAncestor

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

java-static fun hasChild(childSelector: BySelector): BySelector

Constructs a new BySelector and adds a child selector criteria.

See also
hasChild

BySelector.hasChild(BySelector)

hasDescendant

java-static fun hasDescendant(descendantSelector: BySelector): BySelector

Constructs a new BySelector and adds a descendant selector criteria.

See also
hasDescendant

BySelector.hasDescendant(BySelector)

hasDescendant

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

java-static fun hasParent(parentSelector: BySelector): BySelector

Constructs a new BySelector and adds a parent selector criteria.

See also
hasParent

BySelector.hasParent(BySelector)

hint

@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

@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

@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

@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

@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

java-static fun longClickable(isLongClickable: Boolean): BySelector

Constructs a new BySelector and sets the long clickable criteria.

See also
longClickable

BySelector.longClickable(boolean)

pkg

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

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

java-static fun res(resourceName: Pattern): BySelector

Constructs a new BySelector and sets the resource id criteria.

See also
res

BySelector.res(Pattern)

res

java-static fun res(resourceName: String): BySelector

Constructs a new BySelector and sets the resource name criteria.

See also
res

BySelector.res(String)

res

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

java-static fun scrollable(isScrollable: Boolean): BySelector

Constructs a new BySelector and sets the scrollable criteria.

See also
scrollable

BySelector.scrollable(boolean)

selected

java-static fun selected(isSelected: Boolean): BySelector

Constructs a new BySelector and sets the selected criteria.

See also
selected

BySelector.selected(boolean)

text

java-static fun text(regex: Pattern): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
text

BySelector.text(Pattern)

text

java-static fun text(text: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
text

BySelector.text(String)

textContains

java-static fun textContains(substring: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textContains

BySelector.textContains(String)

textEndsWith

java-static fun textEndsWith(suffix: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textEndsWith

BySelector.textEndsWith(String)

textStartsWith

java-static fun textStartsWith(prefix: String): BySelector

Constructs a new BySelector and sets the text value criteria.

See also
textStartsWith

BySelector.textStartsWith(String)