Retrieving the value from a WebElement
I'm having a real problem trying to retrieve the values from WebElement objects. I'm using UFT 11.53 with Web Add-in, to test a web application in IE8 but every object on the page shows up as a WebElement under the page object.
There are 2 sections I need to get the data from in order to compare the values with variables. One holds Surname, Forename, Date of Birth, Date of Issue and Date of Expiry, the other holds 3 messages, but as the only attribute that changes are the ones that are dynamic, I cannot uniquely identify the fields.
Does anyone know how to get round this, I've attached what the object spy comes back with for each field and the holding object.
If you have the web addin installed and you are opening QTP before the Browser then these may not be HTTP/S objects
Do you have some embedded objects like JaveTables etc?
Try opening in Firefox (You will need the FF QTP addin) and see what the Object Spy 'sees' the objects as.
I'm opening QTP before the browser, as I thought that is what you're meant to do.
No, there's no tables showing up at all, I was hoping there would have been, would have made it a bit easier. Everything shows up as WebElements.
It's a locked down machine, so it's difficult to get software installed on it, but I'll see if I can get FF and Chrome on, to see if that makes a difference. Do I need the FF QTP Addin if I'm using 11.53?
Ask your developers what they are using in the web pages (not on the application servers but the client side)
When you view the page in IE using the object spy do all objects show as webelements?
If the point is to verify if the webelements contain some known values, isn't it adequate to use SetTOProperty to set the object property to the known values, and check if the object exists? That covers the positive case, though of course it can't retrieve the actual value in the case where the object is not found...
Alternatively, it seems the objects could be found based on coordinates. I know this is generally a terrible approach, but may be valid (considering the limitations) depending on the flux in your product.
Lastly - I have seen webelements defined based on their xpath, but I don't see that property in your pdf... Is it possible this property is available for you to use?
I don't think there's any issue with UFT but it's behaving normally as it should.
Originally Posted by brigna
The object in question is the HTML Definition/Description List object. As there's no special object type defined in the Web Add-in to deal with Definition List(dl, dt & dd tags), UFT is treating them as generic objects i.e WebElement. And that's case with SPAN tags too.
So you would need to get the dl object, loop through the child objects(dt/dd) & extract the values.