这是匹配文本字段并输入变量的简单命令name
。
private final String name = "foo";
onView(withId(R.id.editTextName)).perform(typeText(name));
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中使用“ foo”可以正常工作。然而:
private final String name = "á";
private final String name = "\u00E1";
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,该onView
行均会失败,归咎于无法在上一个活动的视图中找到视图:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: <myappid>:id/listViewAccounts
Run Code Online (Sandbox Code Playgroud)
Espresso似乎无法处理Unicode字符,如果要求输入Unicode字符,它将失败。它在带有“英语(美国)Android键盘(AOSP)”或“英语(美国)示例软键盘”的AVD上运行。后者还会使双字母变平,这可能是Espresso输入速度有多快的另一个问题。
有人遇到过吗?是Espresso,还是使用的键盘,还是其他?
我将Android软键盘更改为可以长按a
获取的US International键盘á
,但是Espresso同样失败。
更新:
使用á
确实会将其保留在堆栈跟踪中(但\u00E1
不会):
java.lang.RuntimeException: Failed to get key events for string á (i.e. current IME does not understand how to translate the string into key events). As a workaround, you can use …