How would I use an OR with WebUI.verifyEqual()

Katalon Studio Version:
KSE 8.4.0, Build 208
Windows 10 Enterprise (64-bit)
Chrome Version 107.0.5304.122 (Official Build) (32-bit)

Hi Folks,
How would I use an OR with WebUI.verifyEqual()?
The following is not working:

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
String text = "SampleText2"
(WebUI.verifyEqual(text.equals("SampleText"), true) || WebUI.verifyEqual(text.equals("SampleText2"), true))

You should just write ordinary groovy code:

if (text.equals("sampleText") || text.equals("sampleText2")) {
   ...
} else {
   ...
}

You should check the doc of WebUI.verifyEqual()

WebUI.verifyEqual only works for Numbers: WebUI.verifyEqual(10, numvar). ---- I don’t know who will use this.

Perhaps WebUI.verifyEqual() might be usefull if you use the Manual mode of Test Case editor. I think that the Manual mode is designed with assumption that people never want to see if … then … else … clauses. In the Script mode, WebUI.verifyEqual() looks to be a strange beast. It is useless in the Script mode.

Thanks @kazurayam,
I should have known better…

This works as expected for me…

def text = "SampleText"
if (text.equals("SampleText") || text.equals("SampleText2")) {
	println("TextResult: " + text)
}

def text2 = "SampleText2"
if (text2.contains("SampleText") || text2.contains("SampleText2")) {
	println("TextResult2: " + text2)
}

Just to note that I use WebUI.verifyEqual() to compare the number of items in drop-down lists. It did catch one concern in 3 years.
As an example:

numItems =  WebUI.getNumberOfTotalOption(findTestObject('select_ProvinceState'))
WebUI.verifyEqual(numItems, 14)   // count 1 more for blank

Edit: Also, we had a discussion on this forum awhile back on why WebUI.verifyEqual() did not work on Strings, which are objects, which are supposed to be the parameters that need to be used. We found out if you used def to define your String (like you do in your second post) instead of String (which you used in your first post), it worked.

1 Like