I am performing the below test to validate the text on screen , The text is present on the view but need to page scroll to see the text manually.
onView(withText("Launch")).check(ViewAssertions.matches(isDisplayed())); onView(withText("January 2010")).check(ViewAssertions.matches(isDisplayed()));
Following error is coming, However the text is present on the view but need to page scroll to see the text manually.
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected view. Expected: is displayed on the screen to the user Got: "TextView{id=2131361941, res-name=project_details_label_tv, visibility=VISIBLE, width=249, height=41, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=4.0, y=24.0, text=Status, input-type=0, ime-target=false, has-links=false}"
You can use SWIPE to scroll to the bottom of the screen: Espresso. onView(ViewMatchers. withId(R.
To interact with RecyclerViews using Espresso, you can use the espresso-contrib package, which has a collection of RecyclerViewActions that can be used to scroll to positions or to perform actions on items: scrollTo() - Scrolls to the matched View, if it exists.
As you may know the latest Espresso release contains new left and right swiping actions: swipeLeft() and swipeRight() . They both are really useful when you'd like to swipe between activity fragments, tab layouts or any other UI elements. You can use it as any other view action: onView(withId(R.
I don't know how this layout looks like, but to use
Just perform a ViewActions.scrollTo()
before your assertion:
onView(withText("Launch")) .perform(ViewActions.scrollTo()) .check(ViewAssertions.matches(isDisplayed()));
you need to have ScrollView
as your main view in structure.
If you have already LinearLayout, RelativeLayout, you have to change it to like this:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
You can use SWIPE to scroll to the bottom of the screen:
Espresso.onView(ViewMatchers.withId(R.id.recyclerView)).perform(ViewActions.swipeUp());
For me its working nice.
Pablo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With