How use while loop (insteed of waitForElementNotVisible)/set while loop time limit

sir i am using waitForElementNotVisible command with 5 seconds !TIMEOUT_WAIT limit for an loading (.gif) element and its work perfectly.
I read here (waitForVisible (and waitForNOTVisible), assertVisible, assertNotVisible - Selenium IDE Commands Tutorial) that UI.Vision RPA software decided to not support waitForElementNotVisible command to keep things lean.
So i decide to change my code into while loop method.
Sir my problem is that the loading (.gif) element which one i am checking for visibilty its gone between 1-2 seconds and while loop worked. but sometime its hang and showing animated loading.gif (site slow down issue or may be other issue) and while loop running continually. so i want to set timeout limit to while loop 5 second not to element.

Can you please post a link to a test website? Then we can create a macro that works for it.

Just to clarify this further: So you want to wait for this GIF to disappear?

Easy:

  1. Put a counter in your while loop that increases with each iteration
  2. Put a wait ( think it’s called pause) of a couple of seconds or so
  3. Put an if statement if you counter hits a specific number call and just to a goto Label with a “Label” defined outside the while loop

or

use a “Times” loop of “10 iterations” or something and then same thing.
Inside the loop you can jump out with a “goto Label” if the images shows up.

You should use verifyElementPresent command with your locator because this command is wait for element presence while its timout is not reached.

or embed your complete code or target web app.