With UIObject
we have a method :
exists()
to check if view exists
I am looking for same alternative with UIObject2
.
You can do it this way:
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.InstrumentationRegistry;
private UiDevice device = UiDevice.getInstance(
InstrumentationRegistry.getInstrumentation()
);
List<UiObject2> objs = device.findObjects(...)
// Now you can check if objs.size() > 0