Faz*_*ain 6 android ui-testing android-fragments kotlin android-espresso
我正在做这个项目。我开始学习Espresso用于编写 UI 测试的工具测试。我有一个底视图,每个底视图选项卡都有一个父片段及其子片段。我做了一个错误的片段事务,即当从服务底部视图选项卡导航到主页底部视图选项卡时,选择了主页但显示服务片段。
我想在单击主页底部视图选项卡时测试是否添加了主页片段。我已经尝试过这样的代码,但它也传递了错误的情况
我也浏览了下面的 StackOverflow 帖子,但没有工作
@Test
fun testHomeFragment_isDisplayed() {
//click on home navigation button of bottom view
onView(withId(R.id.navigation_home)).perform(click())
//click on services navigation button of bottom view
onView(withId(R.id.navigation_more)).perform(click())
//click on recycler view item at given position
onView(withId(R.id.more_rv)).perform(
RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
1,
MyViewAction.clickChildViewWithId(R.id.row_more_parent)));
//Again click on home navigation button of bottom view
onView(withId(R.id.navigation_home)).perform(click())
//check that the home fragment is displayed or not.
onView(allOf(withId(R.id.home_pager), withParent(withId(R.id.papa)))).
check(matches(isCompletelyDisplayed()))
}
Run Code Online (Sandbox Code Playgroud)
如何知道当前屏幕上显示的是哪个片段?
| 归档时间: |
|
| 查看次数: |
662 次 |
| 最近记录: |