Wait for

When you just want to wait...

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 visualization
  • Wait for Download

Wait for element visible

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

To add a Wait for Element Visible step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Wait for element visible step.
428428
  1. Select the target element in your application.
723723

πŸ“˜

Note:

If you get the message "To choose an element Open base URL or Run test to relevant step" this means that you must first open the application in the base URL or run the test until the relevant step, before adding the Wait for Element Visible step.

Wait for element not visible

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

To add a Wait for Element Not Visible step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Wait for element not visible step.
425425
  1. Select the target element in your application.
723723

πŸ“˜

Note:

If you get the message "To choose an element Open base URL or Run test to relevant step" this means that you must first open the application in the base URL or run the test until the relevant step, before adding the Wait for element not visible step.

Wait for element not visible delay

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.

To add a delay to a Wait for Element Not Visible Step:

  1. Enter the properties of the 'Wait for Element not visible' step that you created.
  2. Check Pre-step delay.
331331
  1. Set delay time in milliseconds (ms). Testim will wait this amount of time before moving to the next step.
321321

Wait for element text

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

To add a Wait for element text step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Wait for element text step.
428428
  1. Select the target text element you want to wait for from your app.
928928

πŸ“˜

Note:

If you get the message "To choose an element Open base URL or Run test to relevant step" this means that you must first open the application in the base URL or run the test until the relevant step, before adding the Wait for element text step.

πŸ“˜

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.

To add a Sleep step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Sleep step.
411411
  1. The default sleep duration is 1 second (1,000ms). To update the sleep duration click the step properties and edit the milliseconds value.
328328

Wait for element visualization

Use wait for element visualization to wait for your element to be visible on the page and validate its expected visualization. See Visual Validation for more information.

To add a Wait for element visualization step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Wait for element visualization step.
417417
  1. Select the target element in your application.
723723

Custom Wait for

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

To add a Custom wait for step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Add custom wait for step.
399399
  1. Provide a name for the new step and click the Create Step button.
731731
  1. In the JavaScript editor, add any code in the function area and verify that the function returns a True / False value.
405405

πŸ“˜

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.
  • You can use step parameters, export parameters, and so on in your Custom wait for step. See Add custom validations and actions for more information about custom actions.

Wait for Download

Add a Wait for Download step if you want Testim to pause to ensure a file is completely downloaded before moving on to the next step.

To add a Wait for Download step:

  1. Navigate to the Test Editor for your test.
  2. Hover over the arrow where you want to insert the new step and click Testim predefined steps.
567567
  1. Select the Wait for Download step.
471471
  1. Provide a name for the new step and click the Create Step button.
740740
  1. In the JavaScript editor, add script language to validate the download has completed. See Validate download for more information.
720720
  1. Click the Back Arrow to return to the test editor. Your script will automatically be saved.
469469

Reassign Target Element in Wait For Steps

After a Wait For step has been created, you can reassign the target element or target text in the step. See Editing Target Element Properties for more information.