Decision-making 'if' stops the loop

Hi there,
I have problem with the Decision-making statment “IF”. My code looks like this

Why when condition in if is false the whole loop stops?
I try add "continue statments but it doesn’t work.

petla_for.png

You have to add correct FailureHandling behavior to verifyElementPresent keyword. Katalon automatically stops the test when verifyElementPresent is not true (default FailureHandling is Stop on failure).

Try this one (it throws WARNING instead of FAILED) :
if (WebUI.verifyElementPresent(newValuePlus, 1, FailureHandling.OPTIONAL))

2 Likes

But when I use FailureHandling.OPTIONAL test case result will be Failed?

It won’t. It will just log WARNING message that element xxx is not present.

Okey! thanks :slight_smile:

Welcome!

Hello there,

I have a function that checks the presence of an element - DoesElementExists (WebDriver driver,By selector) that i had written in Selenium and i want to use the same in katalon. The problem is if the element does not exist, the If condition fails and the script stops.
I am not using inbuilt Katalon keyword - VerifyElementPresent as my element property keeps changing each time i visit the page.

For example - I have to check the presence of a date field in a dynamic table and i used to pass the following arguments to the DoesElementPresent function in my selenium script.

if(DoesElementExists(driver, (By.id(“ctl00_ContentPlaceHolder1_gvServiceAuditDetail_ctl0”+i+"_txtAuditDate"))))

{

driver.findElement(By.id(“ctl00_ContentPlaceHolder1_gvServiceAuditDetail_ctl0”+i+"_txtAuditDate")).sendKeys(StartDate);

}

This works in Katalon if the element is present. If the element is not present, then the script stops with no element found exception.

Could someone please help me with this? Is there a way i can have a optional failure handling in If condition?