Wait Strategy

A proper Wait Strategy is essential for the stability of UI Automation. Your automation will fail randomly with all sorts of Exceptions(NoSuchElementException, StaleElementException….) and your automation won’t run stably. Flaky, that’s what you get.

But how can we come up with the best Wait Strategy? Understand the Dynamism of your application. This is the key, the only way to write a stable and robust automation.

  • Identify all ajax calls on the page
  • What action will trigger this call?
  • If not triggered by user action, then how it is triggered automatically and how frequently it is triggered? Bug the developer(s) until you get the answer
  • identify:
    what you are waiting for
    WHEN shall you wait?
    REASON that you have to wait?

Based on the dynamism of the web, put explicitWait into use, together with condition-checking…
1. Set implicitWait time when the driver is created.
2. Identify special elements on your page that needs extra time to load or show, then use WebDriverWait for waiting
3. Identify AJAX elements and come up with a way to handle it.

Leave a Reply

Your email address will not be published. Required fields are marked *