Confirmed users
1,759
edits
m (→Usable IDs) |
m (→Tips) |
||
Line 118: | Line 118: | ||
= Tips = | = Tips = | ||
A recurring issue faced when writing UI tests is the timing of events. Just to enter a URL, you probably want 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: waitForGeckoEvent("Gecko:Ready"). | A recurring issue faced when writing UI tests is the timing of events. Just to enter a URL, you probably want 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"). | ||
= More Information = | = More Information = | ||
http://code.google.com/p/robotium/ | http://code.google.com/p/robotium/ |