Confirmed users
1,759
edits
Line 154: | Line 154: | ||
=== Be specific: Use clickOnButton or clickOnView in preference to clickOnText === | === Be specific: Use clickOnButton or clickOnView in preference to clickOnText === | ||
We have seen several intermittent failures when using Solo.clickOnText because the specified text appears in more than one place. It's really easy to write a test that says clickOnText("OK"), intending of course to click on the OK button and not the prompt that says "Click OK to proceed"! Worse yet, that test might work sometimes but not others, since Robotium will simply click on the first view with the specified text. Using view-specific functions, like clickOnButton(String text) addresses many of these issues; look over the screen very carefully to catch the others! (You can also enumerate views to identify the view intended, then use clickOnView(View).) | We have seen several intermittent failures when using Solo.clickOnText because the specified text appears in more than one place. It's really easy to write a test that says clickOnText("OK"), intending of course to click on the OK button and not the prompt that says "Click OK to proceed"! Worse yet, that test might work sometimes but not others, since Robotium will simply click on the first view with the specified text. Using view-specific functions, like clickOnButton(String text) addresses many of these issues; look over the screen very carefully to catch the others! (You can also enumerate views to identify the view intended, then use clickOnView(View).) | ||
=== Be careful when relying on scrolling in waitForText === | |||
Solo.waitForText (and some other Robotium functions) will conveniently scroll down in a list to find text that is not displayed. But it will not scroll up again! Consider a test like this: | |||
<open a menu or display a list> | |||
mAsserter.ok(waitForText("Item 1"), ... | |||
mAsserter.ok(waitForText("Item 2"), ... | |||
If both Item 1 and Item 2 are visible, this test passes. | |||
If Item 1 occurs first in the list, with Item 2 later, and Item 2 is off the bottom of the screen, then the first waitForText succeeds immediately, the second waitForText scrolls down, then succeeds, and the test passes. | |||
If Item 2 occurs first in the list, with Item 1 later, and Item 1 is off the bottom of the screen, then the first waitForText scrolls down to find Item 1. If that operation scrolls Item 2 off the top of the screen, then the second waitForText will fail! | |||
= More Information = | = More Information = |