I am attempting to write a few testcases for automation using robotium. I believe my question is easy but I haven't found a solution yet.
I have a dialog prompt ("OK") that is triggered only about 50% of the time. I want this test case to check if the dialog box was prompt, if it is I need to click "OK". If it was not prompt continue logging in.
// Entering "test" into the password field
solo.enterText((EditText) solo
.findViewById("com.mobile.R.id.passwordEditText"),
"test");
// Pressing ENTER from the keyboard
solo.sendKey(ExtSolo.ENTER);
//waiting 5.1 Seconds
solo.sleep(5100);
// This is where I'm stuck
/*
* What I want:
* I want to look for the OK button, but if its not found to continue without it.
* If dialog button was not found, continue to login.
*/
assertTrue("Wait for button (text: OK) failed.",
solo.waitForButton("OK", 20000));
solo.clickOnButton("OK");
//login
solo.clickOnButton("login");
Thank you!
EDIT Maybe I can surpress the token from prompting on login, but I would rather be able to click ok if it is there, or login still if it is not without failing the test case.
solo.getView(String id) I can see if it exist with this, but it will fail if it is not there.
Here you are, it should help:
if (solo.waitForButton("OK", 20000)) {
solo.clickOnButton("OK");
}
solo.clickOnButton("login");