AndroidStudio2.2应该有测试录音功能吧?我在哪里可以找到它以及如何使用它? 最佳答案 6月9日更新:Itisnowavailablewithandroidstudio2.2preview3!EspressoTestRecorderDemooftheEspressoTestRecordershownatIOisnowincludedinPreview3我的电脑截图:下载here或直接从androidstudiopreview2.2打补丁5月30日更新:AndroidStudio2.2preview2已经发布,但还没有“R
在使用带有子ImageView的自定义小部件View时使用Espresso,我可以使用哪种Matcher类型来选择第n个子图像?示例:+--------->NumberSlider{id=2131296844,res-name=number_slider,visibility=VISIBLE,width=700,height=95,has-focus=false,has-focusable=false,has-window-focus=true,is-clickable=false,is-enabled=true,is-focused=false,is-focusable=false,
我正在尝试使用Espresso在ListView中单击文本。我知道他们有thisguide,但我看不到如何通过查找文本来完成这项工作。这是我尝试过的Espresso.onData(Matchers.allOf(Matchers.is(Matchers.instanceOf(ListView.class)),Matchers.hasToString(Matchers.startsWith("ASDF")))).perform(ViewActions.click());正如预期的那样,这不起作用。该错误表示层次结构中没有View。有谁知道如何选择字符串?(在这种情况下为“ASDF”)提前致
我有一个RecyclerView(R.id.recyclerView),其中每一行都有一个图像(R.id.row_image)和一个TextView。我想点击第一行的图片。我尝试使用onData(..)但它似乎不起作用。 最佳答案 使用RecyclerViewActionsonView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(0,click()));将其包含在您的gradle脚本中:dependencies{androidTestCompile'com.an
很简单,如何判断给定的TextView是否包含Espresso中的特定字符串。相当于:myStrings.contains("Subby"); 最佳答案 您可以使用Hamcrest库。它有一个方法containsString。我相信它在Espresso库中。你可以在你的类中静态导入它:importstaticorg.hamcrest.core.StringContains.containsString;在TextView的方法中使用containsString:textView.check(matches(withText(cont
如果测试跨越多个Activity,有没有办法获取当前Activity?getActivtiy()方法只给出一个用于开始测试的Activity。我尝试了类似下面的方法,publicActivitygetCurrentActivity(){Activityactivity=null;ActivityManageram=(ActivityManager)this.getActivity().getSystemService(Context.ACTIVITY_SERVICE);ListtaskInfo=am.getRunningTasks(1);try{ClassmyClass=taskInf
我正在尝试通过以下方式在一些Espresso测试中单击主页图标:onView(withId(android.R.id.home)).perform(click());这适用于Android>3.0-但不适用于旧版本,因为appcompat似乎没有将此id用于此元素。什么是做我想做的事的好方法? 最佳答案 要不依赖于应用语言环境,您可以使用MattLogan中的代码通过用R.string.abc_action_bar_up_description替换“向上导航”:onView(withContentDescription(R.stri
拥有包含一些图像的gridView。gridView的单元格来自相同的预定义布局,具有相同的id和desc。R.id.item_image==2131493330onView(withId(is(R.id.item_image))).perform(click());由于网格中的所有单元格都具有相同的id,因此它得到了AmbiguousViewMatcherException。如何只拿起第一个或其中任何一个?谢谢!android.support.test.espresso.AmbiguousViewMatcherException:'withid:is'matchesmultiplev
以下是我的Espresso测试用例之一。publicvoidtestLoginAttempt(){Espresso.onView(ViewMatchers.withId(R.id.username)).perform(ViewActions.clearText()).perform(ViewActions.typeText("nonexistinguser@krossover.com"));Espresso.onView(ViewMatchers.withId(R.id.username)).perform(ViewActions.clearText()).perform(ViewAc
我正在寻找AndroidUI自动化的测试框架,我偶然发现了UIAutomator和Espresso,这是我感到困惑的部分-两者均由Google维护两者都用于功能UI测试两者都是Android专用框架所以我的问题/疑问是-UIAutomator和Espresso的主要区别是什么?是否必须修改源代码才能集成这些框架?一个框架比另一个框架有什么优势吗?如果是,那么哪个框架最适合Android应用的UI自动化? 最佳答案 其实你不需要选择。UIAutomator和Espresso使用相同的检测运行程序,因此您可以在单个测试中使用它们的命令。