How to do negative testing in login test case?

Hi,

Newbie here. I noticed that after record and play for my login test case (happy path), as expected, there shouldn’t be any failed in the steps. Then I tried doing negative steps by removing or changing the value of either the username text field or the password text field, I get the same result as “Passed”. Please refer to below code:

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ’ ')

Also, I tried inserting failurehandling but what should be the behavior/expected result of this? On my side, nothing happens.

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ‘’, FailureHandling.STOP_ON_FAILURE)

Appreciate your immediate feedback on this.

Ang, Ferdinand said:

Hi,

Newbie here. I noticed that after record and play for my login test case (happy path), as expected, there shouldn’t be any failed in the steps. Then I tried doing negative steps by removing or changing the value of either the username text field or the password text field, I get the same result as “Passed”. Please refer to below code:

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ’ ')

Also, I tried inserting failurehandling but what should be the behavior/expected result of this? On my side, nothing happens.

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ‘’, FailureHandling.STOP_ON_FAILURE)

Appreciate your immediate feedback on this.

Up

Hi Ang

Katalon Studio will do what you tell it to do. So, if you tell it to send some text (or empty spaces) to an input field, it will hopefully send that text to the input. But KS doesn’t know what to expect. That is up to you.
What happens when you type blank spaces to the input_username field on your page (without using Katalon)? You probably get some notification that says something like: “Wrong username or password!” in bright red letters. :slight_smile:
So, you could create your test like this:
- enter wrong username/password
- verify error text appears

Hope this helps

Can anyone send the script on the same issue.How to write the script to test negative login test case and displaying a error validation

WebUI.openBrowser('www.myapp.com')
WebUI.setText(findTesObject('path-to-username-input'), 'myUsername')
WebUI.setText(findTesObject('path-to-password-input'), 'wrong password')
WebUI.verifyTextPresent('Wrong password!')
1 Like

Ang, Ferdinand said:

Hi,

Newbie here. I noticed that after record and play for my login test case (happy path), as expected, there shouldn’t be any failed in the steps. Then I tried doing negative steps by removing or changing the value of either the username text field or the password text field, I get the same result as “Passed”. Please refer to below code:

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ’ ')

Also, I tried inserting failurehandling but what should be the behavior/expected result of this? On my side, nothing happens.

WebUI.setText(findTestObject(‘Login/Page_Admin Portal/input_username’), ‘’, FailureHandling.STOP_ON_FAILURE)

Appreciate your immediate feedback on this.

i love when people need ‘imediate answer’ but don’t have time to read a bit about testing in general

have you considered to negate the assertion?

when we enter the blank password & error message popup wrong username & password this case in result showing pass
why ks recording error message but in result showing passed