I am writing an automation test for the View pager using Espresso 2.2, in which I need to check the functionality of the swipe.
I wrote the code below:
@LargeTest
public class FirstActivityTest {
@Rule
public ActivityTestRule<FirstActivity> firstActivityTestRule =
new ActivityTestRule<>( FirstActivity.class);
@Test
public void testViewPagerSwipeFunctionality() throws InterruptedException{
onView(withId(R.id.tv_commu)).check(matches(withText(R.string.first_screen_text)));
onView(withId(R.id.tv_skip)).check(matches(withText(R.string.skip))) ;
onView(withId(R.id.radio_button_first)).check(matches(isChecked()));
onView(withId(R.id.view_pager)).perform(swipLeft());
onView(withId(R.id.radio_button_second))
.check(matches(isChecked()));
onView(withId(R.id.tv_comp)).check(matches(withText(R.string.second_screen_text)));
onView(withId(R.id.tv_skip)).check(matches(withText(R.string.skip))) ;
onView(withId(R.id.view_pager)).perform(swipeLeft());
onView(withId(R.id.radio_button_third))
.check(matches(isChecked()));
onView(withId(R.id.tv_skip)).check(matches(withText(R.string.skip))) ;
onView(withId(R.id.tv_person)).check(matches(withText(R.string.third_screen_text)));}}
However, the swipeLeft () method does not get permission. Please let me know where I am doing wrong? Your help would be greatly appreciated.
source
share