I’ve seen many times that the Katalon script does not REALLY waits until the page or the element is completely loaded and ready to be clickable. Doesn’t matter if I use:
WebUI.waitForPageLoad(60)
WebUI.waitForElementPresent(findTestObject(....), 60)
WebUI.waitForElementVisible(findTestObject( ..... ), 60)
WebUI.waitForElementClickable(findTestObject( .....), 60)
This resulting in timeouts and errors.
I have implemented a check that is cumbersome but WORKS EVERY TIME. It shouldn’t be necessary having the above mentioned calls.
This loop REALLY DOES THE TRICK in all occasions, if I run 50 test senarios (scripts) with maybe 4 variations each so I actually run 200 scripts it is extremely irritating to get errors because of timeouts due to slow comms. And that type of errors are way too common.
for (int j = 0; j <= 120; j++) {
if (WebUI.waitForElementNotPresent(findTestObject(‘REPOSITORY/Button’), 5) == false) {
WebUI.comment(‘Button is ready. Continue.’)
WebUI.waitForElementPresent(findTestObject(‘REPOSITORY/Button’), 60)
WebUI.waitForElementVisible(findTestObject(‘REPOSITORY/Button’), 60)
WebUI.waitForElementClickable(findTestObject(‘REPOSITORY/Button’), 60)
WebUI.click(findTestObject(‘REPOSITORY/Button’))
break
} else {
WebUI.comment(‘Button is still not ready. Wait.’)
WebUI.delay(1)
}
}
This certainly can be improved in a thousand ways but it WORKS 100% as it is now. I use it for critical fields that have given me problems (often, but not only, the first field in a page), since WebUI.waitForPageLoad does not, according to my experience, completely waits for page load. The three waits above (Present, Visible, Clickable) might seem superfluous when waitForElementNotPresent has returned ‘false’ but that is not true, maybe because they give a little pause before clicking, which is the small difference needed for the above check to be rock solid and to never fail.
MY QUESTION IS: how can the above check be performed smarter.