Monday, 6 September 2021

Disable auto-correct functionality in Espresso test

I wrote an Espresso test that writes some text to a TextView, performs an action and then checks whether the text in the TextView is still the same.

The test fails on one of the test devices (Huawei P20, Android 8.1.0) because the entered text is auto-corrected (from 1234 5678 to 12th 5678). And this fails my test. The text is not auto-corrected when I manually enter the same numbers.

This is how I input the text in my Espresso test:

onView(withId(R.id.reference_value))
            .perform(scrollTo(), click())
            .check(matches(isDisplayed()))
            .perform(typeText("1234 5678"));
        closeSoftKeyboard();

I know I could just change the input text to something that won't be auto-corrected. But I would like to have a solution that generally makes sure that the entered text is not modified to something else. Ideally without having to manually change the configuration of my test device.

Do any of you guys have an idea how I could accomplish this?



from Disable auto-correct functionality in Espresso test

No comments:

Post a Comment