3

I want to click on the app tutorial OK button which is displayed only for first time,

In robotium this statement does this

if(solo.searchText("OK")){
        solo.clickOnText("OK");
    }else{
        //Do other things
}

If OK text is not displayed test should not fail it should continue, but in espresso test is failed when second time app is run because that time app tutorial is not displayed.

In espresso

onView(withText("OK")).check(matches(isDisplayed())).perform(click());

asssertion fails here, I want boolean return value for OK text so that if OK button is not displayed test should continue.

Shivaraj Patil
  • 8,186
  • 4
  • 29
  • 56
  • 1
    http://stackoverflow.com/questions/20807131/espresso-return-boolean-if-view-exists this question is somewhat related to this conditional testing situation – appoll May 20 '15 at 12:59

1 Answers1

0

Try this

 public void checkVisibileText(@StringRes int message) {
    onView(withText(message)).check(ViewAssertions.matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
}
Frank
  • 730
  • 2
  • 9
  • 20