Reputation: 13947
I am using Robotium Solo for activity testing
i need to know that onCreate has finished running before i proceed with my test
i can tell it to sleep for 5 seconds, but that wont help, because i need the first row of onStart to be caught, and onCreate finishes at different times each time
how do i tell solo to wait until onCreate has finished?
this is what my code looks like :
solo.sleep(5000);
solo.clickOnButton("animate");
solo.sleep(5000);
solo.clickOnButton("close");
solo.sleep(5000);
solo.clickOnButton("animate");
solo.sleep(5000);
solo.clickOnButton("close");
solo.sleep(5000);
solo.clickOnButton("animate");
solo.sleep(5000);
solo.clickOnButton("close");
solo.sleep(5000);
Upvotes: 0
Views: 308
Reputation: 1291
you could add another method to search your controls to your code. For example:
static boolean clickOnButton(String name, Solo solo){
Button view = null;
try{
ArrayList<Button> temp = solo.getCurrentViews(Button.class);
for (int i = 0; i < temp.size(); i++) {
if (temp.get(i).getText().toString().equals(name)){
view = temp.get(i);
break;
}
}
view.click();
return true;
} catch (Error err) {
return false;
}
}
If you are sure that the button will exist, you could loop such search, add some flag, make do-while cycle and change the flag by condition
if (view == null)
Upvotes: 1