If statement does not continue - if(!found)

Hello, I got this piece of code:

actual_speed_mobile = WebUI.getText(findTestObject('Page_PageSpeed Insights/div_79'))

def actual_speed_to_be_checked_mobile = actual_speed_mobile.toInteger()

boolean found = false

if (actual_speed_to_be_checked_mobile >= 99) {
 println('Page speed is good')

 found = true
}

if (!found){
 'THE SPEED IS NOT GOOD'
 throw new StepFailedException('THE SPEED IS NOT GOOD')

 }

WebUI.click(findTestObject('desktop/Page_PageSpeed Insights/div_Desktop'))

After :

if (!found){
 'THE SPEED IS NOT GOOD'
 throw new StepFailedException('THE SPEED IS NOT GOOD')

I want to continue to test not to stop. In the Project - Settings I got the option set Continue_on_failure.

But it still fails and does not continue to the next step.

Thank you in advance!

You can’t continue after a throw ... exception. In the case of a conventional executing Test Case, throw causes an immediate exit.

What you may want to do is produce a warning:

import com.kms.katalon.core.util.KeywordUtil

KeywordUtil.markWarning("This is a warning")
1 Like

Yes is a solution but in report in HTML is not displayed any info there is a warning only if I open the test step.

I found a way I replace Warning with Failed and the test case now is failed.

import com.kms.katalon.core.util.KeywordUtil
KeywordUtil.markFailed('THE SPEED IS NOT GOOD')

1 Like