Verify element text not "seeing text"

Hello I have a simple script to enter text into a text field object, and simply verify that the text that was input is the correct text and I get an error:

Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘communication text present’ of test object ‘Object Repository/OLFamily/Sales and Marketing Communication Text Input Field’ are NOT matched.

script: I work in manual mode, but here is a copy of ‘script’ mode

WebUI.click(findTestObject(‘OLFamily/Link to Sales and Marketing Section’))

WebUI.click(findTestObject(‘OLFamily/Sales and Marketing Communication Text Input Field’))

WebUI.setText(findTestObject(‘OLFamily/Sales and Marketing Communication Text Input Field’), ‘communication text present’)

WebUI.verifyElementText(findTestObject(‘OLFamily/Sales and Marketing Communication Text Input Field’), ‘communication text present’)

Any input would be helpful,

thanks

Unfortunately, you’re suffering from a poor choice made by the devs when they named the APIs.

Try:

WebUI.verifyElementAttributeValue(findTestObject('OLFamily/Sales and Marketing Communication Text Input Field'), 'value', 'communication text present')
1 Like

This indeed worked, however I wish I understood the “why” behind it. Im confused about the Verify Element Attribute Value WebUI attributes and how to set them: This is what they look like:

image

thanks for your valuable help!

You are right to be confused - it’s not your fault.

Firstly, In automation testing, you normally don’t (and strictly speaking, shouldn’t) set them - simple reason, regular users can’t set attributes so why should your automation code ever need to?

However, the value property (which is not the same as the value attribute) is set via setText (like I said, poor API naming choices) and is read back using *ElementAttribute APIs as you’ve seen.

So when you think you’re getting the value of the value attribute using verifyElementAttributeValue, you’re not - you’re getting the value of element’s value property.

Messy? Oh yeah. Hence…