Using VerifyElementVisible to end while-loop

i’m trying to use VerifyElementVisible to end a loop but in execution, the script just keeps searching for the element after the 30 seconds standard search time have passed. Here is my script:

Integer RowNr = 1

Boolean Action= false

while (true) {

String xpathValue = ('id("postTradeTable")/tbody\[1\]/tr\[' + RowNr) + '\]/td\[4\]/div\[1\]'

TestObject dynamicObject = new TestObject('dynamicObject').addProperty('xpath', com.kms.katalon.core.testobject.ConditionType.EQUALS, 

    xpathValue, true)





Action= WebUI.verifyElementVisible(findTestObject(‘Post Trade/Repo/Show Trade/RC/Set repurchase Date’))

if (Action== true){break}


try to use WebUI.waitForElementVisible(findTestObject(‘Post Trade/Repo/Show Trade/RC/Set repurchase Date’), 1, FailureHandling.OPTIONAL) instead

But how would i transform that into a boolean?

return value from WebUI.waitForElementVisible() is boolean
so use it exactly as verifyElementVisible

#### @[CompileStatic](  
@com.kms.katalon.core.annotation.Keyword(keywordObject =  
StringConstants.KW\_CATEGORIZE\_ELEMENT) static boolean  
to, int timeOut)


Wait until the given web element is visible within timeout.  





true if the element is present and visible; otherwise, false



`to` \- represent a web element  

`timeOut` \- how many seconds to wait (maximum)

WebUI.waitForElementVisible returns boolean. You don’t have to transform anything.

By the way, while(true) is really dangerous expression. You should add at least some timeout in case that element won’t appear after x tries.