Unable to verify text of object because is stored as variable even though UI is text

Hi All,

New here, i’ve read a few articles to try and see if this has been posted but I couldn’t find anything.

Long story short i’m using the Object Spy to get objects for a website. The field that is presented is a text field and has text populated. However when looking at the Xpath or Attributes it looks like it’s being stored as a variable.

Text field in UI shows “Apple”
Object inspector Xpath and Attribute shows @type = text and @id = fruit and @name = fruitName

My script was:
WebUI.verifyElementText(findTestObject(‘OBJECTURL’), ‘Apple’)

The above is failing because apple isn’t seen in the value of the above. What line of script would I use to pull the actual value being presented in UI? in this case, Apple?

Thanks in advance!

You need to understand how the HTML DOM of the target web page looks like.

In order to see the HTML DOM, you must learn how to use DevTools of browsers. See the following tutorial.

Please show us how the HTML element looks like in the DevTool.

And also show us how your Test Object OBJECTURL is defined. Take the screenshot of the definition of the OBJECTURL and show it to us.

Possibly you would need to study XPath technology. Have a look at

A warning: You should not expect the Object Spy tool automagically solve your problems. It fails to quite often. You need to be skilled; you must understand HTML, CSS Selector and/or XPath.

When you look at the HTML, you will be able to see where your “text” is stored. If the “text” is within the “value” attribute, then you can try:

WebUI.verifyElementAttributeValue(findTestObject('OBJECTURL'), "value", 'Apple', 10)

If I use F12, select element inspector and highlight over the Apple element it expands the following Divs


input placeholder=" " type=“text” id=“FruitName*” aria-label=" " name=“fruit” class=“undefined form-control d-inline-block” autocomplete=“off” data-testid=“fruittNameTestId” min=“” maxlength=“” value=“”

label class=“mat-label” for=“ActualFruitName*”>Actual Fruit Name *</label

div class=“error-message”


Even though the UI clearly shows Apple:

So should I be using id=fruitname as the “value” line as you indicated?

Not in this instance if I get your “code”. However, what element are you using, the input or the label, for the pathway to your “Actual Fruit Name”? It should be the label.
Unfortunately, you did not format the code (by putting 3 backticks, like ```, on a line above the code and another 3 backticks on a line below the code–the backtick is found on the same key as the tilde ~)

So, perhaps, a pathway could be:

and then you can try your:
WebUI.verifyElementText(findTestObject('OBJECTURL'), 'Apple')

Edit: if you are using the asterisk as a identifier for other fruits, and it doesn’t actually exist in the code, then I hope you can understand what I am trying to do. You will have to replace “FruitName*” with what is actually in that position.

Also, if you have a lot of added attributes in your collected element, either delete them or ensure the attributes are NOT checked. I generally only check tag and xpath.

These are actually two different elements. One is the label for the field, and the one in blue is another element.


So where you see “fruit name *” that is the top static label. The bottom one is the value but is treated as different element, I would assume here in the code:

input placeholder=" " type=“text” id=“FruitName*” aria-label=" " name=“fruit” class=“undefined form-control d-inline-block” autocomplete=“off” data-testid=“fruittNameTestId” min=“” maxlength=“” value=“”

The label “fruit name *” is the label above the element for where im looking for the data. The one in the yellow is just the label, the one in the blue is where im looking for the value


Please show the HTML source of the target web page around “Actual Fruit Name” and “Apple”.

Unfortunately I cannot share it as it is a restricted site which i’m running testing on. Trying to test using your suggestions but it still returns a " " response. I’m sorry I cant be of more help showing this, been doing my head in!

Seems all the parameters on the site are like this so for checking valid data I can’t use any of the fields.

I will keep trying and see if I can get any closer.

If you can not share HTML source at all, it is very difficult for others to advise anything.

Would you agree with closing this topic?

Open dev tools. Use find (ctrl and f). Search for the word ‘apple’. Click on each result in the page source code and see if the relevant fruit is highlighted on the UI. If so, this is what you want to capture as xpath. Once you create an xpath, verify it in dev tools. Ie paste into search and make sure it finds the element expected.