Qtp Methods and Properties
上一篇 / 下一篇 2008-08-06 20:58:15 / 个人分类:自动化测试
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
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
3. ChildObjects:Returns the collection of child objects contained within the object.
Syntax: object.ChildObjects (pDescrīption)
Example:
‘The following example uses the ChildObjects method to retrieve a
’set of child objects matching the descrīption listed in the function
‘call and uses the method to display a message indicating how many
‘objects are found with the specified descrīption: none, one (unique),
‘or several (not unique).
Public Function CheckObjectDesription(parent, descr)
Dim oDesc
‘ Create descrīption object
Set ōDesc = Descrīption.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 descrīption
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
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
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
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
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
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
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
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
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
13. GetToProperty:Returns the value of a specified property from the test object descrīption.
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
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
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
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
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
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
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
21. SetToProperty:Sets the value of the specified property in its test object descrīption.
Syntax: object.SetTOProperty Property, Val
Example:
Sub SetTOProperty_Example()
‘The following example uses the SetTOProperty method to set the
‘index of a window’s descrīption.
Window(”Test”).SetTOProperty “Index”, 2
End Sub
22. Type:Type the specified string in the dialog box.
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])
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
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
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 ()
相关阅读:
- 开放性敏捷自动化测试架构介绍(5) (benwu, 2008-8-02)
- 一些需要继续研究的小疑问 (sihanjishu, 2008-8-03)
- 修炼成QTP高手的十个步骤【转载】 (岁月童话, 2008-8-04)
- qtp 8.2 9.2 输出Html格式报告 (pcl2004_27, 2008-8-04)
- 一个自动化测试的实例 (caption, 2008-8-05)
- 51Testing丛书连载:(十三) QTP自动化测试实践 (51testing, 2008-8-05)
- 老婆测试工具培训记 -- QTP Scripting - 实践10 (pcl2004_27, 2008-8-05)
- qtp自动化测试实践即将看完 (sihanjishu, 2008-8-05)
- 软件自动化测试三个发展阶段 (caption, 2008-8-06)
- QTP对象库 (小刀, 2008-8-06)
TAG: 自动化测试
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | 5 | 6 | ||||
7 | 8 | 9 | 10 | 11 | 12 | 13 | |||
14 | 15 | 16 | 17 | 18 | 19 | 20 | |||
21 | 22 | 23 | 24 | 25 | 26 | 27 | |||
28 | 29 | 30 |
我的存档
数据统计
- 访问量: 207668
- 日志数: 169
- 图片数: 10
- 文件数: 4
- 建立时间: 2006-11-30
- 更新时间: 2012-08-18