-
(转)QTP_Database Functions library
2008-08-12 22:19:44
'Example of How to use functions.
''************************************************************************************
' Example use DSN created for database of Flight sample application.
''************************************************************************************
SQL="SELECT * FROM ORDERS"
connection_string="QT_Flight32"
isConnected = db_connect ( curConnection ,connection_string )
If isConnected = 0 then
' execute the basic SQL statement
set myrs=db_execute_query( curConnection , SQL )
' report the query and the connection string
Reporter.ReportEvent micInfo ,"Executed query and created recordset ","Connection_string is ==> " & connection_string & " SQL query is ===> " & SQL
' show the number of rows in the table using a record set
msgBox " Quantity of rows in queried DB ( db_get_rows_count )==> " & db_get_rows_count( myrs )
' show the number of rows in the table using a new SQL statement
msgBox " Quantity of rows in queried DB (db_get_rows_count_SQL ) ==> " & db_get_rows_count_SQL( curConnection , "SELECT COUNT(*) FROM ORDERS" )
' change a value of a field in an existing row
rc = db_set_field_value (curConnection, "ORDERS" , "Agents_Name" , "test", "Agents_Name", "AGENT_TESTER")
' examples of how to retrieve values from the table
msgBox "val row 0 col 0: " & db_get_field_value( myrs , 0 , 0 )
msgBox "val row 0 col 1: " & db_get_field_value( myrs , 0 , 1 )
msgBox "val row 1 col Name: " & db_get_field_value( myrs , 1 , "Agents_Name" )
msgBox "val SQL row 1 col Name: " & db_get_field_value_SQL( curConnection , "ORDERS" , 1 , "Agents_Name" )
db_disconnect curConnection
End If
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
''****************************************************************************************
' Database Functions library
'******************************************************************************************
'db_connect
' ---------------
' The function creates a new connection session to a database.
' curSession - the session name (string)
' connection_string - a connection string
' for example the connection_string can be "DSN=SQLServer_Source;UID=SA;PWD=abc123"
'******************************************************************************************
Function db_connect( byRef curSession ,connection_string)
dim connection
on error Resume next
' Opening connection
set connection = CreateObject("ADODB.Connection")
If Err.Number <> 0 then
db_connect= "Error # " & CStr(Err.Number) & " " & Err.Descrīption
err.clear
Exit Function
End If
connection.Open connection_string
If Err.Number <> 0 then
db_connect= "Error # " & CStr(Err.Number) & " " & Err.Descrīption
err.clear
Exit Function
End If
set curSession=connection
db_connect=0
End Function
'********************************************************************************************
' db_disconnect
' ---------------------
' The function disconnects from the database and deletes the session.
' curSession - the session name (string)
'********************************************************************************************
Function db_disconnect( byRef curSession )
curSession.close
set curSession = Nothing
End Function
'*********************************************************************************************
' db_execute_query
' ---------------------------
' The function executes an SQL statement.
' Note that a db_connect for (arg1) must be called before this function
' curSession - the session name (string)
' SQL - an SQL statement
'**********************************************************************************************
Function db_execute_query ( byRef curSession , SQL)
set rs = curSession.Execute( SQL )
set db_execute_query = rs
End Function
''***********************************************************************************************
' db_get_rows_count
' ----------------------------
' The function returns the number of rows in the record set
' curRS - variable , contain record set , that contain all values that retrieved from DB by query execution
''***********************************************************************************************
Function db_get_rows_count( byRef curRS )
dim rows
rows = 0
curRS.MoveFirst
Do Until curRS.EOF
rows = rows+1
curRS.MoveNext
Loop
db_get_rows_count = rows
End Function
''************************************************************************************************
' db_get_rows_count_SQL
' ------------------------------------
' The function returns the number of rows that are the result of a given SQL statement
' curSession - the session name (string)
' CountSQL - SQL statement
''************************************************************************************************
Function db_get_rows_count_SQL( byRef curSession ,CountSQL )
dim cur_rs
set cur_rs = curSession.Execute( CountSQL )
db_get_rows_count_SQL = cur_rs.fields(0).value
End Function
''*************************************************************************************************
' db_get_field_value_SQL
' -----------------------------------
' curSession - variable denote current active connection
' tableName - name of the table , where value should be retrieved
' rowIndex - row number
' colName - the column name.
'*************************************************************************************************
Function db_get_field_value_SQL( curSession , tableName , rowIndex , colName )
dim rs
SQL = " select " & colName & " from " & tableName
set rs = curSession.Execute( SQL )
rs.move rowIndex
db_get_field_value_SQL = rs.fields(colName).value
End Function
'*************************************************************************************************
' db_get_field_value
' --------------------------
' The function returns the value of a single item of an executed query.
' Note that a db_execute_query for (arg1) must called before this function
' curRecordSet - variable , contain record set , that contain all values that retrieved from DB by query execution
' rowIndex - the row index number (zero based)
' colIndex - the column index number (zero based) or the column name.
' returned values
' -1 - requested field index more than exists in record set
'*************************************************************************************************
Function db_get_field_value( curRecordSet , rowIndex , colIndex )
dim curRow
curRecordSet.MoveFirst
count_fields = curRecordSet.fields.count-1
If ( TypeName(colIndex)<> "String" ) and ( count_fields < colIndex ) then
db_get_field_value = -1 'requested field index more than exists in recordset
Else
curRecordSet.Move rowIndex
db_get_field_value = curRecordSet.fields(colIndex).Value
End If
End Function
'*************************************************************************************************
' db_set_field_value
' ---------------------------
' The function changes the value of a field according to a search criteria.
' We search for a certain row according to a column name and the desired vale, then we change a value in that row according
' to a desired columns
' curConnection - the session name (string)
' tableName - name of the table , where value should be retrieved
' colFind - the column we search the criteria in
' colFindValue - the value we search in the column
' colChange - the column were we want to change the value
' colChangeValue - the new value
' returned values
' -1 - requested field index that doesn't exists in the recordset
'*************************************************************************************************
Function db_set_field_value(curConnection, tableName , colFind , colFindValue, colChange, colChangeValue)
dim curRow
dim updateSQL
dim checkSQL
checkSQL = "select * from Details"
set myrs1 = db_execute_query( curConnection , SQL )
myrs1.MoveFirst
count_fields = myrs1.fields.count
If ( TypeName(colFind)<> "String" ) or ( TypeName(colChange)<> "String" ) then
db_set_field_value = -1 'requested field index that doesn't exists in the record set
Else
updateSQL = "UPDATE " & tableName & " SET " & colChange & "='" & colChangeValue & "' WHERE " & colFind & "='" & colFindValue & "'"
set myrs1 = db_execute_query( curConnection , updateSQL )
db_set_field_value = 1 'operation suceeded
End If
End Function
'*************************************************************************************************
' db_add_row
' -----------------
' The function adds a new row to the desired table
' curConnection - variable , contains a recordset , that contains all the values to be retrieved from DB by query execution
' tableName - name of the table , where value should be retrieved from
' values - array that contains values to be entered in a new row to the table.
' Note: the function must receive values for all the columns in the table!
' returned values
' -1 - the number of values to be entered to the table doesn't fit the number of columns
' 1 - execution of the query succeed and the data was entered to the table
'*************************************************************************************************
Function db_add_row(curConnection, tableName , byRef values)
dim i
dim updateSQL
dim myrs1
updateSQL = "INSERT INTO " & tableName & " VALUES ("
arrLen = UBound (values) - LBound (values) + 1
set myrs1=db_execute_query( curConnection , SQL )
myrs1.MoveFirst
count_fields = myrs1.fields.count
' check if numbers of values fit the numbers of columns
If arrLen <> count_fields then
db_add_row = -1
Else
For i = 0 to arrLen-1
updateSQL = updateSQL & values (i)
If i <> arrLen-1 then
updateSQL = updateSQL & ","
End If
Next
updateSQL = updateSQL & ")"
set myrs1 = db_execute_query( curConnection , updateSQL )
db_add_row = 1
End If
End Function
'*************************************************************************************************
' represent_values_of_RecordSet
' ---------------------------------------------
' the function reports all the values on fields in a record set
' curRS - variable , contains the recordset , that contains all the values that were retrieved from the DB by the query execution
'*************************************************************************************************
Function represent_values_of_RecordSet( myrs)
dim curRowString
myrs.MoveFirst
reporter.ReportEvent 4,"Fields quantity" , myrs.fields.count
count_fields = myrs.fields.count-1
curRow=0
Do Until myrs.EOF
curRowString= ""
curRow = curRow+1
For ii=0 to count_fields
curRowString = curRowString& "Field " &"==> " & myrs.fields(ii).Name &" : Value ==>" & myrs.fields(ii).Value & vbCrLf
Next
myrs.MoveNext
reporter.ReportEvent 4,"Current row"& curRow , curRowString
Loop
End Function -
QTP的未来(转)
2008-08-12 14:06:37
HP在最近的一次会议上,向大家展示了QTP10,代号为“Atlantis”(这个名字好像不大好听 - 传说沉没于大西洋中的岛)。有可能会命名为QucikTest Pro 10.0,预计在2009年初发布。
据说QTP10会在以下方面得到改进和增强:
1. 与QC更加紧密的结合
QTP Atlantis will be launched with Quality Center Atlantis, and their integration will be rebuilt from scratch to offer much more functionality and improvements.
包括一个外部的资源管理器和版本管理。
2. Intellisense
包括:无限层次的展开对象属性。
COM对象的Intellisense查看和访问。
对象Intellisense的赋值可传递性。3. 更多IDE方面的改进和增强,例如,可自定义工具栏、TO-DO视图等。
4. Reporter对象的改进,例如,可把测试日志文件导出成HTML或PDF等格式。据说还会把性能计数器整合到资源监视报告。
5. 新的ChcekPoint,例如检查应用程序使用的GDI对象个数等。
6. 当然,还有对新的环境支持,例如Windows XP SP3, Windows 2008, Windows Vista SP1, IE8, FireFox 3, 新的cirtrix 客户端等。
-
QTP 图片验证点之二进制流对比法
2008-08-10 22:34:59
图片验证主要是文件对比,其中我们可以利用二进制的方法读取图片信息,然后进行对比,达到对比的效果,本例子利用fso对象的文件流的方法实现,代码如下
Public Function CompareFiles (FilePath1, FilePath2)
Dim FS, File1, File2
Set FS = CreateObject("scrīpting.FileSystemObject")
If FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size Then
CompareFiles = True
Exit Function
End IfSet File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0)
CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read(1000)
Str2 = File2.Read(1000)
CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0 ThenCompareFiles = True
Exit Do
End If
Loop
File1.Close()
File2.Close()
End Function返回值:
如果两个文件相同,该功能将返回 0 或 False,否则将返回 True。示例:
File1 = "C:\1.jpg"
File2 = "C:\2.jpg"
If CompareFiles(File1, File2) = False Then
MsgBox "Files are identical."
Else
MsgBox "Files are different."
End If -
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
End2. 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 Sub3. 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 Function4. 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 Sub5. 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 Sub6. 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 Sub7. 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 Sub8. 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 Sub9. 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 Sub10. 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 Sub11. 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 Sub12. 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 Sub13. 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 Sub14. 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 Sub15. 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 Sub16. 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 Sub17. 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 Sub18. 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 Sub19. 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 Sub20. 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 Sub21. 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 Sub22. Type: Type the specified string in the dialog box.
Syntax: object.Type KeyboardInput
Example: Not Available23. 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 Sub24. 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 SubQTP 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 () -
老婆测试工具培训记 -- QTP Scripting - 实践10
2008-08-05 18:09:05
Write a program to comparing text files?
Sub Main
fileName1 = "x:\text1.txt"
fileName2 = "x:\text2.txt"
If CompareFiles(fileName1, fileName2) Then
Msgbox "The files are equal"
Else
MsgBox "The files are different"
End If
End Sub
Function CompareFiles(fileName1, fileName2)
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'Creates the FileSystemObject object
Set fso = CreateObject("scrīpting.FileSystemObject")
'Reads the first text file
Set file1 = fso.OpenTextFile(fileName1, ForReading)
fileText1 = file1.ReadAll
file1.Close
'Reads the second text file
Set file2 = fso.OpenTextFile(fileName2, ForReading)
fileText2 = file2.ReadAll
file2.Close
'Creates the regular expression object
Set regEx = New RegExp
'Specifies the pattern for the date/time mask
'MM/DD/YYYY HH:MM:SSLL (for example: 4/25/2006 10:51:35AM)
regEx.Pattern = "\d{1,2}.\d{1,2}.\d{2,4}\s\d{1,2}:\d{2}:\d{2}\w{2}"
regEx.IgnoreCase = True
regEx.Global = True
'Replaces the text matching the specified date/time format with <ignore>
newText1 = regEx.Replace(fileText1, "<ignore>")
newText2 = regEx.Replace(fileText2, "<ignore>")
'Compares the text
If newText1 = newText2 Then
CompareFiles = True
Else
CompareFiles = False
End If
End Function -
qtp 8.2 9.2 输出Html格式报告
2008-08-04 18:11:53
如果想输出Html格式的Log,如何办呢,其实qtp内建了这个功能,需要打开这个开关。
修改注册表:
HKEY_LOCAL_MACHINE
- SOFTWARE
-Mercury Interactive
-QuickTest Professional
-Logger
- Media
- Log
- Active 1 "REG_DWORD"
这个时候就会在你的qtp工程文件夹下"Log"下多出一个"LogFile"文件夹 里面会多出html格式的Log文件
代码:
Set ōbjShell = Wscrīpt.CreateObject("Wscrīpt.Shell")
KeyVal= objshell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Logger\Media\Log\Active")
objshell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Logger\Media\Log\Active",1,"REG_DWORD"
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
qtApp.Open "C:\Documents and Settings\Administrator\桌面\test", True
set qttest = qtapp.test
qtTest.RunqtApp.Quit
Wscrīpt.Quit
set QtApp=nothing
set Wscrit=nothing
-
老婆测试工具培训记 - QTP Scripting - 实践9
2008-08-01 13:36:11
Write a program to Dynamically adding to WebList ?
思路:html dom 技术
脚本代码:
Dim objDoc
Dim objElement
Dim newNode
Set ōbjDoc = Browser("Browser").Page("Page").Object
Set ōbjElement = objDoc.GetElementByID("WebList")
Set newNode = objDoc.createElement("option")
newNode.Text = "Test——pcl"
objElement.add newNode
Set newNode = Nothing
Set ōbjElement = Nothing
Set ōbjDoc = Nothing -
老婆测试工具培训记-Scripting-实践8
2008-07-29 13:57:33
write a program to Highlight a object?
思路:利用api函数实现
代码:
Extern.Declare micHwnd, "GetDesktopWindow", "User32.DLL", "GetDesktopWindow"
Extern.Declare micULong, "GetWindowDC", "User32.DLL", "GetWindowDC", micHwnd
Extern.Declare micInteger, "ReleaseDC", "User32.DLL", "ReleaseDC", micHwnd, micULong
Extern.Declare micULong, "CreatePen", "Gdi32.DLL", "CreatePen", micInteger, micInteger, micDword
Extern.Declare micInteger, "SetROP2", "Gdi32.DLL", "SetROP2", micULong, micInteger
Extern.Declare micULong, "SelectObject", "Gdi32.DLL", "SelectObject", micULong, micULong
Extern.Declare micULong, "DeleteObject", "Gdi32.DLL", "DeleteObject", micULong
Extern.Declare micULong, "GetStockObject", "Gdi32.DLL", "GetStockObject", micInteger
Extern.Declare micULong, "Rectangle", "Gdi32.DLL", "Rectangle", micULong, micInteger, micInteger, micInteger, micInteger
Function HighlightRect (X, Y, W, H, Times)hDC = Extern.GetWindowDC (Extern.GetDesktopWindow)
hPen = Extern.CreatePen (6, 3, RGB(0, 0, 0)) ' PS_INSIDEFRAME, 3 , RGB(0, 0, 0)
Extern.SetROP2 hDC, 6 ' hDC, R2_NOT
Extern.SelectObject hDC, hPen
Extern.SelectObject hDC, Extern.GetStockObject (5)
For i = 0 to Times * 2 + 1
Extern.Rectangle hDC, X, Y, X + W, Y + H
wait 0, 50
Next
Extern.ReleaseDC Extern.GetDesktopWindow, hDC
Extern.DeleteObject hPenEnd Function
-
老婆测试工具培训记-qtp scriping-实践7
2008-07-25 14:10:12
write a program to send email?
思路:利用 cmo和 outlook对象
解决方法1:
Dim Outlook 'As New Outlook.Application
Set ōutlook = CreateObject("Outlook.Application")
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject ="hello"
.Body = "test"
'Set destination email address
.Recipients.Add ("pcl@51testing.com")
.Send
End With
解决方法2:Dim Email As Object
NameS = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "****@qq.com" '//你自己的油箱号码
Email.To = "" ' // 要发的人
Email.Subject = "" '//相当于邮件里的标题
Email.Textbody = "" '//相当于邮件里的内容
Email.Configuration.Fields.Item(NameS & "sendusing") = 2
Email.Configuration.Fields.Item(NameS & "smtpserver") = "smtp.qq.com" '// 服务器
Email.Configuration.Fields.Item(NameS & "smtpserverport") = 25 '//端口号
Email.Configuration.Fields.Item(NameS & "smtpauthenticate") = 1
Email.Configuration.Fields.Item(NameS & "sendusername") = "**" '//油箱号码@前面的名字
Email.Configuration.Fields.Item(NameS & "sendpassword") = "**" '//你油箱的密码
Email.Configuration.Fields.Update
Email.Send -
老婆测试工具培训记 - QTP Scripting - 实践6
2008-07-22 14:57:20
write a program to Saving a file from IE?
思路: 利用MSXML4里面提供了一个可用的新的组件:WinHttp.WinHttpRequest.5.1
技术主要利用在下载文件验证方面。下面是我做个下载我上传的一个文件的测试,除了WinHttp.WinHttpRequest.5.1对象还利用到了ado.stream对象,进行保存文件处理。
代码如下:
Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
If WinHttp Is Nothing Then Set WinHttp = CreateObject("WinHttp.WinHttpRequest")
WinHttp.Open "GET", "http://www.51testing.com/batch.download.php?aid=10479", False
WinHttp.Send
arrArray = WinHttp.ResponseBody
Set WinHttp = Nothing
On Error Resume Next
Set ōADO = CreateObject("ADODB.Stream")
If oADO Is Nothing Then
Set ōFSO = CreateObject("scrīpting.FileSystemObject")
Set ōTextFile = oFSO.OpenTextFile("c:\a.rar", 2, True)
sData = ""
sBuffer = ""
For iCount = 0 to UBound(arrArray)
oTextFile.Write Chr(255 And Ascb(Midb(arrArray,iCount + 1, 1)))
Next
oTextFile.Close
Else
oADO.Type = 1
oADO.Open
oADO.Write arrArray
oADO.SaveToFile "c:\a.rar", 2
oADO.Close
End If
Set ōADO = Nothing
Set ōTextFile = Nothing
Set ōFSO = Nothing -
自动化测试框架设计随想 1
2008-07-21 18:37:50
软件测试正逐渐从手工测试往测试自动化测试方面发展,其实就是正朝业务流程自动化方向发展。自动化测试是一项工程,需要编写代码,为了保证代码的可维护性,保证代码的灵活性,它也需要设计,所以框架设计变得很重要。
我们知道在大型项目中自动化功能测试是复杂和困难的,因为它需要深入的知识背景。其中包括很重要的两方面知识:一种是编程和测试工具的技能,一种是业务知识。但通常的程序员没有足够的业务领域知识(尤其是复杂的企业系统,如ERP,BOSS等) ,但熟悉业务的测试人员又缺乏编程和自动化测试的经验。所以一般我们在自动化测试团队中需要两种人员:业务专家,主要负责测试场景的设计;
自动化测试工具专家(qtp熟悉的人,如QTP CPC): 负责开发脚本代码,调试实施的职能。要设计并实现一个强大的关键字驱动自动化框架是一项很大的挑战。在公司内部组建一个集中的自动化测试的团队设计关键字数据驱动框架,这么做的好处是可以跨多平台应用,从而节省大量的时间,精力和费用。关键字数据驱动的框架让测试人员关注测试用例的设计,自动化测试开发人员关注在功能的实现。待续............... -
Qtp如何调用vbs中创建的类?
2008-07-14 18:20:33
论坛问题 http://bbs.51testing.com/thread-119751-1-6.html
答案代码如下
Option explicit
Public function stack()
set stack = new clsStack
End Function
Class clsStack
Private l
Private Sub Class_Initialize ' Setup Initialize event.
set l = linkedList ' Create a linked list instance
End Sub
Public function pop()
If l.count = 0 Then exit function ' No items in the list
pop = l.getlast() ' Return the last item
l.deleteLast ' and delete it
End Function
Public sub push(element)
l.add element ' Add an item to the list
End sub
Public function peek()
peek = l.getlast() ' Peek at the top item
End Function
End Class在qtp中加载以上vbs文件然后在qtp中写如下代码:
Dim tStack
set tStack = stack
以上代码运行会有错误,因为linkedList类的实现我没有给出代码。
-
老婆测试工具培训记 - QTP Scripting - 实践5
2008-07-14 16:42:29
针对论坛问题进行实战,在论坛寻找没有被解决的问题进行实战代码演练,问题如下
http://bbs.51testing.com/thread-119326-1-2.html
这里面问题的难点主要利用ado如何读取数据库大二进制流的数据,如何把图片插入到excel中
ado需要利用的方法: GetChunk
功能:
返回大型文本或二进制数据 Field 对象的全部或部分内容。
语法
variable = field.GetChunk( Size )
返回值
返回变体型。
参数
Size 长整型表达式,等于所要检索的字节或字符数。
说明
使用 Field 对象的 GetChunk 方法检索其部分或全部长二进制或字符数据。在系统内存有限的情况下,可使用 GetChunk 方法处理部分而非全部的长整型值。
GetChunk 调用返回的数据将赋给“变量”。如果 Size 大于剩余的数据,则 GetChunk 仅返回剩余的数据而无需用空白填充“变量”。如果字段为空,则 GetChunk 方法返回 Null。
每个后续的 GetChunk 调用将检索从前一次 GetChunk 调用停止处开始的数据。但是,如果从一个字段检索数据然后在当前记录中设置或读取另一个字段的值,ADO 将认为已从第一个字段中检索出数据。如果在第一个字段上再次调用 GetChunk 方法,ADO 将把调用解释为新的 GetChunk 操作并从记录的起始处开始读取。如果其他 Recordset 对象不是首个 Recordset 对象的副本,则访问其中的字段不会破坏 GetChunk 操作。
如果 Field 对象的 Attributes 属性中的 adFldLong 位设置为 True,则可以对该字段使用 GetChunk 方法。
如果在 Field 对象上使用 Getchunk 方法时没有当前记录,将产生错误 3021(无当前记录)。解决问题代码:
sub main
save_pic
insert_Excel_pic
end subSub Save_Pic()
Dim DcnNWind 'As ADODB.Connection
Dim rs 'As ADODB.Recordset
set DcnNWind=New ADODB.Connection
Set rs = New ADODB.Recordset
DcnNWind.CursorLocation = adUseClient
DcnNWind.Open "Provider=SQLOLEDB.1;Integrated Security=SSI;Persist Security Info=False;InitialCatalog=CUSTOM;Data Source=SERVER"
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open "CustomInfo", DcnNWind, , adCmdTable
rs.Move 第几行数据 '指针指向到第几行数据
Call BlobToFile (rs.Fields("Image"), "c:\windows\temp\tmp.bmp", rs.Fields("Image").ActualSize)End Sub
Sub BlobToFile(fld , FileName, Optional ChunkSize )
Dim fnum , bytesLeft , bytes
Dim tmp() 'As Byte
If (fld.Attributes And adFldLong) = 0 Then
Err.Raise 1001, , "Field doesn't support the GetChunk method."
End If
If Dir$(FileName) <> "" Then Kill FileName
fnum = FreeFile
Open FileName For Binary As fnum
bytesLeft = fld.ActualSize
Do While bytesLeft
bytes = bytesLeft
If bytes > ChunkSize Then bytes = ChunkSize
tmp = fld.GetChunk(bytes)
Put #fnum, , tmp
bytesLeft = bytesLeft - bytes
Loop
Close #fnum
end sub
Sub insert_Excel_pic()
Set ōbjExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Range("A1").Select
objExcel.ActiveSheet.Pictures.Insert("C:\a.bmp").Select
'处理Excel
set ōbjExcel=Nothing
End Sub -
xmlhttp的应用
2008-07-13 10:38:10
论坛问题:
1. 在hotel.qunar.com中,城市:广州;入住时间:5-20 离店时间5-25; 用QTP将该城市搜索到的酒店及各个房型的报价记录下来。
2. 在www.qunar.com 中, 写一个qtp 脚本来验证搜索机票单程列表页各个功能问题1: 检索符合要求的酒店 可以通过如下代码获得 获得房型的报价代码还在研究中
Browser("酒店预定").Page("酒店预定").WebEdit("fromDate").Set "2008-7-21"
Browser("酒店预定").Page("酒店预定").WebEdit("toDate").Set "2008-7-22"
Browser("酒店预定").Page("酒店预定").WebCheckBox("paraSearch").Set "OFF"
Browser("酒店预定").Page("酒店预定").WebButton("酒店搜索").ClickSet xmlobj=CreateObject("Microsoft.XMLHTTP")
xmlobj.open "Get","http://hotel.qunar.com/city/guangzhou/?#priceRange=&fromDate=2008-07-21&hotelName=&_VTYPE=map&hselSearchHistory=toCity%3D%25E5%25B9%25BF%25E5%25B7%259E%26fromDate%3D2008-07-21%26toDate%3D2008-07-22&toDate=2008-07-22",false
xmlobj.send()
htmlcode= xmlobj.responsetext
Set RegEx=New RegExp
RegEx.pattern="<a href=.dt-.*"
RegEx.Global=True
regEx.IgnoreCase = true
Set matches=RegEx.execute(htmlcode)
For Each Match in matches
RetStr = Match.Value
RetStr =RegExp_Replace(patrn,RetStr ,"")
RetStr =RegExp_Replace(patrn,RetStr ,"")
'print RetStr
NextSet regex=nothing
Set RegEx=New RegExp
RegEx.pattern="\<.+?>\s*([\s\S]*?)\s*</a>"
RegEx.Global=True
Set matches=RegEx.execute(RetStr)For Each Match in matches
RetStr= Match.submatches(0)
print RetStr
NextSet regex=nothing
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function
------------------------------------------
代码增强,需要验证搜索到的结果正确性,代码没有经过验证,因为不知道后台数据库Browser("酒店预定").Page("酒店预定").WebEdit("fromDate").Set "2008-7-21"
Browser("酒店预定").Page("酒店预定").WebEdit("toDate").Set "2008-7-22"
Browser("酒店预定").Page("酒店预定").WebCheckBox("paraSearch").Set "OFF"
Browser("酒店预定").Page("酒店预定").WebButton("酒店搜索").ClickSet xmlobj=CreateObject("Microsoft.XMLHTTP")
xmlobj.open "Get","http://hotel.qunar.com/city/guangzhou/?#priceRange=&fromDate=2008-07-21&hotelName=&_VTYPE=map&hselSearchHistory=toCity%3D%25E5%25B9%25BF%25E5%25B7%259E%26fromDate%3D2008-07-21%26toDate%3D2008-07-22&toDate=2008-07-22",false
xmlobj.send()
htmlcode= xmlobj.responsetext
Set RegEx=New RegExp
RegEx.pattern="<a href=.dt-.*"
RegEx.Global=True
regEx.IgnoreCase = true
Set matches=RegEx.execute(htmlcode)
For Each Match in matches
RetStr = Match.Value
RetStr =RegExp_Replace(patrn,RetStr ,"")
RetStr =RegExp_Replace(patrn,RetStr ,"")
'print RetStr
NextSet regex=nothing
Set RegEx=New RegExp
RegEx.pattern="\<.+?>\s*([\s\S]*?)\s*</a>"
RegEx.Global=True
Set matches=RegEx.execute(RetStr)dim conn
dim rst
set conn=createobject("adodb.connection")
conn.open "数据库联接字符串"set rst=createobject("adodb.recordset")
rst.open "select * from 表 where 条件符合宾馆地点的 orderby 符合服务器传输数据顺序的",connrst.movefirst
For Each Match in matches
RetStr= Match.submatches(0)
if RetStr=rst.fields("列") thenmsgbox "符合条件"
else
msgbox "数据不符合"
end ifprint RetStr
rst.movenext
Next
rst.close
set rst=nothing
conn.close
set conn=nothingSet regex=nothing
Function RegExp_Replace(patrn,str,replStr)
Dim regEx ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置是否区分大小写。
RegExp_Replace = regEx.Replace(str,replStr) ' 作替换。
End Function
问题2 需要具体知道验证点问题不明确第一个问题还需要跟开发人员交流下,了解页面布局,知道价钱所在位置后,利用dom技术进行页面解析,分解出来所要的数据。
现在仅仅依靠自己分析页面布局,工作量比较大,而且进展很慢。
-
qtp 成为高手需要掌握常用com对象
2008-07-11 15:47:17
成为高手需要了解的基本com对象处理技术,了解常用的com对象的使用,如果你想成为高手,那么从下面对象开始吧:
文件系统对象相关:
("scrīptING.FILESYSTEMOBJECT")应用:数据驱动技术常用,日志输入常用
字典相关:
("scrīptING.DICTIONARY")应用:脚本配置控制开关 list对象item数据对比
脚本外壳相关:
("Wscrīpt.SHELL")应用:最常用其中的sendkeys方法,利用在不可识别对象技术方面
WINDOWS外壳相关:
("SHELL.APPLICATION")正则表达式相关:
("VBscrīpt.REGEXP")应用:网页解析,数据对比 验证点技术实现的一种
编码与密码相关:
("scrīptPW.PASSWORD")
( "scrīptING.ENCODER" )应用:数据包传输测试过程中应用
邮件发送的组件相关:
("JMAIL.MESSAGE")
("CDONTS.NEWMAIL")
("CDO.CONFIGURATION")
("EUDORA.EUAPPLICATION.1")
("NOVELLGROUPWARESESSION")应用:测试报告发送
水晶报表相关:
("CRYSTALRUNTIME.APPLICATION")应用:测试报告美化,常用的是excel的报告输出,这种技术用的少
IE浏览器相关:
("INTERNETEXPLORER.APPLICATION")应用:web测试用的比较多
ADO相关:
("ADODB.CONNECTION")
("ADODB.COMMAND")
("ADODB.RECORDSET")
("ADODB.RECORD")
("ADODB.STREAM")
("DAO.DBENGINE.35")
("ADOX.CATALOG")
("ADOX.TABLE")应用:数据驱动,数据库验证,dao主要利用在access数据库处理
SQL相关:
("SQLDMO.SQLSERVER")
("SQLDMO.LOGIN")
("SQLDMO.BACKUP")
("SQLDMO.USER")
("SQLDMO.BACKUPDEVICE")
("SQLDMO.DATABASE")
("SQLDMO.RESTORE")
("SQLDMO.APPLICATION")OFFICE相关:
("WORD.APPLICATION")
("EXCEL.APPLICATION")
("POWERPOINT.APPLICATION")
("EXCEL.SHEET")
("FRONTPAGE.APPLICATION")
("ACCESS.APPLICATION")
("MSGRAPH.APPLICATION")
("OUTLOOK.APPLICATION")应用:测试报告输出,数据驱动
WMI相关:
("WBEMscrīptING.SWBEMDATETIME")
("WBEMscrīptING.SWBEMLOCATOR")
("WBEMscrīptING.SWBEMNAMEDVALUESET")
("WBEMscrīptING.SWBEMSINK", "SINK_")
("WBEMscrīptING.SWBEMREFRESHER")
("WBEMscrīptING.SWBEMLASTERROR")
("WBEMscrīptING.SWBEMOBJECTPATH")应用:初始化测试环境
对象为我所用,我为测试所用
-
老婆测试工具培训记 - QTP Scripting - 实践4
2008-07-10 22:44:02
Write a program to read and delete cookies?
关键点在于常识:cookies所存放的文件夹位置
Set fso = CreateObject("scrīpting.FilesystemObject")
set wshNetwork = CreateObject("Wscrīpt.Network")
struser = wshNetwork.UserName
fso.DeleteFile "C:\DOCUMENTS AND SETTINGS\" & struser & "\COOKIES\*.*",Force
fso.DeleteFile "C:\DOCUMENTS AND SETTINGS\" & struser & "\LOCAL SETTINGS\TEMP\*.*",Force
fso.DeleteFile "C:\DOCUMENTS AND SETTINGS\" & struser & "\LOCAL SETTINGS\TEMPORARY INTERNET FILE\*.*",Force
fso.DeleteFile "C:\WINNT\TEMP\*.*",Forceset fso=nothing
set wshNetwork=nothingwhat a Limitations of DataTable QTP?
Maximum worksheet size—65,536 rows by 256 columns
Column width—0 to 255 characters
Text length—16,383 characters
Formula length—1024 characters
Number precision—15 digits
Largest positive number—9.99999999999999E307
Largest negative number— -9.99999999999999E307
Smallest positive number—1E-307
Smallest negative number— -1E-307
Maximum number of names per workbook—Limited by available memory
Maximum length of name—255
Maximum length of format string—255
Maximum number of tables (workbooks)—Limited by system resources (windows and memory) -
老婆测试工具培训记 - QTP Scripting - 实践3
2008-07-10 11:18:45
工具只是自动化测试的手段,完全可以利用其他方式来编写脚本自动化,今天的自动化脚本实现的目标是
Write a program to List all links in the web page?
Write a program to Check whether given link exists?
以上两个问题其实很类似,只不过是后面稍微变化了下,我们来看下代码的实现,根据第一个例子的解决方法实现第二个解决方法
程序1
问题1解决方法:
Dim oAnchors
Dim oAnchorSet ōAnchors = Browser(X).Page(X).WebTable(X).Object.GetElementsByTagName("A") '获得页面的所有链接
For Each oAnchor in oAnchors
msgbox oAnchor.innertext
Next 'oAnchorSet ōAnchors = Nothing
问题2解决方法
Dim oAnchors
Dim oAnchor
Dim blnFoundSet ōAnchors = Browser(X).Page(X).WebTable(X).Object.GetElementsByTagName("A")
blnFound = False
For Each oAnchor in oAnchors
If oAnchor.innertext = "Whatever" Then
oAnchor.Click()
blnFound = True
End If
Set ōAnchor = Nothing
If blnFound = True Then Exit For
Next 'oAnchorSet ōAnchors = Nothing
实际问题应用:2006年在论坛上有位广州的朋友问得一个问题
QuickTestPro处理带有IFRAME的问题原问题链接:http://bbs.51testing.com/viewthread.php?tid=35723&extra=page%3D1
解决问题的答案: http://www.51testing.com/html/27/1566.html
http://www.51testing.com/html/27/1565.html
思考题:利用dom技术解决以上问题
项目实际问题延伸:
对比页面table表格中的数据,利用ado读取数据库内容,然后对比页面实际数据,页面扫描cell代码如下:
Dim objRows
Dim objRow
Dim objCells
Dim objCell
Dim blnFound
Dim lngCellCountSet ōbjRows = Browser(X).Page(X).WebTable(X).Object.GetElementsByTagName("TR")
blnFound = False
lngCellCount = 0For Each objRow in objRows
Set ōbjCells = objRow.GetElementsByTagName("TD")
For Each objCell in objCells
If objCell.InnerText = "需要查找的内容,可以利用数据库读取的数据对比" Then
'可以打印报告 你可以按照自己的意愿自己处理
End If
Set ōbjCell = NothingNext 'objCell
Set ōbjCells = Nothing
Set ōbjRow = Nothing
Next 'objRowSet ōbjRows = Nothing
-
老婆测试工具培训记 - QTP Scripting - 实践2
2008-07-09 18:35:25
今天培训的内容是关闭特定程序,这里特定程序是browser,涉及到的知识点有com,可描述性编程,虽然有些难度,老婆还是很快搞定了,希望老婆再接再厉。
Write a program to close all browsers from QTP?
思路:解决问题 关闭ie所有的进程 利用dp的方法关闭
程序1:利用Systemutil的方式关闭
systemutil.CloseProcessByName "IEXPLORE.EXE"
程序2:利用wmi关闭
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'IEXPLORE.EXE'"Set ōbjWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
NextSet ōbjWMIService=Nothing
程序3:
利用QuickTest Professional Descrīptive Programming.动态处理Browser
Do While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").Close
Loop思考题:利用api的方式关闭特定的进程
-
老婆测试工具培训记 - QTP Scripting - 实践1
2008-07-09 12:49:41
Write a program to enter data in login screen
思路:1.录制程序 2.增强脚本进行数据驱动
程序1:
systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set "lytester"
Dialog("Login").WinEdit("Password:").SetSecure "48743575b1759f8f151c2d2741124daec13d6e7d"
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close程序2:
数据驱动:文件数据驱动,利用FSO对象'文件格式
'111111,mercury
'22222,mercuryDim fso
Dim f
'......
Dim s_User
Dim s_Pwd
Dim arrTempSet fso=CreateObject("scrīpting.filesystemobject")
Set f=fso.OpenTextFile("路径",1,false)Do while f.atEndOfLine<>true
s_Temp=f.ReadLine
arrTemp=split(s_Temp,",")
s_User=arrTemp(0)
s_Pwd=arrTemp(1)
systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set s_User
Dialog("Login").WinEdit("Password:").Set s_Pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
loopf.close
set f=nothing
set fso=nothing思考题目:实现数据驱动脚本包含登陆的所有成功和失败的情况
2 Write a program to find the x and y coordinates of a buttonDim x
Dim ysystemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
x=Dialog("Login").WinButton("OK").GetROProperty("x")
y=Dialog("Login").WinButton("OK").GetROProperty("y")
msgbox "x:"+cstr(x)+";y:"+cstr(y)思考题目:API方式
3 Write a program to Read items in a list box
思路:利用VB addin 识别对象后利用getcontent方法实现
Dim sContent 'as string
Dim MyArray ' this is a array
Dim strMsg 'as stringsContent = VbWindow("Form1").VbList("List1").GetContent()
MyArray = split( sContent ,vbLf)For i=LBOUND(MyArray) to UBound(MyArray)
strMsg=strMsg+MyArray(i)
NextMsgBox strMsg
思考题:利用Api方式获得
-
自动化测试框架设计
2008-07-08 16:26:10
标题搜索
我的存档
数据统计
- 访问量: 205701
- 日志数: 169
- 图片数: 10
- 文件数: 4
- 建立时间: 2006-11-30
- 更新时间: 2012-08-18