# ViewAssertions

Summary:[Methods](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#)  

# ViewAssertions

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
ViewAssertions
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|--------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.assertion.ViewAssertions |

<br />

*** ** * ** ***

Collection of common[ViewAssertions](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | ` `[doesNotExist](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#doesNotExist())`() ` Returns an assert that ensures the view matcher does not find any matching view in the hierarchy.                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` static `[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | ` `[matches](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#matches(org.hamcrest.Matcher<? super android.view.View>))`(Matcher<? super `[View](https://developer.android.com/reference/android/view/View.html)`> viewMatcher) ` Returns a generic[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)that asserts that a view exists in the view hierarchy and is matched by the given view matcher.                                                                                                                                                 |
| ` static `[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | ` `[selectedDescendantsMatch](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#selectedDescendantsMatch(org.hamcrest.Matcher<android.view.View>, org.hamcrest.Matcher<android.view.View>))`(Matcher<`[View](https://developer.android.com/reference/android/view/View.html)`> selector, Matcher<`[View](https://developer.android.com/reference/android/view/View.html)`> matcher) ` Returns a generic[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)that asserts that the descendant views selected by the selector match the specified matcher. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public methods

### doesNotExist

```
ViewAssertion doesNotExist ()
```

Returns an assert that ensures the view matcher does not find any matching view in the hierarchy.

<br />

|                                                   Returns                                                    ||
|------------------------------------------------------------------------------------------------------|--------|
| [ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | <br /> |

### matches

```
ViewAssertion matches (Matcher<? super View> viewMatcher)
```

Returns a generic[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)that asserts that a view exists in the view hierarchy and is matched by the given view matcher.

<br />

|           Parameters            ||
|---------------|------------------|
| `viewMatcher` | `Matcher` <br /> |

|                                                   Returns                                                    ||
|------------------------------------------------------------------------------------------------------|--------|
| [ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | <br /> |

### selectedDescendantsMatch

```
ViewAssertion selectedDescendantsMatch (Matcher<View> selector, 
                Matcher<View> matcher)
```

Returns a generic[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)that asserts that the descendant views selected by the selector match the specified matcher.

Example:`onView(rootView).check(selectedDescendantsMatch(not(isAssignableFrom(TextView.class)),
hasContentDescription()))`;

<br />

|          Parameters          ||
|------------|------------------|
| `selector` | `Matcher` <br /> |
| `matcher`  | `Matcher` <br /> |

|                                                   Returns                                                    ||
|------------------------------------------------------------------------------------------------------|--------|
| [ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion) | <br /> |

-

  ## Classes

  - [LayoutAssertions](https://developer.android.com/reference/android/support/test/espresso/assertion/LayoutAssertions)
  - [PositionAssertions](https://developer.android.com/reference/android/support/test/espresso/assertion/PositionAssertions)
  - [ViewAssertions](https://developer.android.com/reference/android/support/test/espresso/assertion/ViewAssertions)