Updated 31 May 2019
In espresso, some times the swipe functionality not works like for “Swipeleft”, “swiperight”,”swipeup”,”swipedown”,”swipeup”.
so for this problem we can create a custom swipe to swipe up , down , left and right.
Swipe up used to custom swipe the page upward using the id of any element.
1 |
public static ViewAction customswipeUp() {return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER,GeneralLocation.TOP_CENTER, Press.FINGER);} |
usage:-
1 |
onView(withId(R.id. element_id).perform(customswipeUp()); |
Swipe down used to custom swipe the page downward direction using the id of any element.
1 |
public static ViewAction customswipeDown() {return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER,GeneralLocation.BOTTOM_CENTER, Press.FINGER);} |
usage :-
1 |
onView(withId(R.id. element_id)).perform(customswipeDown()); |
Swipe left used to custom swipe the page leftward direction using the id of any element.
1 |
public static ViewAction customswipeLeft() {return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_RIGHT,GeneralLocation.CENTER_LEFT, Press.FINGER);} |
usage :-
1 |
onView(withId(R.id. element_id)).perform(customswipeLeft()); |
Swipe left used to custom swipe the page rightward direction using the id of any element.
1 |
public static ViewAction customswipeRight() {return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT,GeneralLocation.CENTER_RIGHT, Press.FINGER);} |
usage :-
1 |
onView(withId(R.id. element_id)).perform(customswipeRight()); |
So in this way, we can create a custom swipe approach in espresso when the swipe doesn’t work.
Hope this blog will help you.
Thanks for readingĀ : )
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.