I am writing tests to determine that a specific button is not clickable or is clickable. However it seems to me that there isn't any method or maybe I can't find a method that can check this feature using Espresso. Can anyone help me ?
Thank you
I am writing tests to determine that a specific button is not clickable or is clickable. However it seems to me that there isn't any method or maybe I can't find a method that can check this feature using Espresso. Can anyone help me ?
Thank you
Why not? You can use isClickable() Matcher.
onView(withId(R.id.your_button)).check(matches(isClickable()));
i always combine more tests for my button
@Test
public void buttonIsEnabled() {
onView(withId(R.id. your_button)).check(matches(isEnabled()));
}
@Test
public void buttonIsDisplayed() {
onView(withId(R.id. your_button)).check(matches(isDisplayed()));
}
@Test
public void buttonIsCompletelyDisplayed() {
onView(withId(R.id. your_button)).check(matches(isCompletelyDisplayed()));
}
@Test
public void buttonIsNotSelectable() {
onView(withId(R.id. your_button)).check(matches(not(isSelected())));
}
@Test
public void buttonIsClickable() {
onView(withId(R.id. your_button)).check(matches(not(isClickable())));
}
@Test
public void buttonWithText() {
onView(withId(R.id.your_button)).check(matches(withText(R.string.your_text)));
}