Skip to content

Element Attributes

The Espresso driver supports various native and custom element attributes. Available attributes depend on the currently active subdriver (espresso or compose), which can be set using the driver setting.

Espresso Subdriver

class

Example: android.view.View

Full name of the element's class. Inner classes are preferred. Could be null.

package

Example: com.mycompany

Name of the package the element belongs to, retrieved from Context.getPackageName().

resource-id

Example: com.mycompany:id/resId

Resource identifier of the element, retrieved as a combination of Resources.getResourcePackageName(), Resources.getResourceTypeName(), and Resources.getResourceEntryName(). Could be null.

view-tag

Example: my tag

Tag value of the element, retrieved from View.getTag().

content-desc

Example: foo

Content description of the element, retrieved from View.getContentDescription().

text

Example: my text

Text or value of the element, depending on the element's view type:

  • TextView: set to the value of getHint() if populated, otherwise getText()
  • NumberPicker: set to the value of getValue()
  • ProgressBar: set to the value of getProgress()
  • All other view types: attribute is omitted

bounds

Example: [0,0][100,100]

Bounds of the element's frame as a combination of its top-left and bottom-right corner points, formatted as [<top-left-X>,<top-left-Y>][<bottom-right-X>,<bottom-right-Y>]. Retrieved as a combination of View.getLocationOnScreen(), View.getWidth(), and View.getHeight().

index

Example: 1

Index of the element under its parent ViewGroup. Set to 0 if the parent view is not a ViewGroup.

viewIndex

Example: 1

Index of the element in the full application source of the current view. Indices start from 1.

checkable

Example: true

Whether the element is checkable, retrieved by determining if the element implements the Checkable interface.

checked

Example: true

Whether the element is checked, retrieved by determining if it satisfies the isChecked matcher. Always false if the element is not checkable.

clickable

Example: true

Whether the element is clickable, retrieved by determining if it satisfies the isClickable matcher.

enabled

Example: true

Whether the element is enabled, retrieved by determining if it satisfies the isEnabled matcher.

focusable

Example: true

Whether the element is focusable, retrieved by determining if it satisfies the isFocusable matcher.

focused

Example: true

Whether the element is accessibility focused, retrieved from View.isAccessibilityFocused(). Always false if the element is not focusable.

long-clickable

Example: true

Whether the element reacts to long clicks, retrieved from View.isLongClickable().

password

Example: true

Whether the element is a password input field, retrieved by checking the element's content type against TYPE_TEXT_VARIATION_PASSWORD, TYPE_TEXT_VARIATION_WEB_PASSWORD and TYPE_NUMBER_VARIATION_PASSWORD.

scrollable

Example: true

Whether the element is scrollable, retrieved from View.isScrollContainer().

selected

Example: true

Whether the element is selected, retrieved by determining if it satisfies the isSelected matcher.

hint

Example: true

Whether the element's text value is a hint. The value depends on the element's view type:

  • TextView: set to true only if getText() is empty while getHint() is non-empty, otherwise false
  • NumberPicker, ProgressBar: set to false
  • All other view types: attribute is omitted

no-multiline-buttons

Example: true

Whether the element's view hierarchy does not contain multiline buttons. This attribute is not included in the default page source, but it can be retrieved using the standard W3C WebDriver Get Element Attribute endpoint. Retrieved by calling noMultilineButtons().

no-overlaps

Example: true

Whether element's descendant objects assignable to TextView or ImageView do not overlap each other. This attribute is not included in the default page source, but it can be retrieved using the standard W3C WebDriver Get Element Attribute endpoint. Retrieved by calling noOverlaps().

no-ellipsized-text

Example: true

Whether the element's view hierarchy does not contain ellipsized or cut off text views. This attribute is not included in the default page source, but it can be retrieved using the standard W3C WebDriver Get Element Attribute endpoint. Retrieved by calling noEllipsizedText().

visible

Example: true

Whether the element is selected, retrieved by determining if it satisfies the isDisplayed matcher.

adapter-type

Example: ListAdapter

Type of adapters contained by this AdapterView. Set to null for all element view types other than AdapterView. Cannot be retrieved using the standard W3C WebDriver Get Element Attribute endpoint.

adapters

Example: android.widget.CursorAdapter@45a7bc,android.widget.CursorAdapter@58db2a

Comma-separated string of adapter objects contained by this AdapterView. Set to null for all element view types other than AdapterView. Cannot be retrieved using the standard W3C WebDriver Get Element Attribute endpoint.

Compose Subdriver

class

Example: ComposeNode

Name of the element's class. Usually retrieved from SemanticsProperties.Role if populated. Set to ComposeNode by default.

resource-id

Example: com.mycompany:id/resId

Resource identifier of the element, retrieved from SemanticsNode.id.

view-tag

Example: my tag

Tag value of the element, retrieved from SemanticsProperties.TestTag.

content-desc

Example: foo

Content description of the element, retrieved from SemanticsProperties.ContentDescription.

text

Example: my text

Text or value of the element, retrieved from SemanticsProperties.Text, SemanticsProperties.EditableText, or ProgressBarRangeInfo.current, whichever is populated first.

bounds

Example: [0,0][100,100]

Bounds of the element's frame as a combination of its top-left and bottom-right corner points, formatted as [<top-left-X>,<top-left-Y>][<bottom-right-X>,<bottom-right-Y>]. Retrieved from SemanticsNode.boundsInWindow().

index

Example: 1

Index of the element node under its parent. Set to 0 if the node has no parent.

checked

Example: true

Whether the element is checked, retrieved from SemanticsProperties.ToggleableState.

clickable

Example: true

Whether the element is clickable, retrieved by determining if the element responds to SemanticsActions.OnClick.

enabled

Example: true

Whether the element is enabled, retrieved from the inverse of SemanticsProperties.Disabled.

focused

Example: true

Whether the element is accessibility focused, retrieved from SemanticsProperties.Focused.

password

Example: true

Whether the element is a password input field, retrieved from SemanticsProperties.Password.

scrollable

Example: true

Whether the element is scrollable, retrieved by determining if the element responds to SemanticsActions.ScrollBy.

selected

Example: true

Whether the element is selected, retrieved from SemanticsProperties.Selected.