QTP DIALOG BOX PROPERTIES
1. Activate: Activates the current Dialog Box.
Syntax: object.Activate [BUTTON]
Example:
Sub Activate_Example()
‘The following example uses the Activate method to activate the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Activate
End Sub
Syntax: object.Activate [BUTTON]
Example:
Sub Activate_Example()
‘The following example uses the Activate method to activate the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Activate
End Sub
2. CaptureBitmap: Saves the screen capture of the object as a .png or .bmp image using the specified file name.
Syntax: object.CaptureBitmap FullFileName, [OverrideExisting]
Example:
Sub CaptureBitmap_Example1()
‘The following example uses the CaptureBitmap method to capture a
‘screen shot of the Internet Options dialog box. The file is
‘automatically saved to a different folder (the test run results
‘folder) in each run.
Browser(“Mercury Tours”).Dialog(“Internet Options”).CaptureBitmap “internet_options.bmp”
End Sub
Syntax: object.CaptureBitmap FullFileName, [OverrideExisting]
Example:
Sub CaptureBitmap_Example1()
‘The following example uses the CaptureBitmap method to capture a
‘screen shot of the Internet Options dialog box. The file is
‘automatically saved to a different folder (the test run results
‘folder) in each run.
Browser(“Mercury Tours”).Dialog(“Internet Options”).CaptureBitmap “internet_options.bmp”
End Sub
3. ChildObjects: Returns the collection of child objects contained within the object.
Syntax: object.ChildObjects (pDescription)
Example:
‘The following example uses the ChildObjects method to retrieve a
‘set of child objects matching the description listed in the function
‘call and uses the method to display a message indicating how many
‘objects are found with the specified description: none, one (unique),
‘or several (not unique).
Public Function CheckObjectDesription(parent, descr)
Dim oDesc
‘ Create description object
Set oDesc = Description.Create()
arProps = Split(descr, “,”)
For i = 0 To UBound(arProps)
arProp = Split(arProps(i), “:=”)
If UBound(arProp) = 1 Then
PropName = Trim(arProp(0))
PropValue = arProp(1)
oDesc(PropName).Value = PropValue
End If
Next
‘ Get all child objects with the given description
Set children = parent.ChildObjects(oDesc)
If children.Count = 1 Then
CheckObjectDesription = “Object Unique”
ElseIf children.Count = 0 Then
CheckObjectDesription = “Object Not Found”
Else
CheckObjectDesription = “Object Not Unique”
End If
End Function
Syntax: object.ChildObjects (pDescription)
Example:
‘The following example uses the ChildObjects method to retrieve a
‘set of child objects matching the description listed in the function
‘call and uses the method to display a message indicating how many
‘objects are found with the specified description: none, one (unique),
‘or several (not unique).
Public Function CheckObjectDesription(parent, descr)
Dim oDesc
‘ Create description object
Set oDesc = Description.Create()
arProps = Split(descr, “,”)
For i = 0 To UBound(arProps)
arProp = Split(arProps(i), “:=”)
If UBound(arProp) = 1 Then
PropName = Trim(arProp(0))
PropValue = arProp(1)
oDesc(PropName).Value = PropValue
End If
Next
‘ Get all child objects with the given description
Set children = parent.ChildObjects(oDesc)
If children.Count = 1 Then
CheckObjectDesription = “Object Unique”
ElseIf children.Count = 0 Then
CheckObjectDesription = “Object Not Found”
Else
CheckObjectDesription = “Object Not Unique”
End If
End Function
4. Click: Clicks on a object.
Syntax: object.Click [X], [Y], [BUTTON]
Example:
Sub Click_Example()
‘The following example uses the Click method to click a right mouse
‘button at coordinates 47, 131 on the Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Click 47, 131, 1
End Sub
Syntax: object.Click [X], [Y], [BUTTON]
Example:
Sub Click_Example()
‘The following example uses the Click method to click a right mouse
‘button at coordinates 47, 131 on the Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Click 47, 131, 1
End Sub
5. Close: Closes the Dialog Box.
Syntax: object.Close
Example:
Sub Close_Example()
‘The following example uses the Close method to close the Internet
‘Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Close
End Sub
Syntax: object.Close
Example:
Sub Close_Example()
‘The following example uses the Close method to close the Internet
‘Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Close
End Sub
6. DblClick: Double clicks on a object.
Syntax: object.DblClick X, Y, [BUTTON]
Example:
Sub DblClick_Example()
‘The following example uses the DblClick method to double-click a right
‘mouse button at coordinates 73, 120 on the SysListView32 object.
Window(“Exploring”).WinListView(“SysListView32″).DblClick 73, 120, 1
End Sub
Syntax: object.DblClick X, Y, [BUTTON]
Example:
Sub DblClick_Example()
‘The following example uses the DblClick method to double-click a right
‘mouse button at coordinates 73, 120 on the SysListView32 object.
Window(“Exploring”).WinListView(“SysListView32″).DblClick 73, 120, 1
End Sub
7. Drag: Performs the ‘drag’ part of a drag and drop operation.
Syntax: object.Drag X, Y, [BUTTON]
Example:
Sub Drag_Example1()
‘The following example uses the Drag and Drop methods to drag the object from
‘coordinates 10, 20 within the Test window and drop the object at
‘coordinates 30, 40 within the same window.
Window(“Test”).Drag 10, 20
Window(“Test”).Drop 30, 40
End Sub
Syntax: object.Drag X, Y, [BUTTON]
Example:
Sub Drag_Example1()
‘The following example uses the Drag and Drop methods to drag the object from
‘coordinates 10, 20 within the Test window and drop the object at
‘coordinates 30, 40 within the same window.
Window(“Test”).Drag 10, 20
Window(“Test”).Drop 30, 40
End Sub
8. Drop: Performs the ‘drop’ part of a drag and drop operation.
Syntax: object.Drop X, Y, [BUTTON]
Example:
Sub Drop_Example1()
‘The following example uses the Drag and Drop methods to drag the object from
‘coordinates 10, 20 within the Test window and drop the object at
‘coordinates 30, 40 within the same window.
Window(“Test”).Drag 10, 20
Window(“Test”).Drop 30, 40
End Sub
Syntax: object.Drop X, Y, [BUTTON]
Example:
Sub Drop_Example1()
‘The following example uses the Drag and Drop methods to drag the object from
‘coordinates 10, 20 within the Test window and drop the object at
‘coordinates 30, 40 within the same window.
Window(“Test”).Drag 10, 20
Window(“Test”).Drop 30, 40
End Sub
9. Exist: Checks that an object exists.
Syntax: object.Exist([TimeOut])
Example:
Sub Exist_Example()
‘The following example uses the Exist method to determine the existence
‘of the Internet Options dialog box. If the dialog box exists a
‘message box appears confirming its appearance.
If Browser(“Mercury Tours”).Dialog(“Internet Options”).Exist Then
MsgBox (“The object exists.”)
End If
End Sub
Syntax: object.Exist([TimeOut])
Example:
Sub Exist_Example()
‘The following example uses the Exist method to determine the existence
‘of the Internet Options dialog box. If the dialog box exists a
‘message box appears confirming its appearance.
If Browser(“Mercury Tours”).Dialog(“Internet Options”).Exist Then
MsgBox (“The object exists.”)
End If
End Sub
10. GetRoProperty: Returns the current value of the test object property from the object in the application.
Syntax: object.GetROProperty (Property, [PropData])
Example:
Sub GetROProperty_Example()
‘The following example uses the GetROProperty method to retrieve the
‘x coordinate of the Test window.
x = Window(“Test”).GetROProperty(“x”)
y = Window(“Test”).GetROProperty(“y”)
End Sub
Syntax: object.GetROProperty (Property, [PropData])
Example:
Sub GetROProperty_Example()
‘The following example uses the GetROProperty method to retrieve the
‘x coordinate of the Test window.
x = Window(“Test”).GetROProperty(“x”)
y = Window(“Test”).GetROProperty(“y”)
End Sub
11. GetTextLocation: Checks whether the specified text string is contained in the specified window area.
Syntax: object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly])
Example:
Sub GetTextLocation_Example()
‘The following example uses the GetTextLocation method to retrieve
‘all of the text within the object.
l = -1
t = -1
r = -1
b = -1
result = Dialog(“Dialog”).WinObject(“Date”).GetTextLocation(“2002″, l, t, r, b)
If result Then
MsgBox “Text found. Coordinates:” & l & “,” & t & “,” & r & “,” & b
End If
End Sub
Syntax: object.GetTextLocation (TextToFind, Left, Top, Right, Bottom, [MatchWholeWordOnly])
Example:
Sub GetTextLocation_Example()
‘The following example uses the GetTextLocation method to retrieve
‘all of the text within the object.
l = -1
t = -1
r = -1
b = -1
result = Dialog(“Dialog”).WinObject(“Date”).GetTextLocation(“2002″, l, t, r, b)
If result Then
MsgBox “Text found. Coordinates:” & l & “,” & t & “,” & r & “,” & b
End If
End Sub
12. GetToProperties: Returns the collection of properties and values used to identify the object.
Syntax: object.GetTOProperties
Example:
Sub GetTOProperties_Example1()
‘The following example uses the GetTOProperties method to retrieve the
‘list of properties and values used to identify the Internet Options
‘dialog box.
IEOptsDialog = Browser(“Mercury Tours”).Dialog(“Internet Options”).GetTOProperties()
End Sub
Syntax: object.GetTOProperties
Example:
Sub GetTOProperties_Example1()
‘The following example uses the GetTOProperties method to retrieve the
‘list of properties and values used to identify the Internet Options
‘dialog box.
IEOptsDialog = Browser(“Mercury Tours”).Dialog(“Internet Options”).GetTOProperties()
End Sub
13. GetToProperty: Returns the value of a specified property from the test object description.
Syntax: object.GetTOProperty (Property)
Example:
Sub GetTOProperty_Example()
‘The following example uses the GetTOProperty method to retrieve the
‘RegExpWndClass property from the Object Repository.
Dim ObjectName
RegExpWndClass = Window(“Test”).GetTOProperty(“RegExpWndClass”)
End Sub
Syntax: object.GetTOProperty (Property)
Example:
Sub GetTOProperty_Example()
‘The following example uses the GetTOProperty method to retrieve the
‘RegExpWndClass property from the Object Repository.
Dim ObjectName
RegExpWndClass = Window(“Test”).GetTOProperty(“RegExpWndClass”)
End Sub
14. GetVisibleText: Returns the text from specified area.
Syntax: object.GetVisibleText ([Left], [Top], [Right], [Bottom])
Example:
Sub GetVisibleText_Example1()
‘The following example uses the GetVisibleText method to retrieve the
‘text from the Telnet window. If the returned string contains the “login:”
‘sub-string, the Type method is used to type the guest string in the
‘window.
TelnetText = Window(“Telnet”).GetVisibleText
If InStr(1, TelnetText, “login:”, 1) > 0 Then
Window(“Telnet”).Type “guest”
End If
End Sub
Syntax: object.GetVisibleText ([Left], [Top], [Right], [Bottom])
Example:
Sub GetVisibleText_Example1()
‘The following example uses the GetVisibleText method to retrieve the
‘text from the Telnet window. If the returned string contains the “login:”
‘sub-string, the Type method is used to type the guest string in the
‘window.
TelnetText = Window(“Telnet”).GetVisibleText
If InStr(1, TelnetText, “login:”, 1) > 0 Then
Window(“Telnet”).Type “guest”
End If
End Sub
15. MouseMove: Moves the mouse pointer to the designated position inside the activeXobject.
Syntax: object.MouseMove X, Y
Example:
Sub MouseMove_Example()
‘The following example uses the MouseMove method to move the mouse
‘pointer to the position (20, 30) inside the Advanced object.
Browser(“MyPage”).Dialog(“Settings”).WinObject(“Advanced”).MouseMove 20, 30
End Sub
Syntax: object.MouseMove X, Y
Example:
Sub MouseMove_Example()
‘The following example uses the MouseMove method to move the mouse
‘pointer to the position (20, 30) inside the Advanced object.
Browser(“MyPage”).Dialog(“Settings”).WinObject(“Advanced”).MouseMove 20, 30
End Sub
16. Move: Moves the dialog box to the specified absolute location on the screen.
Syntax: object.Move X, Y
Example:
Sub Move_Example()
‘The following example uses the Move method to move the Internet
‘Options dialog box to the specified location.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Move 659, 35
End Sub
Syntax: object.Move X, Y
Example:
Sub Move_Example()
‘The following example uses the Move method to move the Internet
‘Options dialog box to the specified location.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Move 659, 35
End Sub
17. Maximize: Maximize the dialog box to fill the entire screen.
Syntax: object.Maximize
Example:
Sub Maximize_Example()
‘The following example uses the Maximize method to maximize the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Maximize
End Sub
Syntax: object.Maximize
Example:
Sub Maximize_Example()
‘The following example uses the Maximize method to maximize the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Maximize
End Sub
18. Minimize: Minimizes the dialog box to an icon.
Syntax: object.Minimize
Example:
Sub Minimize_Example()
‘The following example uses the Minimize method to minimize the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Minimize
End Sub
Syntax: object.Minimize
Example:
Sub Minimize_Example()
‘The following example uses the Minimize method to minimize the
‘Internet Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Minimize
End Sub
19. Resize: Resize the dialog box to the specified dimensions.
Syntax: object.Resize Width, Height
Example:
Sub Resize_Example()
‘The following example uses the Resize method to resize the Internet
‘Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Resize 296, 348
End Sub
Syntax: object.Resize Width, Height
Example:
Sub Resize_Example()
‘The following example uses the Resize method to resize the Internet
‘Options dialog box.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Resize 296, 348
End Sub
20. Restore: Restores the dialog box to its previous size.
Syntax: object.Restore
Example:
Sub Restore_Example()
‘The following example uses the Restore method to restore the
‘Internet Options dialog box to its previous size.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Restore
End Sub
Syntax: object.Restore
Example:
Sub Restore_Example()
‘The following example uses the Restore method to restore the
‘Internet Options dialog box to its previous size.
Browser(“Mercury Tours”).Dialog(“Internet Options”).Restore
End Sub
21. SetToProperty: Sets the value of the specified property in its test object description.
Syntax: object.SetTOProperty Property, Val
Example:
Sub SetTOProperty_Example()
‘The following example uses the SetTOProperty method to set the
‘index of a window’s description.
Window(“Test”).SetTOProperty “Index”, 2
End Sub
Syntax: object.SetTOProperty Property, Val
Example:
Sub SetTOProperty_Example()
‘The following example uses the SetTOProperty method to set the
‘index of a window’s description.
Window(“Test”).SetTOProperty “Index”, 2
End Sub
22. Type: Type the specified string in the dialog box.
Syntax: object.Type KeyboardInput
Example: Not Available
Syntax: object.Type KeyboardInput
Example: Not Available
23. WaitProperty: Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.
Syntax: object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
Syntax: object.WaitProperty (PropertyName, PropertyValue, [lTimeOut])
Example:
Sub WaitProperty_Example()
‘The following example uses the WaitProperty method to make the
‘program wait for the “Test” window to become active or for 3 seconds
‘(3 milliseconds) to pass, whichever comes first.
y = Window(“Test”).WaitProperty(“focused”, True, 3000)
End Sub
Sub WaitProperty_Example()
‘The following example uses the WaitProperty method to make the
‘program wait for the “Test” window to become active or for 3 seconds
‘(3 milliseconds) to pass, whichever comes first.
y = Window(“Test”).WaitProperty(“focused”, True, 3000)
End Sub
24. Output: Retrieves the current value of an item and stores it in a specified location.
Syntax: object.Output pVerify
Example:
Sub Output_Example()
‘The following example uses the Output method to output text into the
‘”You can change” Data Table column.
Browser(“index”).Dialog(“Internet Options”).Static(“You can change”).Output CheckPoint(“You can change”)
End Sub
Syntax: object.Output pVerify
Example:
Sub Output_Example()
‘The following example uses the Output method to output text into the
‘”You can change” Data Table column.
Browser(“index”).Dialog(“Internet Options”).Static(“You can change”).Output CheckPoint(“You can change”)
End Sub
QTP COMBO BOX PROPERTIES
1. GetContent: Returns a string containing the names of all of the items in the combo box.
Syntax: object.GetContent
Example:
Sub GetContent_Example ()
‘The following example uses the getcontent method to return the items in the ‘fly from list.
With window (“Flight Reservation”)
Content= .WinCombobox (“Fly From:”).GetContent
End With
End sub
Syntax: object.GetContent
Example:
Sub GetContent_Example ()
‘The following example uses the getcontent method to return the items in the ‘fly from list.
With window (“Flight Reservation”)
Content= .WinCombobox (“Fly From:”).GetContent
End With
End sub
2. GetItem: Returns the value of the item specified by the index.
Syntax: object.GetItem (Item)
Example:
Sub GetItem_Example()
‘The following example uses the GetItem method to return the value
‘of the fifth item in the list.
itemVal = Window(“Flight Reservation”).WinComboBox(“Fly To:”).GetItem(4)
End Sub
Syntax: object.GetItem (Item)
Example:
Sub GetItem_Example()
‘The following example uses the GetItem method to return the value
‘of the fifth item in the list.
itemVal = Window(“Flight Reservation”).WinComboBox(“Fly To:”).GetItem(4)
End Sub
3. GetItemsCount: Returns the number of items in the combo box specified by the index.
Syntax: object.GetItemsCount
Example:
Sub GetItemsCount_Example()
‘The following example uses the GetItemsCount method to return the
‘number of items in the Fly From combo box.
With Window(“Flight Reservation”)
cnt = .WinComboBox(“Fly From:”).GetItemsCount
End With
End Sub
Syntax: object.GetItemsCount
Example:
Sub GetItemsCount_Example()
‘The following example uses the GetItemsCount method to return the
‘number of items in the Fly From combo box.
With Window(“Flight Reservation”)
cnt = .WinComboBox(“Fly From:”).GetItemsCount
End With
End Sub
4. GetSelection: Returns a string containing the names of all selected items in the combo box.
Syntax: object. GetSelection
Example:
Sub GetSelection_Example()
‘the following example uses the GetSelection method to return the
‘selected items in the Fly From combo box.
With Window(“Flight Reservation”)
sel = .WinComboBox(“Fly From:”) .GetSelection
End With
End Sub
Syntax: object. GetSelection
Example:
Sub GetSelection_Example()
‘the following example uses the GetSelection method to return the
‘selected items in the Fly From combo box.
With Window(“Flight Reservation”)
sel = .WinComboBox(“Fly From:”) .GetSelection
End With
End Sub
5. Select: Select an item from the combo box.
Syntax: object. Select item
Example:
Sub Select_Example()
‘The following example uses the Select method to select the item 22
‘from the Size combo box.
Window(“Notepad”).Dialog(“Font”).WinComboBox(“&Size:”).Select “22″
‘or
Window(“Notepad”).Dialog(“Font”).WinComboBox(“&Size:”).Select 7
End Sub
Syntax: object. Select item
Example:
Sub Select_Example()
‘The following example uses the Select method to select the item 22
‘from the Size combo box.
Window(“Notepad”).Dialog(“Font”).WinComboBox(“&Size:”).Select “22″
‘or
Window(“Notepad”).Dialog(“Font”).WinComboBox(“&Size:”).Select 7
End Sub
QTP ACTIVE X PROPERTIES
1. Click: Click an ActiveX object.
Syntax: object.Click [X], [Y], [BUTTON]
Example:
Sub Click_Example()
‘The following example uses the Click method to click a
‘”Flight Reservations” AcxTable object at coordinates 20, 10.
Browser(“Flight”).Page(“Flight”).AcxTable(“Flight Reservations”).Click 20, 10
End Sub
Syntax: object.Click [X], [Y], [BUTTON]
Example:
Sub Click_Example()
‘The following example uses the Click method to click a
‘”Flight Reservations” AcxTable object at coordinates 20, 10.
Browser(“Flight”).Page(“Flight”).AcxTable(“Flight Reservations”).Click 20, 10
End Sub
2. Dblclick: Double clicks an ActiveX object.
Syntax: object.DblClick X, Y, [button]
Example:
Sub DblClick_Example()
‘The following example uses the DblClick method to double-click a
‘”Calendar” ActiveX object at coordinates 73, 120.
Browser(“Flight”).Page(“Flight”).ActiveX(“Calendar”).DblClick 73, 120, 1
End Sub
Syntax: object.DblClick X, Y, [button]
Example:
Sub DblClick_Example()
‘The following example uses the DblClick method to double-click a
‘”Calendar” ActiveX object at coordinates 73, 120.
Browser(“Flight”).Page(“Flight”).ActiveX(“Calendar”).DblClick 73, 120, 1
End Sub
3. FireEvent: Simulates an event on the ActiveX object.
Syntax: object.FireEvent Eventname, [Args()]
Example:
Sub FireEvent_Example()
‘The following example uses the FireEvent method to simulate a
‘click event on the Save button.
Browser(“Homepage”).Page(“Welcome”).AcxButton(“Save”).FireEvent “Click”
End Sub
Syntax: object.FireEvent Eventname, [Args()]
Example:
Sub FireEvent_Example()
‘The following example uses the FireEvent method to simulate a
‘click event on the Save button.
Browser(“Homepage”).Page(“Welcome”).AcxButton(“Save”).FireEvent “Click”
End Sub
4. MakeVisible: Scrolls an ActiveX object into view if it is not visible in the window.
Syntax: object.MakeVisible
Example:
Sub MakeVisible_Example()
‘The following example uses the MakeVisible method to bring the
‘CIRC3 AcxRadioButton into view.
Browser(“Welcome to A-Soft”).Page(“Untitled Normal”).AcxRadioButton(“CIRC3.Circ3Ctrl.1″).MakeVisible
End Sub
Syntax: object.MakeVisible
Example:
Sub MakeVisible_Example()
‘The following example uses the MakeVisible method to bring the
‘CIRC3 AcxRadioButton into view.
Browser(“Welcome to A-Soft”).Page(“Untitled Normal”).AcxRadioButton(“CIRC3.Circ3Ctrl.1″).MakeVisible
End Sub
5. MouseMove: Moves the mouse pointer to the designated position inside the ActiveX object.
Syntax: object. MouseMove X,Y
Example:
Sub MouseMove_Example()
‘The following example uses the MouseMove method to move the
‘mouse pointer to the top left corner of the “Calendar” object:
Window(“Date”).ActiveX(“Calendar”).MouseMove 0, 0
End Sub
Syntax: object. MouseMove X,Y
Example:
Sub MouseMove_Example()
‘The following example uses the MouseMove method to move the
‘mouse pointer to the top left corner of the “Calendar” object:
Window(“Date”).ActiveX(“Calendar”).MouseMove 0, 0
End Sub
6. Object: Accesses the internal methods and properties of the ActiveX object.
Syntax: object.Object
Example:
Sub Object_Example()
‘The following example uses the Object method to activate the AboutBox
‘method, you would insert the following statement into your test script.
‘The assumption is that the AboutBox method is supported for your
‘ActiveX control.
Browser(“Flight Reservation”).Page(“Flight details”).ActiveX(“Calendar”).Object.AboutBox
‘Alternatively, you could insert the following:
Set MyObj = Browser(“Flight Reservation”).Page(“Flight details”).ActiveX(“Calendar”).Object
MyObj.AboutBox
End Sub
Syntax: object.Object
Example:
Sub Object_Example()
‘The following example uses the Object method to activate the AboutBox
‘method, you would insert the following statement into your test script.
‘The assumption is that the AboutBox method is supported for your
‘ActiveX control.
Browser(“Flight Reservation”).Page(“Flight details”).ActiveX(“Calendar”).Object.AboutBox
‘Alternatively, you could insert the following:
Set MyObj = Browser(“Flight Reservation”).Page(“Flight details”).ActiveX(“Calendar”).Object
MyObj.AboutBox
End Sub
7. Type: Types the specified string in the ActiveX object.
Syntax: object.Type wsTypeSeq
Example:
Sub Type_Example()
‘The following example uses the Type method to type “ABC” in the
‘AcxTable object.
Browser(“Homepage”).Page(“Welcome”).AcxTable(“MSFlexGrid”).Type “ABC”
End Sub
Syntax: object.Type wsTypeSeq
Example:
Sub Type_Example()
‘The following example uses the Type method to type “ABC” in the
‘AcxTable object.
Browser(“Homepage”).Page(“Welcome”).AcxTable(“MSFlexGrid”).Type “ABC”
End Sub
QTP RADIO BUTTON PROPERTIES
1. Set: Sets the radio button as the selected radio button.
Syntax: object.Set
Example:
Sub Set_Example()
‘The following example uses the Set method to select the “Not Shared”
‘radio button.
Window(“Window”).Dialog(“System Properties”).WinRadioButton(“Not Shared”).Set
End Sub
Syntax: object.Set
Example:
Sub Set_Example()
‘The following example uses the Set method to select the “Not Shared”
‘radio button.
Window(“Window”).Dialog(“System Properties”).WinRadioButton(“Not Shared”).Set
End Sub
QTP MENU PROPERTIES
1. BuildMenuPath: Returns the path of specified Menu Item.
Syntax: object.BuildMenuPath (Args())
Example:
Sub BuildMenuPath_Example1()
‘The following example uses the BuildMenuPath method to construct the
‘menu item path string for selecting the second menu item under the
‘File menu. This method returns the string File;:
Path = Window(“Notepad”).WinMenu(“Menu”).BuildMenuPath(“File”, 2)
Window(“Notepad”).WinMenu(“Menu”).Select Path
End Sub
Syntax: object.BuildMenuPath (Args())
Example:
Sub BuildMenuPath_Example1()
‘The following example uses the BuildMenuPath method to construct the
‘menu item path string for selecting the second menu item under the
‘File menu. This method returns the string File;:
Path = Window(“Notepad”).WinMenu(“Menu”).BuildMenuPath(“File”, 2)
Window(“Notepad”).WinMenu(“Menu”).Select Path
End Sub
2. GetItemProperty: Returns the current value of the specified property for the specified Menu Item.
Syntax: object.GetItemProperty(Item, Property)
Example:
Sub GetItemProperty_Example1()
‘The following example uses the GetItemProperty method to retrieve the
‘label property of a menu item.
itemLabel = Window(“Notepad”).WinMenu(“Menu”).GetItemProperty(“;”, “Label”)
End Sub
Syntax: object.GetItemProperty(Item, Property)
Example:
Sub GetItemProperty_Example1()
‘The following example uses the GetItemProperty method to retrieve the
‘label property of a menu item.
itemLabel = Window(“Notepad”).WinMenu(“Menu”).GetItemProperty(“;”, “Label”)
End Sub
3. Select: Selects the specified item in the menu.
Syntax: object.Select Item
Example:
Sub Select_Example()
‘The following example uses the Select method to open the Open File
‘dialog box in Notepad.
Window(“Notepad”).WinMenu(“Menu”).Select “File;Open… Ctrl+O”
‘You can also open a menu item according to its indexed number.
Window(“Notepad”).WinMenu(“Menu”).Select “;”
End Sub
Syntax: object.Select Item
Example:
Sub Select_Example()
‘The following example uses the Select method to open the Open File
‘dialog box in Notepad.
Window(“Notepad”).WinMenu(“Menu”).Select “File;Open… Ctrl+O”
‘You can also open a menu item according to its indexed number.
Window(“Notepad”).WinMenu(“Menu”).Select “;”
End Sub
4. ExpandMenu: Indicates whether to expand the menu when retrieving menu item properties.
Syntax: object. ExpandMenu[=Value]
Example:
Sub ExpandMenu_Example()
‘The following example uses the ExpandMenu method to instruct
”QuickTest NOT to open each menu item when retrieving the menu item’s
‘property. The GetItemProperty method retrieves the Label property of
‘each menu item and writes them in the test’s report log.
Window(“Notepad”).WinMenu(“Menu”).ExpandMenu = False
Window(“Notepad”).Activate
GetNamesRec “”, Window(“Notepad”).WinMenu(“Menu”)
Syntax: object. ExpandMenu[=Value]
Example:
Sub ExpandMenu_Example()
‘The following example uses the ExpandMenu method to instruct
”QuickTest NOT to open each menu item when retrieving the menu item’s
‘property. The GetItemProperty method retrieves the Label property of
‘each menu item and writes them in the test’s report log.
Window(“Notepad”).WinMenu(“Menu”).ExpandMenu = False
Window(“Notepad”).Activate
GetNamesRec “”, Window(“Notepad”).WinMenu(“Menu”)
QTP LISTBOX PROPERTIES
1. Activate: Activates the specified item in the list.
Syntax: object.Activate Item, [btn]
Example:
Sub Activate_Example()
‘The following example uses the Activate method to double-click the
‘MyFile item in the Files list.
Dialog(“Open”).WinList(“Files”).Activate “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).Activate 2
End Sub
Syntax: object.Activate Item, [btn]
Example:
Sub Activate_Example()
‘The following example uses the Activate method to double-click the
‘MyFile item in the Files list.
Dialog(“Open”).WinList(“Files”).Activate “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).Activate 2
End Sub
2. Deselects: Deselects an item in the list.
Syntax: object. Deselects item
Example:
Sub Deselect_Example()
‘The following example uses the Deselect method to deselect a selected
‘item from the Files list.
Dialog(“Open”).WinList(“Files”).Deselect “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).Deselect 3
End Sub
Syntax: object. Deselects item
Example:
Sub Deselect_Example()
‘The following example uses the Deselect method to deselect a selected
‘item from the Files list.
Dialog(“Open”).WinList(“Files”).Deselect “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).Deselect 3
End Sub
3. ExtendSelect: Selects an additional item from the multi-selection list.
Syntax: object. ExtendSelect item
Example:
Sub ExtendSelect_Example()
‘The following example uses the ExtendSelect method to add an item
‘to a multiple-selection list in the Files list.
Dialog(“Open”).WinList(“Files”).ExtendSelect “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).ExtendSelect 2
End Sub
Syntax: object. ExtendSelect item
Example:
Sub ExtendSelect_Example()
‘The following example uses the ExtendSelect method to add an item
‘to a multiple-selection list in the Files list.
Dialog(“Open”).WinList(“Files”).ExtendSelect “MyFile”
‘or
Dialog(“Open”).WinList(“Files”).ExtendSelect 2
End Sub
4. GetContent: Returns all of the items in the list.
Syntax: object.GetContent
Example:
Sub GetContent_Example()
‘The following example uses the GetContent method to return the items
‘in the Files list.
Contents = Dialog(“Open”).WinList(“Files”).GetContent()
End Sub
Syntax: object.GetContent
Example:
Sub GetContent_Example()
‘The following example uses the GetContent method to return the items
‘in the Files list.
Contents = Dialog(“Open”).WinList(“Files”).GetContent()
End Sub
5. GetItemProperty: Returns the current value of a property from an item in the list.
Syntax: object.GetItemProperty(Item, Property)
Example:
Sub GetItemProperty_Example()
‘The following example uses the GetItemProperty method to gather
‘information about various properties for items in a list.
sReport = “”
With Window(“WinBurger”).WinList(“ListBox”)
For i = 0 To 4
sReport = sReport & .GetItemProperty(i, “Selected”) & vbTab
sReport = sReport & .GetItemProperty(i, “Checked”) & vbTab
sReport = sReport & .GetItemProperty(i, “Focused”) & vbTab
sReport = sReport & .GetItemProperty(i, “IsAnchor”) & vbTab
sReport = sReport & .GetItemProperty(i, “Height”) & vbCr
Next
End With
Reporter.ReportEvent micDone, “List data”, sReport
End Sub
Syntax: object.GetItemProperty(Item, Property)
Example:
Sub GetItemProperty_Example()
‘The following example uses the GetItemProperty method to gather
‘information about various properties for items in a list.
sReport = “”
With Window(“WinBurger”).WinList(“ListBox”)
For i = 0 To 4
sReport = sReport & .GetItemProperty(i, “Selected”) & vbTab
sReport = sReport & .GetItemProperty(i, “Checked”) & vbTab
sReport = sReport & .GetItemProperty(i, “Focused”) & vbTab
sReport = sReport & .GetItemProperty(i, “IsAnchor”) & vbTab
sReport = sReport & .GetItemProperty(i, “Height”) & vbCr
Next
End With
Reporter.ReportEvent micDone, “List data”, sReport
End Sub
6. GetItemsCount: Returns the number of items in the list.
Syntax: object.GetItemsCount
Example:
Sub GetItemsCount_Example()
‘The following example uses the GetItemsCount method to return the
‘number of items in the Files list.
NumberOfItems = Dialog(“Open”).WinList(“Files”).GetItemsCount
End Sub
Syntax: object.GetItemsCount
Example:
Sub GetItemsCount_Example()
‘The following example uses the GetItemsCount method to return the
‘number of items in the Files list.
NumberOfItems = Dialog(“Open”).WinList(“Files”).GetItemsCount
End Sub
7. GetSelection: Returns all of the selected items in the list.
Syntax: object.GetSelection
Example:
Sub GetSelection_Example()
‘The following example uses the GetSelection method to return the
‘selected items in the “Files” list.
Dialog(“Open”).WinList(“Files”).Select “bin”
Dialog(“Open”).WinList(“Files”).ExtendSelect “dat”
Dialog(“Open”).WinList(“Files”).ExtendSelect “encrypt”
Selection = Dialog(“Open”).WinList(“Files”).GetSelection
End Sub
Syntax: object.GetSelection
Example:
Sub GetSelection_Example()
‘The following example uses the GetSelection method to return the
‘selected items in the “Files” list.
Dialog(“Open”).WinList(“Files”).Select “bin”
Dialog(“Open”).WinList(“Files”).ExtendSelect “dat”
Dialog(“Open”).WinList(“Files”).ExtendSelect “encrypt”
Selection = Dialog(“Open”).WinList(“Files”).GetSelection
End Sub
8. Select: Selects an item from the list.
Syntax: object.Select Item, [BUTTON], [Offset]
Example:
Sub Select_Example1()
‘The following example uses the Select method to select the item
‘CONTENTS from the list.
With Window(“Windows Help”)
.WinList(“ListBox”).Select “CONTENTS”
End With
End Sub
Syntax: object.Select Item, [BUTTON], [Offset]
Example:
Sub Select_Example1()
‘The following example uses the Select method to select the item
‘CONTENTS from the list.
With Window(“Windows Help”)
.WinList(“ListBox”).Select “CONTENTS”
End With
End Sub
9. SelectRange: Select all list items between ( and including) the two specified items.
Syntax: object.SelectRange Item, [ItemTo]
Example:
Sub SelectRange_Example1()
‘The following example uses the SelectRange method to select all the
‘items between (and including) Red and Blue.
Dialog(“Select Color”).WinList(“Colors”).SelectRange “Red”, “Blue”
End Sub
Syntax: object.SelectRange Item, [ItemTo]
Example:
Sub SelectRange_Example1()
‘The following example uses the SelectRange method to select all the
‘items between (and including) Red and Blue.
Dialog(“Select Color”).WinList(“Colors”).SelectRange “Red”, “Blue”
End Sub
10. SetItemState: Sets the state of check box icon of the specified item in the list.
Syntax: object.SetItemState vItem, State
Example: NOT AVAILABLE
Syntax: object.SetItemState vItem, State
Example: NOT AVAILABLE
QTP CHECKBOX PROPERTIES
1. Set: Sets value of the check box.
Syntax: object. Set value
Example:
Sub Set_Example()
‘The following example uses the Set method to set the Include
‘subfolders check box in the Find: All Files dialog box to ON.
Dialog(“Find: All Files”).WinCheckBox(“Include &subfolders”).Set “ON”
End Sub
Syntax: object. Set value
Example:
Sub Set_Example()
‘The following example uses the Set method to set the Include
‘subfolders check box in the Find: All Files dialog box to ON.
Dialog(“Find: All Files”).WinCheckBox(“Include &subfolders”).Set “ON”
End Sub
QTP WINDOW PROPERTIES
1. RunAnalog: Runs the specified analog track.
Syntax: object. RunAnalog Actionid, [Speed]
Example:
Sub RunAnalog_Example1()
‘The following example uses the RunAnalog method to perform the
‘mouse drags used to replicate a user’s signature on a window using
‘the Fast run speed. QuickTest clicks in the signature area of a
‘flight reservation application and then uses the RunAnalog method
‘to run the external Track1 analog file.
Window(“Flight Reservation”).Dialog(“Fax Order No.”).Click 216, 204
Window(“Flight Reservation”).Window(“Fax Order No.”).RunAnalog “Track1″
End Sub
Reference source: http://pulsetechnologies.wordpress.com/2009/01/06/qtp-methods-and-properties-2/Syntax: object. RunAnalog Actionid, [Speed]
Example:
Sub RunAnalog_Example1()
‘The following example uses the RunAnalog method to perform the
‘mouse drags used to replicate a user’s signature on a window using
‘the Fast run speed. QuickTest clicks in the signature area of a
‘flight reservation application and then uses the RunAnalog method
‘to run the external Track1 analog file.
Window(“Flight Reservation”).Dialog(“Fax Order No.”).Click 216, 204
Window(“Flight Reservation”).Window(“Fax Order No.”).RunAnalog “Track1″
End Sub
No comments:
Post a Comment