'Verify Element Text' passes even when object not found

using KSE 8.0.5 on Windows 10 and I see odd behaviour with Web UI keyword ‘Verify Element Text’ . When object is not found, step still passes and confirmation message is:
“Actual text and expected text of test object ‘Object Repository/myObject’ are matched.”

yet I also see this in the log:
"Unable to find the element located by ‘By.xpath: //*[contains(@id, ‘endtime-field-label’) and contains(@for, ‘endtime-endtime.fieldControl-date-time-input’) and (text() = ‘End Time’ or . = ‘End Time’)]’. Please recheck the objects properties to make sure the desired element is located. "

My script looks like:
WebUI.verifyElementText(findTestObject(‘MyObjects/MyObject’), EndTime)
My project default is ‘Stop on failure’.
I have a number of these checks - some pass and presumably the xpath and value is correct. The problem is that I shouldn’t be able to match the object text if the object is not found. To add, this step took 31 seconds to run (to default timeout).
Regards, Dan

Please use code formatting syntax in your posts to make them better readable.

You currently have this:

Here you seem to have a variable named EndTime. I guess the variable is empty. An empty string will match any string, so you will inevitably see a message “Actual text and expected text of test object ‘Object Repository/myObject’ are matched.”

Possibly you should change it to:

    "End Time")

If you have this XPath expression

//*[contains(@id, ‘endtime-field-label’) 
    and contains(@for, ‘endtime-endtime.fieldControl-date-time-input’) 
    and (text() = ‘End Time’ or . = ‘End Time’)]


You should not use WebUI.verifyElementText(TestObject,Striig text) here. You should rather use WebU.verifyElementPresent() keyword. Because the XPath expression contains a test for a string literal `“End Time” already.

If you want to use WebUI.verifyElemetText() keyword, then you should change your XPath to

//*[contains(@id, ‘endtime-field-label’)

You should not repeat testing if the element contains a text End Time in the keyword-call and the XPath expression.

You should note that the XPath expression generated by Recorder&Spy tools are not always the best one. You should review the XPath expressions. And you should not hesitate to edit the XPath expressions.

Hi @kazurayam Completely agree on the xpath comment and it is on the list to fix :slight_smile:
… but that still leaves a question around how my step passes when xpath not found?
This step should do two things - answer whether the element is present and if it is, that the text it contains is correct. I’m unclear what Katalon is comparing otherwise. Thanks Dan

I don’t have any answer to your question. I suppose you are confused somehow.

You can read the source of WebUI.verifyElementText keyword here:

Review your code and the keyword source; look into the log carefully. You may get some Aha!

Hi again
the aha moment arrived :flushed:
Thanks for your input - although the Log Viewer claims that the xpath is not found, the console reveals that smart healing has found an acceptable alternative and the text is as per the variable expected.
Will be putting your other tips into practice, as there is no point verifying text where the xpath performs the same function.

I don’t use it. It does something I do not expect. It confuses me.


I could not agree more.

I suppose if someone were not familiar with how element location works and did not have any of their own strategies, then smart healing might appear to be useful. But when you have your own way of targeting elements, smart healing quickly becomes more harmful than helpful.