浓咖啡-typeText()无法正常工作,有时会丢失字母 [英] Espresso - typeText() not working correclty, sometimes letters are missing
问题描述
我开始登录活动,并在Espresso测试中使用:
I start my login activity and I use in Espresso test:
onView(withId(R.id.username)).perform(typeText("USERNAME"));
我希望字段中的文本为"USERNAME",但有时我会得到"SERNAME",其他人为"UERNAME".
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.
以下是重现该错误的示例代码: https://github.com/neoranga55/CleanGUITestArchitecture
Here is the sample code to reproduce the bug: https://github.com/neoranga55/CleanGUITestArchitecture
推荐答案
测试电话使用启用了双重语言键入功能的Swift键盘.显然,这会导致电话启动后键盘的首次出现速度变慢,而且还会以一种奇怪的方式自动更正Espresso键入的单词的第一个字母.
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.
这篇关于浓咖啡-typeText()无法正常工作,有时会丢失字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!