How to use if to compare boolean type true and string type true? Can the boolean type be converted to a string type?
Please show us what you have done. Show us what you expected to see and what actually saw. Please show us your code.
is_present is the false returned by verify element present, it is of Boolean type,
findTestData(‘Deploy/OverlayNetwork/Lan_Interface/Add_OverlayLan’).getValue(15, index)) {
The result of WebUI.click(findTestObject(‘Page_IO Controller WAN/deploy/overlay_network/lan_interface/btn_OverlayLan_Vrrp’)) is also false, but it is a string type, so the result of the comparison between the two is not equal, but I hope they are equal
java.lang.Boolean.valueOf(String)
returns boolean value. For example, the following code would be what you want.
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
boolean is_present = false
String findTestDataResult = "false"
if (is_present == findTestDataResult) {
WebUI.comment("1st challenge: equal")
} else {
WebUI.comment("1st challenge: not equal")
}
boolean evaluated = Boolean.valueOf(findTestDataResult)
if (is_present == evaluated) {
WebUI.comment("2nd challenge: equal")
} else {
WebUI.comment("2nd challenge: not equal")
}
thank you , i try