Robotium: How do I wait for loading to complete before proceeding?
Asked Answered
H

1

6

I want to write a Robotium/Junit test for an android app. At certain steps, I want my test to wait until the spinning loading symbol disappears off the screen.

How can I do that?

Hexachord answered 23/2, 2012 at 12:41 Comment(0)
F
13

There are different ways in which you can do that. In Robotium there are a lot of different waitFor methods that you can use. In your case you can use:

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.

Please see the Robotium API Documentation for more waitFor methods in Robotium.

Fahy answered 23/2, 2012 at 16:52 Comment(3)
Thanks... it seems to work but takes longer than I expected when I use this command: solo.waitForActivity(solo.getCurrentActivity().toString());Hexachord
@Fahy If i want to wait for horizontal progress bar means, how could i use these methods?Gerigerianna
solo.waitForDialogToClose() will not work if u have alert dialog immediately after progressdialog, robotium will will wait for alert dialog to close.Citole

© 2022 - 2024 — McMap. All rights reserved.