Password invalid attempt , if 1 sentence is satisfied then test case should be pass

Hi,

If enter invalid password upto 3 times, then every different sentence is showing that measne remaining attempt it showing like,
Incorrect Password 4 attempts remaining
Incorrect Password 3 attempts remaining
Incorrect Password 2 attempts remaining
Incorrect Password 1 attempts remaining

I expect that the script should be passed if I get any one sentence.

So how do you write a script for the expected condition?

Following is a script I have written,

WebUI.openBrowser('')
WebUI.maximizeWindow()
WebUI.navigateToUrl('website')
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Select Organization'))
WebUI.setText(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/input_Select Company_CompanyID'), 
    'Listany New')
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Listany New'))
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Enter User Name'))
WebUI.setText(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/input_User name_txtUserName'), 
    'Amita')
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Enter Password'))
WebUI.setEncryptedText(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/input_Password_txtPassword'), 
    '2MI5LF/YjhgjdsZ3lLyhf7rfGnb0lZQ9g==')
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Login'))
WebUI.closeBrowser()

Before closing I have entered conditions as,

if (UserName=="Amita" && password==β€œ111111”)
	{
	WebUI.verifyElementText(findTestObject('TracetLogin/Basic Validation/Page_Tracet Login - Tracet - Fixed Asset Management System/span_Incorrect Password 4 attempts remaining'),'Incorrect Password 4 attempts remaining')
	}
	
	else if (UserName=="Amita" && password==β€œ111111”)
		
	{
	WebUI.verifyElementText(findTestObject('TracetLogin/Basic Validation/Page_Tracet Login - Tracet - Fixed Asset Management System/span_Incorrect Password 3 attempts remaining'),' Incorrect Password 3 attempts remaining')
	}

Can anyone please tell me how to write this condition-based script?

1 Like

Not sure exactly how the error message is displayed but maybe you could use:

import com.kms.katalon.core.util.KeywordUtil

. . . 
WebUI.click(findTestObject('Object Repository/TracetLogin/Page_Tracet Login - Tracet - Fixed Asset Ma_6ba7fe/span_Login'))
WebUI.waitForPageLoad(10)
if (!WebUI.verifyTextPresent("Incorrect Password \\d attempts remaining", true)) {
    KeywordUtil.markFailed("Phrase blew up")
}
WebUI.closeBrowser()

Edit: the β€œtrue” in verifyTextPresent() means to use RegEx so that we do not have to worry about which number, but can put in a replacement for any number.

The exclamation mark at the beginning means to reverse the boolean that returns from verifyTextPresent(), however, you might try and remove the exclamation mark and instead use: verifyTextNotPresent(). See if either of them work.

RegEx will help

I don’t understand what is the condition you want to check. It seems to me that you want to check if your target web app allows you to try logging in up to 3 times but rejects any more challenges. Do I understand you correctly? If not, please make your description clearer a bit, please.

1 Like