# LayoutElementAssertion

# LayoutElementAssertion

Artifact:[androidx.wear.protolayout:protolayout-testing](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/testing/LayoutElementAssertion.kt+class:androidx.wear.protolayout.testing.LayoutElementAssertion)  
Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertion "View this page in Java")

<br />

```
class LayoutElementAssertion
```

<br />

*** ** * ** ***

Represents a layout element that can be asserted on.

An instance of \[LayoutElementAssertion\] can be obtained from 'onElement' method on a \[LayoutElementAssertionsProvider\].

## Summary

|                                                       ### Public functions                                                        |
|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LayoutElementAssertion](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementAssertion) | [assert](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementAssertion#assert(androidx.wear.protolayout.testing.LayoutElementMatcher))`(matcher: `[LayoutElementMatcher](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementMatcher)`)` Asserts that the provided[LayoutElementMatcher](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementMatcher)is satisfied for this element. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [assertDoesNotExist](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementAssertion#assertDoesNotExist())`()` Asserts that no element was found in the element tree.                                                                                                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [assertExists](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementAssertion#assertExists())`()` Asserts that the element was found in the element tree.                                                                                                                                                                                                                                                                                                                |

## Public functions

### assert

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun assert(matcher: LayoutElementMatcher): LayoutElementAssertion
```

Asserts that the provided[LayoutElementMatcher](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/testing/LayoutElementMatcher)is satisfied for this element.  

### assertDoesNotExist

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun assertDoesNotExist(): Unit
```

Asserts that no element was found in the element tree.  

### assertExists

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun assertExists(): Unit
```

Asserts that the element was found in the element tree.