Descriptive Programming Using VbScript
Find All List Objects On a Web Page :
Sub ChildObjects_Example()
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()
Dim EditToSearch, ValueToSet, NumberOfEdits
EditToSearch = "credit_card_number"
ValueToSet = "3558986773230578"
Set oDesc = Description.Create()
oDesc("micclass").Value = "WebEdit"
oDesc("name").Value = "credit_card_number"
Set EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)
NumberOfEdits = EditCollection.Count
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()
Dim NumberOfEdits
Set oDesc = Description.Create()
oDesc("micclass").Value = "WebEdit"
Set EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)
NumberOfEdits = EditCollection.Count
For i = 0 To NumberOfEdits - 1
CurrentCreditNumber = EditCollection(i).GetROProperty("text")
WriteToCreditCardNumberExcelFile (CurrentCreditNumber)
Next
End Sub
Post a Comment