Confirmed users
1,759
edits
(→Creating a new test: Add stuff about BaseTest) |
(→Tips) |
||
| Line 141: | Line 141: | ||
= Tips = | = Tips = | ||
A recurring issue | === Event timing === | ||
A recurring issue when writing UI tests is the timing of events. To enter a URL, you need to click on the awesome bar and then send the key events for the text. If you click() and then immediately sendKeys(), the text probably won't get to the awesome bar. If you sleep() briefly before and after clicking, the task will probably succeed...but how long are those sleep() calls? Will the test still work on other devices, reliably? Avoid the temptation to scatter sleep() throughout your test. Whenever possible, wait for events or other feedback to verify the UI is in the required state before proceeding. For example, many tests will want to wait for startup before starting the test: driver.waitForGeckoEvent("Gecko:Ready"). | |||
=== Activities === | |||
Most tests will access UI views using FennecNativeDriver.findElement, which takes an activity as an argument. Some tests will only interact with one activity, but others may need to use multiple activities. For instance, when there are multiple tabs, there may be multiple awesome bar activities; use the wrong activity and you'll be accessing an unexpected element / view! See testNewTab for an example with multiple activities. | |||
= More Information = | = More Information = | ||
http://code.google.com/p/robotium/ | http://code.google.com/p/robotium/ | ||