I changed your “compare” function into “compareLetter” as I don’t like to use phrases that are possibly reserved words.
As for if there is an easier way, that is possible but try your way and then keep investigating afterwards, such as using a Sort routine for Lists that is possible.
Edit: You should try your routine idea also: return wordOne[0] <= wordTwo[0];
The WebUI.verifyMatch keyword and WebUI.verifyEqual keyword emit silly messages, such as:
FAILED 02-27-2018 04:48:39 午後 Unable to verifyequal between actuial object ‘true’ and expected object ‘false’ (Root cause: Actual object ‘true’ and expected object ‘false’ are not equal)
Do you understand what this message is meant for?
true and false are not equal
This sounds philosophical, but I don’t think this message is useful. I would never use these poorly designed built-in Keywords…
Instead, I would use KeywordUtil.markFailed(String) or my Custom Keyword :
One last point if you don’t mind on the above statement. The last true indicates whether or not you want to use Regular Expression (RegEx) and true means you do. For the above statement, you have no RegEx characters and the comparison is small enough that it may not matter, however, you should know that doing a RegEx comparison as to a direct comparison can cause you concerns if you don’t know what you are doing. You should use false in the third position as a default unless you really need to use RegEx.
I use WebUI.verifyMatch in other cases as well. E.g.:
topMachineName = WebUI.getText(findTestObject('Smoke Test Objects/Fleet/Top menu machine name'))
leftMenuFirstMachineName = WebUI.getText(findTestObject('Smoke Test Objects/Fleet/First machine on AllProject or Favorites Tab'))
WebUI.verifyMatch(topMachineName, leftMenuFirstMachineName, true)
@grylion54 it seems I should verify matching in another way?
I use verifyMatch as well, and it does what I want. In my case, I want to do the comparison and keep going. I don’t want to fail my test, but to instead tell me when something is not what I was expecting. Personally, start with verifyMatch and if you have concerns somewhen, then change it.
With the above, again you should not use true, but false.