August 2017
Beginner to intermediate
220 pages
4h 50m
English
The preceding example uses onView() to identify the views we want to test using their ID, and this is fine for components we have already named; however, items in lists cannot be identified so explicitly, and, for this, we will need another approach. When dealing with lists, such as recycler views and spinners, Espresso provides the onData() method to identify list items.
To see this in action, add a spinner as shown in the following one of your app activities:
public class SomeActivity extends AppCompatActivity { ArrayList<String> levelList = new ArrayList<String>(); TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { . . . Spinner spinner = (Spinner) findViewById(R.id.spinner); levelList.add("Easy"); ...Read now
Unlock full access