Skip to content

Custom espresso actions for operating on descendant views such as children of a RecyclerView

License

Notifications You must be signed in to change notification settings

joerogers/EspressoDescendantActions

Repository files navigation

Espresso Descendant Actions

Adding support for accessing descendant child views such as a button contained within the root view of a row/column element in the recycler view for testing with espresso.

Latest version
Download

For history on this project see my blog post

Basic Usage

Checking state of the specific adapter view at position 5:

onView(withId(R.id.recyclerView)).perform(
    actionOnItemAtPosition(5,
        DescendantViewActions.checkViewAction(matches(isCompletelyDisplayed())))
);

Checking state of a descendant view:

onView(withId(R.id.recyclerView)).perform(
    actionOnItemAtPosition(5,
        DescendantViewActions.checkDescendantViewAction(
            withId(R.id.favoriteButton), matches(withContentDescription(R.string.favorite))))
);

Performing an action on a descendant view:

onView(withId(R.id.recyclerView)).perform(
    actionOnItemAtPosition(5,
        DescendantViewActions.performDescendantAction(withId(R.id.favoriteButton), click()))
);

See the sample project for a functional example.

Gradle

dependencies {
    androidTestCompile 'com.forkingcode.espresso.contrib:espresso-descendant-actions:{version}'
}

If you need to exclude support-annotations use this form:

dependencies {
    androidTestCompile('com.forkingcode.espresso.contrib:espresso-descendant-actions:{version}') {
        exclude module: 'support-annotations'
    }
}

License

Copyright (C) 2016 Joe Rogers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Custom espresso actions for operating on descendant views such as children of a RecyclerView

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages