By

public class By
extends Object

java.lang.Object
   ↳ android.support.test.uiautomator.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 methods

static BySelector checkable(boolean isCheckable)

Constructs a new BySelector and sets the checkable criteria.

static BySelector checked(boolean isChecked)

Constructs a new BySelector and sets the checked criteria.

static BySelector clazz(String packageName, String className)

Constructs a new BySelector and sets the class name criteria.

static BySelector clazz(Class clazz)

Constructs a new BySelector and sets the class name criteria.

static BySelector clazz(Pattern className)

Constructs a new BySelector and sets the class name criteria.

static BySelector clazz(String className)

Constructs a new BySelector and sets the class name criteria.

static BySelector clickable(boolean isClickable)

Constructs a new BySelector and sets the clickable criteria.

static BySelector copy(BySelector original)

Constructs a new BySelector and copies the criteria from original.

static BySelector depth(int depth)

Constructs a new BySelector and sets the depth criteria.

static BySelector desc(String contentDescription)

Constructs a new BySelector and sets the content description criteria.

static BySelector desc(Pattern contentDescription)

Constructs a new BySelector and sets the content description criteria.

static BySelector descContains(String substring)

Constructs a new BySelector and sets the content description criteria.

static BySelector descEndsWith(String substring)

Constructs a new BySelector and sets the content description criteria.

static BySelector descStartsWith(String substring)

Constructs a new BySelector and sets the content description criteria.

static BySelector enabled(boolean isEnabled)

Constructs a new BySelector and sets the enabled criteria.

static BySelector focusable(boolean isFocusable)

Constructs a new BySelector and sets the focusable criteria.

static BySelector focused(boolean isFocused)

Constructs a new BySelector and sets the focused criteria.

static BySelector hasChild(BySelector childSelector)

Constructs a new BySelector and adds a child selector criteria.

static BySelector hasDescendant(BySelector descendantSelector)

Constructs a new BySelector and adds a descendant selector criteria.

static BySelector hasDescendant(BySelector descendantSelector, int maxDepth)

Constructs a new BySelector and adds a descendant selector criteria.

static BySelector longClickable(boolean isLongClickable)

Constructs a new BySelector and sets the long clickable criteria.

static BySelector pkg(Pattern applicationPackage)

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

static BySelector pkg(String applicationPackage)

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

static BySelector res(String resourceName)

Constructs a new BySelector and sets the resource name criteria.

static BySelector res(String resourcePackage, String resourceId)

Constructs a new BySelector and sets the resource name criteria.

static BySelector res(Pattern resourceName)

Constructs a new BySelector and sets the resource id criteria.

static BySelector scrollable(boolean isScrollable)

Constructs a new BySelector and sets the scrollable criteria.

static BySelector selected(boolean isSelected)

Constructs a new BySelector and sets the selected criteria.

static BySelector text(Pattern regex)

Constructs a new BySelector and sets the text value criteria.

static BySelector text(String text)

Constructs a new BySelector and sets the text value criteria.

static BySelector textContains(String substring)

Constructs a new BySelector and sets the text value criteria.

static BySelector textEndsWith(String substring)

Constructs a new BySelector and sets the text value criteria.

static BySelector textStartsWith(String substring)

Constructs a new BySelector and sets the text value criteria.

Inherited methods

From class java.lang.Object

Public methods

checkable

BySelector checkable (boolean isCheckable)

Constructs a new BySelector and sets the checkable criteria.

Parameters
isCheckable boolean
Returns
BySelector

See also:

checked

BySelector checked (boolean isChecked)

Constructs a new BySelector and sets the checked criteria.

Parameters
isChecked boolean
Returns
BySelector

See also:

clazz

BySelector clazz (String packageName, 
                String className)

Constructs a new BySelector and sets the class name criteria.

Parameters
packageName String
className String
Returns
BySelector

See also:

clazz

BySelector clazz (Class clazz)

Constructs a new BySelector and sets the class name criteria.

Parameters
clazz Class
Returns
BySelector

See also:

clazz

BySelector clazz (Pattern className)

Constructs a new BySelector and sets the class name criteria.

Parameters
className Pattern
Returns
BySelector

See also:

clazz

BySelector clazz (String className)

Constructs a new BySelector and sets the class name criteria.

Parameters
className String
Returns
BySelector

See also:

clickable

BySelector clickable (boolean isClickable)

Constructs a new BySelector and sets the clickable criteria.

