我正在尝试检查Espresso是否显示View。这是一些伪代码来显示我正在尝试的内容:if(!Espresso.onView(withId(R.id.someID)).check(doesNotExist()){//thendosomething}else{//donothing,orwhathaveyou}但我的问题是.check(doesNotExist())不返回boolean值。这只是一个断言。使用UiAutomator,我可以做这样的事情:if(UiAutomator.getbyId(SomeId).exists()){.....} 最佳答案
我正在尝试检查Espresso是否显示View。这是一些伪代码来显示我正在尝试的内容:if(!Espresso.onView(withId(R.id.someID)).check(doesNotExist()){//thendosomething}else{//donothing,orwhathaveyou}但我的问题是.check(doesNotExist())不返回boolean值。这只是一个断言。使用UiAutomator,我可以做这样的事情:if(UiAutomator.getbyId(SomeId).exists()){.....} 最佳答案
我有登录屏幕,其中包含要在底部使用提交按钮输入的电子邮件和密码。根据启用软键盘的要求,我将提交按钮移至顶部,即向用户显示提交按钮使用以下代码在软键盘上方和我的电子邮件/密码布局下方。mainrel.getViewTreeObserver().addOnGlobalLayoutListener(newViewTreeObserver.OnGlobalLayoutListener(){@OverridepublicvoidonGlobalLayout(){Rectr=newRect();mainrel.getWindowVisibleDisplayFrame(r);intheightDif
我正在尝试测试一个应用程序,我需要隐藏键盘,因为我因此无法点击按钮。所以,我在build.gradle中添加了Espresso:androidTestCompile'com.android.support.test.espresso:espresso-core:2.2.2'并尝试从android.support.test.espresso.action.ViewActions库中使用它:ViewActions.closeSoftKeyboard();测试成功运行,但在我的布局中的EditText中键入一些文本后失败。键盘还在那里,正在显示。附言在readingthisanswer.之后
在我的build.gradle文件中,我有支持库依赖项:compile"com.android.support:appcompat-v7:22.2.0"compile"com.android.support:recyclerview-v7:22.2.0"compile"com.android.support:design:22.2.0"我也有espresso测试的依赖项:androidTestCompile'com.android.support.test.espresso:espresso-core:2.2'androidTestCompile'com.android.support
我有一个自定义的ImageButton设计不完全可见,所以当我执行点击操作时,我得到这个错误:android.support.test.espresso.PerformException:Errorperforming'singleclick'onview'withid:test.com.myproject.app:id/navigationButtonProfile'.Causedby:java.lang.RuntimeException:Actionwillnotbeperformedbecausethetargetviewdoesnotmatchoneormoreofthefol
我想匹配加载Salesforce登录页面的WebView中的用户名文本字段(但也可以应用于任何其他带有文本字段的页面)。我试过:onView(withHint("UserName")).perform(typeText("test@sf.com"));但这行不通。有更好的主意吗? 最佳答案 这可以使用EspressoWeb2.2API来完成onWebView().withElement(findElement(Locator.ID,"username")).perform(webKeys("test@sf.com"));
在Espresso测试结束时,是否可以让受测应用程序处于任何状态?我不在乎它是失败还是成功。当我正在开发一个功能并测试该功能时,只要让检测应用程序停止并让应用程序处于任何状态下单独进行测试就会很有用。这将允许我手动或附加调试器并查看发生了什么,而无需手动运行整个流程。有人知道这是否可行吗? 最佳答案 游戏中有多个参与者试图终止您的Activity...最后我不得不提供一个自定义规则和一个自定义运行器来获得我想要的行为。记录在这里:https://gist.github.com/dbachelder/4d0588ab6adf0aa6e
这太奇怪了。我有一个Activity和一个ViewPager,它承载几个Fragment,第一个有一个RadioButton使用IDandroid:id="@+id/backjudgeRadionButton"。我有一个Espresso测试,如下所示:importandroid.test.ActivityInstrumentationTestCase2;importmodel.GameSetup;importui.SetupActivity;importweigl.fm.refwatch.R;importstaticandroid.support.test.espresso.Espre
我有一个使用ViewPager的Android应用程序,View寻呼机中的每个fragment都有自己的WebView。我能够编写测试用例来检查ViewPager上的导航。但是我如何测试作为View寻呼机第一个子节点的webview中的div是否断言提供的字符串?onWebView().withElement(findElement(Locator.ID,"desgination")).check(webMatches(getText(),containsString("Doctor")));这个扔android.support.test.espresso.AmbiguousViewM