I have a custom viewpager (with swiping disabled for reasons) working with a tablayout. The content changes based on which tab is selected. I want to test this using espresso: 1) Click on a particular tab 2) Check some data in a particular page of the tab How can I do that. I am a novice to espresso
相关问题
- It returns null when I use getView() to get root V
- Android TabLayout tabPaddingTop and tabPaddingBott
- NullPointerException in RecyclerViewMatcher when t
- Fragment transaction with viewpager returns blank
- “java.lang.RuntimeException: Could not launch inte
相关文章
- PageCurl animations on ViewPager transitions?
- ViewPager first fragment shown is always wrong wit
- How to handle back button using view pager?
- How to make tab title alignment to left in TabLayo
- Using proguard with espresso/androidTest
- Flaky Android Espresso Test - Snackbar
- android.support.design.widget.TabLayout select Tab
- How to display video in VideoView in the center of
Espresso should be used when you clearly know what is expected in the UI and so you can verify the same.
In your case, to go to any tab, you can use view action to tap on that tab. To verify the data, first you should know what data is expected to be there on that tab and then just use matchers to check if they are displayed or not.
There are several ways of doing this, an easy one is to select the element by the tab title, I use this code:
You only have to adapt the matcher to your layout. Then, check the content.
For example:
or:
You can find examples here in the Specifying a View Matcher section: http://developer.android.com/intl/es/training/testing/ui-testing/espresso-testing.html
If you are using a RecyclerView to show the content of the tabs have a look at this: Espresso RecyclerView inside ViewPager