How to use wait for element not visible correctly

Repeated operations many times, wait for element not visible will always encounter the same problem and report an error, which can be avoided by directly using delay
I don’t know if there is a problem with my writing? code show as below
WebUI.waitForElementNotVisible(findTestObject(‘Page_IO Controller WAN/Design/Network_Design/Link_Setting/tbtn_LinkSetting_RouteDomain_Add_Confirm’),
30)

log.txt (76.8 KB)

I just solved it and need to add a third parameter WebUI.waitForElementNotVisible(findTestObject(‘Page_IO Controller WAN/Design/Network_Design/Link_Setting/tbtn_LinkSetting_RouteDomain_Add_Confirm’), 30, FailureHandling.OPTIONAL)

You can read the source code of WebUI.waitForElementNotVisible() keyword in Java here:

@1968693027

This code tells me:

  1. you are expecting an HTML element to be possibly present in the page at first,
  2. and you are expecting the element to disappear from the page within 30 seconds.
  3. but in fact the HTML element stayed present after 30 seconds,
  4. therefore the WebUI.waitForElementNotVisible() keyword informed you of the fact

I suppose the keyword is working as designed.


You specified FailureHandling.OPTIONAL as the 3rd argument. This means, you instructed the keyword:

  • Be quiet! Don’t mark this time of test execution as FAILED even if the HTML element is still visible after 30 seconds.

Do you think it is an acceptable solution? I guess, it is not. I suppose, you should check if the target HTML element is really present after 30 seconds or not. If the element is found there, that is the real problem you should look at.

I also understand this principle, but I often encounter elements that are no longer visible, and still report errors. Only when the third keyword is added can it run correctly. This is the biggest problem I am confused about.

this keyword calls WebElement.isDisplayed method.

the following Stackoverflow thread tells us that isDislayed method sometimes behaves NOT as you naively expect.

Be aware of this complexity in mind, you should examine the HTML DOM of your target page.