Setting Ample Timeouts in your Test

PROBLEM

Your tests often fail because of a synchronization issue. For instance, you're testing an ASP .NET application. You have a test step that clicks on a button. This button is dynamically generated after certain conditions are met. However, when these conditions are met, it still takes 20 seconds for the app to perform a postback and generate the button. Your test fails because Test Studio attempts to click on the button after it's supposed to have been generated, but without waiting an ample amount of time for it to appear. How can you avoid similar synchronization problems?

SOLUTION

The majority of test steps in any given test will consist of interactions with elements within the browser. If the element associated with a given step can't be found, the step doesn't immediately fail. Instead, it waits a set amount of time for the element to appear.

 

By default, each step is set to use the Global WaitOnElementsTimeout as defined in the Quick Execution Options. The default is 10,000 milliseconds (10 seconds). The corresponding Test List Setting is ElementWaitTimeout.

 

Each test step will wait 10 seconds for the element to appear in the page's DOM. So, if you have a button to be clicked but it's not there yet, the Click step will wait for 10 seconds for the element to appear. If it appears in that time, it will be clicked and the test will continue executing. If it's still not there after 10 seconds, the test will fail with a Timed Out: Waiting for Element exception. In most situations the elements will appear immediately and the 10 seconds timeout will be ample.

 

In other cases, however, you will need to increase the timeout for a step in order to get it to work. You can either increase the Global WaitOnElementsTimeout to affect all elements, or edit the properties of a single step. For a single step, change UseStepWaitOnElementsTimeout to True and increase the WaitOnElementsTimeout to an ample number.