Handle random Dialogs using Robotium


I am try yo test the login scenario using Robotium. My confusion is that, how could I test following:

Case 1: If some error occurs during the web service call and a dialog is displayed randomly, how can I handle that. As I’m not sure if this dialog will appear.

Case 2: If this thing is handled, will the test be a fail or a pass? Because for a successful login, user should navigate to next screen.

  • You must to post comments

You know when and where this dialog can happen so its possible to place in code to handle the dialog. for instance:

lets say you have some code like this


and you know the dialog can appear between these two steps of your test, you can place in code that is something like:

if(solo.waitForView(dialogView, 1000, false)){
.clickOnView(view2) //retry the step above

If its possible the erro can happen again it might make sense to put these calls into function and recursively/loop through trying this cycle for a length of time before failing the test.

As for case 2. Well this depends on your success criteria, ideally if I was you i would try to remove any external dependancies that cause the above error so it never happens but if you are stuck with it being flaky. Well does a user consider this to be an error? I would probably say that if your production app is failing to login very often then something is wrong with the app and I would fail that step and not implement the points above, but thats my interpretation, speak to the business analyst/customer/end users and get their perspective.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.