Object Identification by Descriptive Programming

Descriptive Programming Using VbScript

Find All List Objects On a Web Page :


Sub ChildObjects_Example()
'The following example uses the ChildObjects method to find all the
'list objects on a Web page, and then to select an item in each list.

Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebList"
Set Lists = Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(oDesc)
    NumberOfLists = Lists.Count()
For i = 0 To NumberOfLists - 1
    Lists(i).Select i + 1
Next

End Sub



Find All Web Edit Objects On a Web Page :


Sub ChildObjects_Example()

'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 all WebEdit 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
End Sub



Find All Specific Web Edit Objects On a Web Page :

Sub ChildObjects_Example()

'The following example retrieves the collection of
'WebEdit objects that contain credit card numbers
'and inserts them in an Excel file.

Dim NumberOfEdits

'Create a Description object to help retrieve all
'WebEdit objects in a specific page.
Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebEdit"

'Retrieve all WebEdit objects from this page.
Set EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)
NumberOfEdits = EditCollection.Count

'Use the GetROProperty to retrieve the "text" property
'(which in this case represents a credit card number),
'and insert all retrieved credit card numbers in an Excel file.
For i = 0 To NumberOfEdits - 1
     CurrentCreditNumber = EditCollection(i).GetROProperty("text")
     WriteToCreditCardNumberExcelFile (CurrentCreditNumber)
Next

End Sub




Post a Comment

Previous Post Next Post