Skip to content

Waits

A common cause of false negatives in UI tests is attempting to interact with an element before it appears or becomes ready.

Modern web applications rarely render everything at once. Elements may appear later due to API calls, lazy-loading techniques, dynamic rendering, animations, or simply network variability.

To keep tests reliable, UI-licious commands have built-in waits, so that you don't need to clutter your test scripts with manual waits.

Automatic waits on page navigation

Whenever a command triggers navigation (I.goTo, clicking a link, submitting a form), UI-licious automatically waits for the new page to fully load before running the next command.

A page is considered ready when:

  • all static assets (HTML, images, CSS, and Javascript) are loaded
  • immediate Javascript code is ran
  • document.readyState reaches complete

UI-licious will wait up to 5 minutes for a page to be ready.

If the page does not become ready within that time, the command fails with a timeout error.

Automatic waits on element interactions

UI-licious also waits for elements to appear and become visible for interactive commands — e.g. I.click, I.fill, I.select, I.upload, I.see.

UI-licious performs visibility checks to ensure the target element is rendered and visible to a human user. This includes checking the position and the display, visibility and opacity styles on the elements. Hidden or off-screen elements are skipped — even if they technically exist in the DOM.

Adjusting the wait timeout

By default, UI-licious waits for up to 15 seconds for elements to appear.

If no matching elements appear within the timeout, the command fails with an error indicating that the element cannot be found.

You can increase the timeout by setting TEST.commandTimeout (in seconds) at any point in the test. This is useful if you expect certain parts of the application to be slower.

js
TEST.commandTimeout = 300 // wait for up to 5 minutes

I.click("Generate report")
I.dontSee("Processing") 
I.see("EOY Report")

TEST.commandTimeout = 15 // reset to 15 seconds timeout

Manual waits

You can use the I.wait command to pause execution for a fixed duration (in number of seconds):

js
I.click("Generate report")
I.wait(300) // wait for 5 minutes
I.see("EOY Report")

If you are simply waiting for elements to be ready, we recommend adjusting the automatic wait timeout instead of inserting fixed duration waits using I.wait, to allow the tests to execute with minimal delays. I.wait should be used for timings that are inherently fixed or predictable, such as animations or countdown timers.