Using control statement on whether checkbox is checked

Hello,

I’m trying to use a control statement in Katalon to do something if a checkbox is checked. Could anyone give some ideas on how we could do this? If element is checked, do this, else do this. I know we already have a verifyelementchecked/not checked ability but I would probably have to use some exception handling. Is there a good way to handle this?

This is it.

if(WebUI.verifyElementChecked(testobject, 1, FailureHandling.OPTIONAL)) {
	println "checked"
} else {
	println "not checked"
}

You need FailureHandling parameter to avoid StepFailedException if element is not checked.

Thanks for the response I tried implementing this but ran into error. I tried something like this to start out:
if (WebUI.verifyElementNotChecked(‘Common/Preferences/Portal Preferences/Portal Sign In Preferences/Portal Status Offline Radiobutton’,
1, FailureHandling.OPTIONAL)) {
println(‘checked’)
} else {
println(‘not checked’)
}

but trying this out just threw me an error:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementNotChecked() is applicable for argument types: (java.lang.String, java.lang.Integer, com.kms.katalon.core.model.FailureHandling) values: [Common/Preferences/Portal Preferences/Portal Sign In Preferences/Portal Status Offline Radiobutton, …]

Change

if (WebUI.verifyElementNotChecked(‘Common/Preferences/Portal Preferences/Portal Sign In Preferences/Portal Status Offline Radiobutton’,
1, FailureHandling.OPTIONAL)) {
println(‘checked’)
} else {
println(‘not checked’)
}

to

if (WebUI.verifyElementNotChecked(findTestObject(‘Common/Preferences/Portal Preferences/Portal Sign In Preferences/Portal Status Offline Radiobutton’),
1, FailureHandling.OPTIONAL)) {
println(‘checked’)
} else {
println(‘not checked’)
}