Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Espresso checkbox is checked

I am new to Espresso and I have this problem: How can I check if some checkBox is checked? I create a matcher from checkbox and I click on it by espresso.

I read some tutorial about use getInstrumentation() but I only can use InstrumentationRegistry.getInstrumentation() and it doesnt work.

In general, how can I create real widget such as Button, CheckBox etc. from Matcher object?

Thanks for help.

like image 286
Michael Drdlíček Avatar asked Mar 03 '16 15:03

Michael Drdlíček


1 Answers

After click you can check that checkbox is checked with such expression:

onView(withId(R.id.checkbox)).check(matches(isChecked()));
like image 189
Vyacheslav Pedak Avatar answered Oct 15 '22 19:10

Vyacheslav Pedak