title: Unit testing Android Tab Layout
body: <p>I am new to Android Unit testing and trying to write some test cases for Android tab layout with <code>Robolectric</code>. I am able to verify the tab count and tab titles. But I am not able to verify some content in tabs. Can anyone help me in getting the fragment content and verify some elements in that?</p>
  
  <p>Here is my code</p>
  
  <pre><code>public void verifyTabsDefaultText() throws Exception{
      ViewPager viewPager = searchActivity.findViewById(R.id.container);
      FragmentPagerAdapter tabAdapter = (FragmentPagerAdapter) viewPager.getAdapter();
  
      viewPager.setCurrentItem(0);
  
      TextView hintTextView = tabAdapter.getItem(0).getActivity().findViewById(R.id.search_hint_text_view);
  
      assertTrue(hintTextView.getVisibility() == View.VISIBLE);
  
  }
  </code></pre>
  
  <p><code>tabAdapter.getItem(0)</code> is giving <code>null</code> value.</p>
  
  <p>Thanks in advance. </p>