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.
For AndroidX use this
import androidx.test.espresso.Espresso.onView