Find a given value in a property of the collection of child objects In QTP

Activate an Edit Box's Native Focus Method  :

Sub Object_Example()
'The following example uses the .Object property to activate an
'edit box's native focus method:

Set MyWebEdit = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object
MyWebEdit.focus

End Sub


 Find a given value in a property of the collection of child objects:

Sub ROPropertyOfChildObjects()

' Find a given value in a property of the collection of child objects
Dim lvToSearch, ValueToSelect, NumberOfListViews, ListViewCollection

'Search for this value of the 'swfname" property for the SwfListView.
lvToSearch = "listView" ' "files"
ValueToSelect = "Invoice 2345"
'Create a description object to retrieve all WebEdits in a specific page.
Set oDesc = Description.Create()
oDesc("swftypename").Value = "System.Windows.Forms.ListView"
'Retrieve all The ListView objects in this window
Set ListViewCollection = SwfWindow("dotNET ListView").ChildObjects(oDesc)
NumberOfListViews = ListViewCollection.Count
' Select the first matching item in the WListView
For i = 0 To NumberOfListViews - 1
    If ListViewCollection(i).GetROProperty("swfname") = lvToSearch Then
        ListViewCollection(i).Select ValueToSelect
        Exit For
    End If
Next
' Do something with the selected item
End Sub


Get a Property from a Button  :


Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve the value of the text property for the
'"button4" button.
strText = SwfWindow("Form1").SwfButton("button4").GetROProperty("Text")

End Sub
 
Retrieve a Calendar's Selection Mode Property :


Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve the value of the selection mode
'property for the "Calendar1" calendar.
runtimeProp = Browser("Browser").Page("Page").WbfCalendar("Calendar1").GetROProperty("selection mode")

End Sub



Finding y Co ordinate of an Object :

Sub GetROProperty_Example()
'The following example uses the GetROProperty method to retrieve the
'Y coordinate of the AcxCheckBox object relative to the top left
'corner of the screen.

Set Value = Browser("Flight").Page("Flight").AcxCheckBox("LogicalName").GetROProperty("abs_y")

End Sub

Post a Comment

Previous Post Next Post