How to pass test case when If condition is false

Hi,

In my test case, I have to verify that a field cannot be edited(that i cannot input data into the field). So, I perform the below steps

  1. Set Text to the field.
  2. If SetText == false, then keywordutils.markpassed(field cannot be edited)
  3. Else, keywordutils.markfailed(field can be edited)

Please note: These objects do not have an attribute “Input field” or “ReadOnly” etc.

I need my test case to pass, when my If condition is false. Presently, I am unable to do so. The Test case fails, since the Set Text boolean is false(as expected). Has anybody done this before? Please suggest.

My code is as below

boolean Date_Reported = WebUI.setText(findTestObject(‘Object Repository/___________’),
‘text’, FailureHandling.CONTINUE_ON_FAILURE)

if (Date_Reported == false) {
KeywordUtil.markPassed(‘Expected Result : The application does not allow the user to edit the field.’)
} else {
KeywordUtil.markFailed(‘Failure: The application allows the user to edit the field.’)
}

Change it to:

boolean Date_Reported = WebUI.setText(findTestObject(‘Object Repository/___________’),
‘text’, FailureHandling.OPTIONAL)