Espresso how to search for text and if the text is displayed click on it still continue the test
I want to click on the OK OK button which is only displayed the first time,
In robotium, this statement does it
if(solo.searchText("OK")){
solo.clickOnText("OK");
}else{
//Do other things
}
If the OK text is not displayed, the test should not fail, it should continue, but the espresso test fails when the application is run a second time because the timing tutorial is not displayed.
In espresso
onView(withText("OK")).check(matches(isDisplayed())).perform(click());
asssertion doesn't work here, I want to have a boolean return value for the text OK so that if the OK button is not shown the test should continue.
+3
source to share