Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Saturday, 30 March 2019

Find Objects on a Web Page and Set a Value

'The following example retrieves the collection of WebEdit objects in order to find a
specific WebEdit object in a page and set a value for it.
 Dim EditToSearch, ValueToSet, NumberOfEdits

'This is the value of the 'name' property for the WebEdit object we want to find.
EditToSearch = "credit_card_number"

ValueToSet = "3558986773230578"
'Create a description object to help retrieve allWebEdit objects in a specific page.
Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebEdit"
    oDesc("name").Value = "credit_card_number" 
'Retrieve all WebEdit objects in this page
Set EditCollection = Browser("Book a Flight: Mercury")_
                    .Page("Book a Flight: Mercury").ChildObjects(oDesc)
NumberOfEdits = EditCollection.Count

'Search for a specific WebEdit object and set its value
For i = 0 To NumberOfEdits - 1
    If EditCollection(i).GetROProperty("name") = EditToSearch Then
       EditCollection(i).Set ValueToSet
    End  If 
Next