Robotium:如何在继续之前等待加载完成?

6

我想为一个Android应用写一个Robotium/Junit测试。在某些步骤中,我希望我的测试等待,直到旋转加载符号从屏幕上消失。

我该如何做呢?

1个回答

13

您可以使用不同的方法来实现此目的。在Robotium中,有许多不同的等待方法可供使用。在您的情况下,您可以使用:

solo.waitForDialogToClose() //waits for the dialog to close
solo.waitForActivity() // if there is a activity change
solo.waitForText() //if a certain text appears after the loading is done
solo.waitForView() //if a certain view is shown after the load screen is done.
请查看Robotium API文档,了解更多Robotium的waitFor方法。

谢谢...看起来它能工作,但是当我使用这个命令时,它比我预期的要花费更长的时间:solo.waitForActivity(solo.getCurrentActivity().toString()); - user952342
@Renas 如果我想等待水平进度条,该如何使用这些方法? - Mani
如果在ProgressDialog之后立即出现AlertDialog,则solo.waitForDialogToClose()将无法正常工作,Robotium会等待AlertDialog关闭。 - Suru

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接