🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

onRootWithViewInteraction

Scopes Compose interactions to the View hierarchy matched by an Espresso ViewInteraction.

onRootWithViewInteractionBasicSample

@Sampled
fun onRootWithViewInteractionBasicSample() {
    // Select the "Header" View container
    val headerInteraction = onView(withId(header_id))

    // Scope the Compose interaction to only the Header
    composeTestRule
        .onRootWithViewInteraction(headerInteraction)
        .onNodeWithContentDescription("Settings")
        .performClick()
}

onRootWithViewInteractionRecyclerViewSample

@Sampled
fun onRootWithViewInteractionRecyclerViewSample() {
    // Select the specific View row containing "Item #5"
    val specificRowInteraction =
        onView(allOf(withId(recycler_item_root_id), hasDescendant(withText("Item #5"))))

    // Scope interaction to that specific row View
    composeTestRule
        .onRootWithViewInteraction(specificRowInteraction)
        .onNodeWithTag("fav_icon")
        .assertIsDisplayed()
        .performClick()
}

onRootWithViewInteractionFragmentSample

@Sampled
fun onRootWithViewInteractionFragmentSample() {
    // Select the container for the Detail Fragment
    val detailContainerInteraction = onView(withId(detail_fragment_container_id))

    // Assert that the submit button exists/is enabled only in the detail fragment
    composeTestRule
        .onRootWithViewInteraction(detailContainerInteraction)
        .onNodeWithText("Submit")
        .assertIsEnabled()
}