android - 设备显示屏上的 Espresso UI 测试表情符号
问题描述
我正在使用 Espresso 为聊天应用程序编写 UI 测试。我很想知道是否存在一种方法,我们可以测试设备屏幕上是否存在特定的表情符号。我自己尝试过,但没有找到任何方法。提前致谢。
解决方案
您可以使用此函数来确定某个字符串是否存在于屏幕上的任何位置:
public boolean textExists(String text){
try{
onView(first(allOf(withText(containsString(text)), isDisplayed()))).perform(closeSoftKeyboard());
return true;
}
catch (NoMatchingViewException e){
return false;
}
}
像这样使用它:
boolean emoji = textExists("");
推荐阅读
- javascript - 在子类中调用 super() 后的属性查找实际上是如何工作的
- node.js - 动态水印 - 命令失败:gm convert:无法读取字体
- c# - 调用者尚未分配管理角色标头中请求的任何 RBAC 角色
- java - 调用 notifyDataSetChanged() 后丢失 EditText 值;
- java - 将 ZonedDateTime 和 Instant 格式化为不同的字符串格式
- android - 没有这样的表:TABLE_TEAM (code 1): ,编译时:SELECT * FROM TABLE_TEAM WHERE (TEAM_ID = '133604')
- networking - TCP拥塞控制——快速重传和快速恢复
- c++11 - 从 QStackedLayout 中的 QWidget 中删除框架
- string - 为什么 string.Replace 在 golang 中不起作用
- apache-kafka - 确定kafka topic中每个partition的数据大小