Espresso UI testing doesn't recognize onView()

You should either use a static import:

import static android.support.test.espresso.Espresso.onView;

or

import android.support.test.espresso.Espresso;

and call it in the following way

Espresso.onView()

To extend what Egor has suggested, in Android Studio, once you get red text at onView(), simply press alt+enter when the red bulb popped up. Then choose static import.


Keep writing. Android Studio will suggest the needed Espresso imports, from the 'inside out'. For example: onView(withId()) First will detect withId(), then onView()