TestProject Forum

Text = null validation

How do you validate an element’s text equals null?

Hello,
If you want to make sure that your text is equal to an empty string you can use the following logic:

If you want to make sure the element doesn’t have text attribute at all you can use this logic:

On advanced settings revert step result:

image

Trying the “element doesn’t have text attribute” and getting the following results:


image

That doesn’t seem to be working?

Looks like the step return text = null and passed can you please try to use the following method instead:

Take the element locator like in the example below and make sure it’s not found when it has a text attribute:

After I inverted the step and added a text attribute the action failed

How do I do this for mobile? (Android)

Simply add [@text] to your XPath

example:
//androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[1]//android.widget.ImageView[@text]
It will try look for the same element with an attribute = text if it cannot find the element with this attribute you will get the wanted outcome (fail) then simply revert the step.
Or you can use this action:

I can’t tell if this is working or not to be honest. (inverted step enabled)