diff --git a/src/androidTest/java/de/dennisguse/opentracks/EspressoDeleteTrackTest.java b/src/androidTest/java/de/dennisguse/opentracks/EspressoDeleteTrackTest.java index 6c6fe76ff..9d53df2e7 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/EspressoDeleteTrackTest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/EspressoDeleteTrackTest.java @@ -8,6 +8,8 @@ import static androidx.test.espresso.action.ViewActions.longClick; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withParent; +import static androidx.test.espresso.matcher.ViewMatchers.withParentIndex; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.anything; @@ -49,7 +51,7 @@ public class EspressoDeleteTrackTest { onView(withId(R.id.finish_button)).perform(click()); // select track - onData(anything()).inAdapterView(withId(R.id.track_list)).atPosition(0).perform(longClick()); + onView(allOf(withParent(withId(R.id.track_list)), withParentIndex(0))).perform(longClick()); // open menu and delete selected track //TODO openActionBarOverflowOrOptionsMenu(); doesn't work diff --git a/src/androidTest/java/de/dennisguse/opentracks/EspressoUITest.java b/src/androidTest/java/de/dennisguse/opentracks/EspressoUITest.java index a81cbecc5..3ba3c777d 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/EspressoUITest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/EspressoUITest.java @@ -8,6 +8,8 @@ import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isClickable; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withParent; +import static androidx.test.espresso.matcher.ViewMatchers.withParentIndex; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.anything; import static de.dennisguse.opentracks.util.EspressoUtils.selectTabAtIndex; @@ -95,6 +97,6 @@ public class EspressoUITest { @Test public void selectAndDeleteTrack() { onView(withId(R.id.track_list)).check(matches(isDisplayed())); - onData(anything()).inAdapterView(withId(R.id.track_list)).atPosition(0).perform(longClick()); + onView(allOf(withParent(withId(R.id.track_list)), withParentIndex(0))).perform(longClick()); } }