2015-06-19 8 views
7

To wydaje się być poprawne ...Android Espresso: Jak mogę stwierdzić, że pogląd ten nie powinien być wyświetlany

onView (withId (R.id.menu_delete)).check (matches (not (isDisplayed()))); 

... ale to rzuca ten wyjątek:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.just10.android:id/menu_delete 
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:com.github.ksoichiro.android.observablescrollview.ObservableListView{3169f0f3 VFED.VC. .F...... 0,0-480,724 #102000a android:id/list} 

Co'S najlepszy sposób potwierdzenia nie powinien być wyświetlany?

Odpowiedz

14

Co należy użyłem to:

onView (withId(R.id.menu_delete)).check (doesNotExist()); 

To może zwłaszcza na fakt, że widok jest w menu opcji i może lub nie może faktycznie istnieje w danym momencie, w zależności od implementacji w onCreateOptionsMenu i onPrepareOptionsMenu

EDIT

jest to kolejna metoda, która pracowała dla mnie widoki non-menu:

onView (withID(R.id.menu_delete)) 
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))); 
Powiązane problemy