Squish/Waiting for a Progress Bar

From Qt Wiki
Jump to navigation Jump to search


Waiting for a progress bar or progress dialog

When you have a calculation or some other work item in your AUT that takes an arbitrary amount of time to complete, it can be hard to get your test script to be stable by just using snooze() or waitForObject() calls to wait for the work item to finish. Instead, you can use the more powerful waitFor() method, that takes any code statement, executes it until it returns True, or until the optional timeout is reached before it continues the script playback.

Assuming the work item shows a progress bar or a progress dialog while it is running, you can easily use waitFor() to make sure your script does not continue playback until the work item has completed and the progress dialog has gone away:

clickButton(waitForObject(&quot;:Dialog.Calculate_QPushButton&amp;quot;))<br />waitFor(&quot;object.exists(':_QProgressDialog')&quot;, 20000)<br />waitFor(&quot;not object.exists(':_QProgressDialog')&quot;)