机器人馆。 waitForActivity() 对于 TabHostActivity 中的嵌入活动返回 false
我有一个 TabHostActivity,它有 4 个选项卡(以及 4 个相应的活动)。当我在测试中点击其中之一(“Search”)时,SearchActivity 应该会出现(而且实际上确实出现了)。问题是,在 Robotuim-test 中,我尝试使用 solo.waitForActivity()
等待此活动,即使活动位于屏幕上,它也会失败。此外,此活动的所有视图都无法通过 solo.getView()
获得 - 返回 null。
I have a TabHostActivity that has 4 tabs (and 4 corresponding Activities). When in the test I click on one of them("Search")
the SearchActivity should appear (and it actually does). The problem is that in Robotuim-test I try to wait for this activity using solo.waitForActivity()
and it fails even if the Activity is on the screen. Also all view of this activity are not available via solo.getView()
- returns nulls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
solo.waitForActivity()
不起作用,您可以使用solo.sleep(time)
,然后使用solo.assertCurrentActivity("notdesiredactivity", Activity.class)
以确认您处于所需的活动中。并且可以继续进行进一步的动作表演。If
solo.waitForActivity()
doesn't work, you can usesolo.sleep(time)
and followed bysolo.assertCurrentActivity("not desired activity", Activity.class)
to confirm that you are in desired activity. And you can continue with further action performance.Tabhosts 和 Robotium 不能很好地混合,基本上,solo.waitforactivity 只期望一次打开一个活动,但使用选项卡主机时,会发生不好的事情,其中多个活动实际上打开并且会变得混乱。
Tabhosts and robotium do not mix very well, basically the solo.waitforactivity only expects one activity to be open at a time but with tab hosts bad things happen where multiple activities are actually open and it gets confused.