Best Practices


Long Load Time for AJAX Calls

  • As we know, modern web applications always load data by AJAX calls. Sometimes, it may take a long time to get the AJAX call result. The automation test case becomes unstable in this case, because the test case runs the test steps without waiting for the AJAX call to end.
  • Normally, there is a loading indicator on the HTML to indicate whether an AJAX call is completed or not. We could resolve the problem by adding the waitElement command after the AJAX call test step. So that the system will wait for a certain number of seconds until the loading indicator element becomes visible/hidden/enabled/disabled.
  • The waitElement command:
    • Type: The value could be Visible, Hidden, Enabled, and Disabled.
    • Timeout: The waiting time in seconds.
    • Element ID/Element CSS/XPATH: These values can be used to locate the AJAX loading indicator HTML element on the UI page.