Parameters
isClickable boolean
Returns
BySelector

See also:

copy

BySelector copy (BySelector original)

Constructs a new BySelector and copies the criteria from original.

Parameters
original BySelector
Returns
BySelector

depth

BySelector depth (int depth)

Constructs a new BySelector and sets the depth criteria.

Parameters
depth int
Returns
BySelector

desc

BySelector desc (String contentDescription)

Constructs a new BySelector and sets the content description criteria.

Parameters
contentDescription String
Returns
BySelector

See also:

desc

BySelector desc (Pattern contentDescription)

Constructs a new BySelector and sets the content description criteria.

Parameters
contentDescription Pattern
Returns
BySelector

See also:

descContains

BySelector descContains (String substring)

Constructs a new BySelector and sets the content description criteria.

Parameters
substring String
Returns
BySelector

See also:

descEndsWith

BySelector descEndsWith (String substring)

Constructs a new BySelector and sets the content description criteria.

Parameters
substring String
Returns
BySelector

See also:

descStartsWith

BySelector descStartsWith (String substring)

Constructs a new BySelector and sets the content description criteria.

Parameters
substring String
Returns
BySelector

See also:

enabled

BySelector enabled (boolean isEnabled)

Constructs a new BySelector and sets the enabled criteria.

Parameters
isEnabled boolean
Returns
BySelector

See also:

focusable

BySelector focusable (boolean isFocusable)

Constructs a new BySelector and sets the focusable criteria.

Parameters
isFocusable boolean
Returns
BySelector

See also:

focused

BySelector focused (boolean isFocused)

Constructs a new BySelector and sets the focused criteria.

Parameters
isFocused boolean
Returns
BySelector

See also:

hasChild

BySelector hasChild (BySelector childSelector)

Constructs a new BySelector and adds a child selector criteria.

Parameters
childSelector BySelector
Returns
BySelector

See also:

hasDescendant

BySelector hasDescendant (BySelector descendantSelector)

Constructs a new BySelector and adds a descendant selector criteria.

Parameters
descendantSelector BySelector
Returns
BySelector

See also:

hasDescendant

BySelector hasDescendant (BySelector descendantSelector, 
                int maxDepth)

Constructs a new BySelector and adds a descendant selector criteria.

Parameters
descendantSelector BySelector
maxDepth int
Returns
BySelector

See also:

longClickable

BySelector longClickable (boolean isLongClickable)

Constructs a new BySelector and sets the long clickable criteria.

Parameters
isLongClickable boolean
Returns
BySelector

See also:

pkg

BySelector pkg (Pattern applicationPackage)

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

Parameters
applicationPackage Pattern
Returns
BySelector

See also:

pkg

BySelector pkg (String applicationPackage)

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

Parameters
applicationPackage String
Returns
BySelector

See also:

res

BySelector res (String resourceName)

Constructs a new BySelector and sets the resource name criteria.

Parameters
resourceName String
Returns
BySelector

See also:

res

BySelector res (String resourcePackage, 
                String resourceId)

Constructs a new BySelector and sets the resource name criteria.

Parameters
resourcePackage String
resourceId String
Returns
BySelector

See also:

res

BySelector res (Pattern resourceName)

Constructs a new BySelector and sets the resource id criteria.

Parameters
resourceName Pattern
Returns
BySelector

See also:

scrollable

BySelector scrollable (boolean isScrollable)

Constructs a new BySelector and sets the scrollable criteria.

Parameters
isScrollable boolean
Returns
BySelector

See also:

selected

BySelector selected (boolean isSelected)

Constructs a new BySelector and sets the selected criteria.

Parameters
isSelected boolean
Returns
BySelector

See also:

text

BySelector text (Pattern regex)

Constructs a new BySelector and sets the text value criteria.

Parameters
regex Pattern
Returns
BySelector

See also:

text

BySelector text (String text)

Constructs a new BySelector and sets the text value criteria.

Parameters
text String
Returns
BySelector

See also:

textContains

BySelector textContains (String substring)

Constructs a new BySelector and sets the text value criteria.

Parameters
substring String
Returns
BySelector

See also:

textEndsWith

BySelector textEndsWith (String substring)

Constructs a new BySelector and sets the text value criteria.

Parameters
substring String
Returns
BySelector

See also:

textStartsWith

BySelector textStartsWith (String substring)

Constructs a new BySelector and sets the text value criteria.

Parameters
substring String
Returns
BySelector

See also: