Hi guys,
I just wanna ask, is it possible to verify the wording of error message like this
without capturing the object?
maybe on the FSD, the error message was clearly written like “Login failed! Please ensure the username and password are valid.”, but I’m not sure is there a typo or not
usually, I try to capture the object of the error message first and then try to using WebUI.verifymatch() like this:
String username = “John”
String password = “Password”
String Errormsg = “Login failed! Please ensure the username and password are valid.”
//Open browser
WebUI.openBrowser(‘https://katalon-demo-cura.herokuapp.com/’)
//Click option button
WebUI.click(findTestObject(‘Homepage/Option_btn’))
//Click login button
WebUI.click(findTestObject(‘Homepage/Login_btn’))
//Set the username and password
WebUI.setText(findTestObject(‘Login/Username_field’), username)
WebUI.setText(findTestObject(‘Login/Pass_field’), password)
//Click login button
WebUI.click(findTestObject(‘Login/Login_btn’))
//verify the error message is appear
if(WebUI.verifyElementPresent(findTestObject(‘Login/Err_msg’), 30)) {
KeywordUtil.markPassed(“Error message is appear”)
}else {
KeywordUtil.markFailed(“Error message does not appear”)
}
//verify the wording message
Errmsg_notif = WebUI.getText(findTestObject(‘Login/Err_msg’))
if(WebUI.verifyMatch(Errmsg_notif, Errormsg, false)) {
KeywordUtil.markPassed(“Wording is fine”)
}else {
KeywordUtil.markFailed(“There’s a typo”)
}