Dra*_*ake 7 android android-testing android-espresso
我进行了浓缩咖啡测试,希望应用程序在测试完成后保持准确的活动。我需要继续与应用程序交互。
@SmallTest
public void testOpenNavigationDrawer()
{
Espresso.onView(ViewMatchers.withId(com.eleks.espresso.example.app.R.id.content_frame)).perform(ViewActions.swipeRight());
ListView lvDrawerMenu = (ListView) getActivity().findViewById(com.eleks.espresso.example.app.R.id.lvDrawerMenu);
Preconditions.checkNotNull(lvDrawerMenu, "lvDrawerMenu is null");
final int count = lvDrawerMenu.getAdapter().getCount();
Preconditions.checkPositionIndex(2, count, "No 1 index " + count + " size");
Object obj = lvDrawerMenu.getItemAtPosition(2);
Espresso.onView(Matchers.allOf(ViewMatchers.withId(com.eleks.espresso.example.app.R.id.tvItem), ViewMatchers.hasSibling(ViewMatchers.withText(obj.toString())))).perform(ViewActions.click());
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢你!
pio*_*543 -2
抱歉,但这是不可能的。
我认为您对自动化测试的了解还不够多。\
Espresso、Robotium、Calabash 和其他 UI 测试框架都是为简短的测试活动而设计的。它模拟用户的特定行为 - 运行应用程序,执行一些技巧,然后(如果成功)关闭应用程序。
当然,Espresso 允许您创建自定义空闲资源并将其注册到应用程序中。此外,将测试休眠特定时间的最简单方法是使用方法Thread.sleep(time_in_miliseconds),但正如我所说,这违背了自动化测试的理念。
| 归档时间: |
|
| 查看次数: |
3471 次 |
| 最近记录: |