Waiting for element to disappear (from users perspective)

There is an image shown when page content is loading, and I want to wait for it to disappear. It would tell for sure that page content ready to use.

I’m using the following code to wait for element to become ‘not visible’:

WebUI.waitForElementNotVisible(testObject, timeout, FailureHandling.STOP_ON_FAILURE)

But when image disappears from DOM, Katalon throws StaleElementReferenceException. Seems like waitForElementNotVisible method work only for objects that are permanently existing in HTML code of the page. But my intentions are to have method which determine element visibility from user’s perspective: user just wants to confirm that they doesn’t see that element in the application anymore (no matter what the reason is).

So, the question is: is there a way to use Katalon-native methods to implement my needs? Or should I implement that mechanism on my own?

1 Like

perhaps this one may work, give it a try:

1 Like

Thanks, but what if the element will become hidden instead of just disappearing from the DOM? THe logic I would like to be implemented is as following: element is treated “disappeared” when it is:

  1. becomes invisible
  2. is removed from the HTML page code

Both situations look similar to the user, and when we use BDD approach, we would like to behave as a user when testing application. So, the step would be “The I confirm element disappear in 10 seconds”. And when it comes to implementation, it’s great to have a method which returns TRUE for both situations: whether element is invisible or it is not present in DOM.

Seems like we should implement it on our own.

Probably. I did. I called it (actually, them)

  1. isVisibleToHumans
  2. isNotVisibleToHumans.

They are JavaScript functions derived from bits and pieces I found on StackOverflow etc.

If you’re comfortable working in Groovy(JavaScript(CSS)), let me know.