Unexpected Behavior with While Loop

In my Katalon test, there is a step that requires some additional processing. During this time, the words “Awaiting Validation” will appear on the page. I am trying to create a while loop that will delay for 10 seconds, then click on a Refresh button on the page (not the browser refresh button) if the page contains “Awaiting Validation”. Once the “Awaiting Validation” text is no longer present on the page, click on the “Assign to Me” link, Here is the snippet from my script:

while (WebUI.verifyTextPresent('Awaiting Validation', false)) {
    WebUI.click(findTestObject('Console/Refresh button'))
WebUI.click(findTestObject('Console/Assign to Me link'))

It works when the text “Awaiting Validation” appears on the page, but the script dies (does not continue beyond the while loop - does not click on the “Assign to Me” link) when the text does not appear on the page.The page loads, contains the “Awaiting Validation” text, the script recognizes it, delays 10 seconds, clicks the Refresh button, then, once the page reloads and no longer contains the “Awaiting Validation” text, script execution stops and I get this:

Unable to verify text 'Awaiting Validation' is present  (Root cause: Text 'Awaiting Validation' is not present on page )

Not the behavior that I was expecting. What am I doing wrong?

in verifyTextPresent use failure control handling either FailureHandling.CONTINUE_ON_FAILURE or FailureHandling.OPTIONAL

1 Like

Thank you! That fixed it!