Issue I writing a test case in espresso that requires performing a delete (backspace). The code I came up is like this onView(withId(R.id.testNumberEditText)) .perform(replaceText(“123”)) .perform(pressKey(KeyEvent.KEYCODE_DEL)) .check { view, _ -> assertEquals(“12”, (view as EditText).text.toString()) } But this code doesn’t work
Continue readingTag: android-espresso
Proper Espresso test setup for Fragment with RecyclerView using Databinding
Issue I’ve been facing an issue when trying to run instrumented tests for a fragment. With the code below, the test starts but looks like it never launches the fragment, gets stuck on loading. I need to cancel it in
Continue readingHow to type text on a SearchView using espresso
Issue TypeText doesn’t seem to work with SearchView. onView(withId(R.id.yt_search_box)) .perform(typeText(“how is the weather?”)); gives the error: Error performing ‘type text(how is the weather?)’ on view ‘with id:../yt_search_box’ Solution For anyone that bump into this problem too, the solution is to
Continue readingHow to catch a View with Tag by Espresso in Android?
Issue I have a PinCodeView that extends LinearLayout. I have following code in my init() method. DigitEditText extends EditText and just accepts one digit. This view will be used to receive confirmation code which has 4 digits long. private void
Continue readingEspresso check content of next fragment in AndroidX Navigation
Issue I’m testing the login feature with Espresso and it’s correctly working as long as I check that the navigation action would bring the user to the fragment ith correct id. @Test fun loginLogout() { val fragmentArgs = bundleOf("numElements" to
Continue readingEspresso check content of next fragment in AndroidX Navigation
Issue I’m testing the login feature with Espresso and it’s correctly working as long as I check that the navigation action would bring the user to the fragment ith correct id. @Test fun loginLogout() { val fragmentArgs = bundleOf("numElements" to
Continue readingIn Espresso, how to avoid AmbiguousViewMatcherException when multiple views match
Issue Having gridView which has some images. The gridView’s cell comes out from same predefined layout, which has same id and desc. R.id.item_image == 2131493330 onView(withId(is(R.id.item_image))).perform(click()); Since all cells in the grid have same id, it got AmbiguousViewMatcherException. How to
Continue readingHow to use espresso to press a AlertDialog button
Issue I want to press below button using Espresso, but I’m not sure how. Should I get the resource-id? Or how to set an ID to the AlertDialog?? @RunWith(AndroidJUnit4.class) public class ApplicationTest { @Rule public ActivityTestRule<LoadingActivity> mActivityRule = new ActivityTestRule<>(LoadingActivity.class);
Continue readingEspresso: Toggle Network State
Issue I am currently working on an Espresso test suite that covers offline functionality. In order for me to implement these tests, I need to create a method that I can call to toggle on/off network connectivity. So far, I
Continue readingEspresso AutoCompleteTextView click
Issue So I recently started messing around with Espresso in one of my existing Android projects. Everything went pretty decently, until I came to find AutoCompleteTextView in my program. I don’t seem to understand how to properly click the first
Continue reading