There might be instances where you want to wait for a certain event to occur before taking the next step. It can be a wait to display an element, wait for text display, simply wait for 2 seconds or for any other reason for which the wait is required.

Testim has a built-in capability to help you wait ...

Types of waits we provide:

  • Wait for element visible
  • Wait for element not visible
  • Wait for element text
  • Sleep
  • Custom Wait for (JavaScript)
  • Wait for element pixel

Wait for element visible

Use wait for element visible to wait for your element to be visible on the page. 

How to add

  • Hover over the arrow menu where you want to add your "wait".
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Wait for Element Visible’.
  • Select the element you want to wait for from your app.

Note: If you get the message "No app to choose an element from" this means that you must first run the test so you can select a component from within your application.

How to change

If you want to change the element you selected, you don't have to re-record this step.

  • Click the 'Reassign' button under the element you choose in the properties panel.
  • Select a different element from your application.

Wait for element not visible

Use "Wait for element not visible" to wait until an element disappears from the page.

How to add

Similar to adding "Wait for Element Visible".

  • Hover over the arrow menu where you want to add your "wait".
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Wait for Element not visible’.
  • Select the element you want to wait for from your app.

Note: If you get the message "No app to choose an element from" this means that you must first run the test so you can select a component from within your application.


Delay step
In some cases, you want to set a delay time before checking that the element is not visible. For example, you want to make sure that the element does not suddenly appear on the page.

  • Enter the properties of the 'Wait for Element not visible' step that you created.
  • Check 'Pre-step delay'. 
  • Set delay time in ms. 

How to change

As you do in "Wait for Element Visible", using the reassign button.

Wait for element text

Use wait for element text to make sure a specific text appears before continuing with the test. 

How to add

  • Hover over the arrow menu where you want to add the wait.
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Wait for Element Text’.
  • Select the text you want to wait for from your app.

How to change

If you want to change the wait for text, you don't have to re-record this step.

  • Enter the properties of the step that you created.
  • Change the text in the 'Expected Value' field

Note: Parameters, regular expressions, and Java Script expression can be used in the 'Expected Value' field. Read Advanced Text validation to learn how.

Sleep

Sometimes you want to wait a few seconds between the steps. Use it carefully as constant waiting will make the test run longer.

How to add

  • Hover over the arrow menu where you want to add the wait.
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Sleep’.
  • The default sleep time is 1 second.
  • To change the default time double click the step, and edit the time. 

Wait for element pixels

Use wait for element pixel to wait for your element to be visible on the page and validate it at a pixel level.

How to add

  • Hover over the arrow menu where you want to add your "wait".
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Wait for Element Pixels’.
  • Select the element you want to wait for from your app.

Custom Wait for

Custom Wait are JavaScript steps that are used in instances where none of the built-in steps presented fit your need. 

How to add

  • Hover over the arrow menu where you want to add your "wait".
  • Click ‘+’ ⇒ ‘Wait for’ ⇒ ‘Add Custom Wait For’.
  • Write any JavaScript code in the function area, verify that the function returns a True / False value.
  • You can use step parameters, export parameters and so on.
  • Read more about custom steps here

Note:

  • Wait for step will retry until the function returns a true value or until the timeout for the step is reached.
  • Custom Wait for steps are reusable components. You can use them on other tests.

Did this answer your question?