how to verify the field is null

I use this and it still pass, i want to verify that the element has null value WebUI.verifyElementText(findTestObject('object), ‘’)

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

There is a difference between null and the empty string. Null is the complete absence of an object. The empty string is just no text–there is an object but it has zero length. So, if you want null, then just ensure the “findTestObject” doesn’t exist in your OR. :smile:
What you have above is a test that the object has zero length. Another way to do it could be:

WebUI.verifyElementAttributeValue(findTestObject('object'), "value", "", 10)

If you want more information, then you will have to explain further.

Edit: maybe you mean that the object does not exist on the page. You can do this perhaps by:

WebUI.verifyElementNotPresent(findTestObject('object'), 2)
or
WebUI.verifyElementNotVisible(findTestObject('object'))

The difference is that “NotPresent” is not on the page, which may be your “null”, and “NotVisible” is somewhere on the page but is not visible at the current time, like it may have an attribute, “display:none”. You will note that I only put the “timeOut” for the “NotPresent” at 2. The system will actually stall on this statement for the full “timeOut”, so I generally make it a small amount. Do not put the “timeOut” at 0 as you may encounter false situations.

Example:
WebUI.waitForElementVisible(findTestObject('myPage/input_GeneralInfo.DocuLink'), 10)

WebUI.verifyElementVisible(findTestObject('myPage/input_GeneralInfo.DocuLink'))

WebUI.verifyElementVisible(findTestObject('myPage/button_GeneralInfo.RemoveDocument'))

WebUI.delay(0.5)

WebUI.click(findTestObject('myPage/button_GeneralInfo.RemoveDocument'))

WebUI.waitForElementNotPresent(findTestObject('myPage/input_GeneralInfo.DocuLink'), 2)

WebUI.verifyElementNotPresent(findTestObject('myPage/input_GeneralInfo.DocuLink'), 2)

WebUI.verifyElementNotPresent(findTestObject('myPage/button_GeneralInfo.RemoveDocument'), 2)