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?
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: id("FruitName*")/following-sibling::label
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.
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.
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.