Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Espresso - typeText() not working correclty, sometimes letters are missing

I start my login activity and I use in Espresso test:

onView(withId(R.id.username)).perform(typeText("USERNAME"));

I expect the text in the field to be "USERNAME", but sometimes I get "SERNAME", others "UERNAME".

Most of the times it works but sometimes it fails, specially after rebooting the phone.

Here is the sample code to reproduce the bug: https://github.com/neoranga55/CleanGUITestArchitecture

like image 375
Sebas LG Avatar asked Sep 19 '15 11:09

Sebas LG


Video Answer


2 Answers

You can also try replaceText(). It should not be affected by the slow IME:

onView(withId(R.id.username)).perform(replaceText("USERNAME"));

like image 183
ejboy Avatar answered Sep 27 '22 20:09

ejboy


The test phone uses Swift keyboard with double language typing enabled. Apparently this causes the first appearance of the keyboard after phone boot to be slow but also auto-correct in a weird way the first letters of a word typed by Espresso.

Solution: always use default system keyboard on testing device/emulator and make sure a software keyboard is enabled to avoid this other issue.

like image 36
Sebas LG Avatar answered Sep 27 '22 20:09

Sebas LG