Unable to verify object 'Object Repository/Form Search/Search_datatable' is not present

I am working on Search functionality. added multiple data in my excel sheet and here is the functionality how it works. if i give the exact id it will be navigated to the next page or will be stayed in the same page with partial search.
my test case is passing when my script runs with the exact id and coming back to the search page. when the loop enters the 2nd set data (partial search) and able to display the results and it is not entering the 3rd data. here is the code i have written.

for (int rowNum = 1; rowNum <= findTestData(‘LocationID’).getRowNumbers(); rowNum++) {
WebUI.setText(findTestObject(‘Form Search/input_Location ID or Name_LocIdSearchString’), findTestData(‘LocationID’).getValue(1, rowNum))

WebUI.click(findTestObject('Form Search/button_Search'))


if (WebUI.verifyElementNotPresent(findTestObject('Form Search/Search_datatable'), 0)) {
    WebUI.verifyElementPresent(findTestObject('Form Search/p_Forms Search             Filing History'), 0)


    WebUI.click(findTestObject('Object Repository/Page_SAGE/a_Forms'))

    WebUI.click(findTestObject('Object Repository/Page_SAGE/a_Informational Forms Search'))
} else {
    WebUI.verifyElementPresent(findTestObject('Form Search/h1_Form Search'), 0)


error logs:
Elapsed time: 57.716s

Test Cases/TC_Form Search FAILED.
com.kms.katalon.core.exception.StepFailedException: Unable to verify object ‘Object Repository/Form Search/Search_datatable’ is not present


I guess the next part is “Caused by […] Web element […] is present”.

Present != Visible : an hidden element will be mark as “present” because it is on the DOM

Thanks Helene…but could you please gimme more clarification on this:
I guess the next part is “Caused by […] Web element […] is present”.

Present != Visible : an hidden element will be mark as “present” because it is on the DOM

What she meant is there’s a difference between “present” and “visible”.

You test fail because the element is still present. The test isn’t wrong and the code is working correctly.

The element is still present in the DOM, so the test fail. If you want to verify that the object isn’t visible to the user, you have to use verifyElementNotVisible().

Also, verifyElement() throw an exception when it fails, so you will never reach your else() statement. You should use waitForElement() instead.

I would recommend not using Thread.sleep() and use waitForElementVisible(findTestObject(‘Object Repository/Page_SAGE/a_Forms’), 10) instead. It will wait maximum 10 second or until the object is visible. It makes the test flow faster.

1 Like

Exactly @Nilau

Or verifyElement with FailureHandling.OPTIONAL

thanks Helene.