Your web application does not always respond when icons are clicked. Real users know to re-click and wait for the page to load before advancing to the next step, but how do automated users know how to respond?
Using "Wait for Image to Disappear" in conjunction with "On Failure" and "Resume" will create a fool-proof method for keeping automated users in synch with the application under test.
Let's examine the following Scenario:
This Scenario opens Yahoo.com and then uses a "Click on Image" Action to click on the link to the "Autos" page. Next (step 5) in the Scenario uses a "Find Image" Action with the same image of the "Autos" link, but with the "Wait for Image to Disappear" property enabled (notice this changes the Action type to a "Wait Image Disappear" Action):
So we've added a step that waits for the image to disappear. Now we need to add steps to take in the event that the image does not disappear at all.
This is handled in the Scenario's "On Failure" section, which first uses another "Click on Image" Action to click that same "Autos" link. Then, a "Resume" Action tells ScenarioBuilder to go back to the point of the failure and pick up where it left off. The "Resume" has a "Retries" property which determines the number of times to loop through the "On Failure" section before giving up. In our Scenario it's set to 3.
So, to recap, in plain terms, our Scenario does the following:
1. Opens the Yahoo website.
2. Clicks the "Autos" link and waits for the image of the link to disappear (to ensure that our Scenario does not advance if the proper page does not load).
3. If the image does disappear, the Scenario advances to the next Action without missing aHowever, if for some reason the "Autos" link does not disappear, our Scenario is smart enough to know that the next Action cannot be performed because the expected page has not loaded. Therefore, the "On Failure" section is triggered.
4. In the "On Failure" section we have a "Click on Image" Action that clicks the "Autos" image again, followed by a "Resume" Action which returns the Scenario to the "Wait Image Disappear" step (point of the failure). This sequence will happen up to 3 times, as dictated by the "Retries" property of the "Resume" Action.
Give this one a try!