|
本帖最后由 stone1121 于 2012-5-4 17:24 编辑
求助:Excel表实现参数化提示错误信息(QTP刚学习不知道问题出在那里,还请高手帮忙分析解决,谢谢!)[img]file:///C:/Users/Administrator/Documents/Tencent%20Files/479366081/Image/S[91RSTX3%7D6%7DD0~1RV%60$JM7.jpg[/img]
代码如下:
'获取参数文件路径
FilePath=Environment("TestDir")&"\data.xls"
Set ExcelBook=CreateObject("Excel.Application")
'设置为true的情况,文档会打开
ExcelBook.Visible=false
ExcelBook.DisplayAlerts=false
Set MyExcelBook=ExcelBook.WorkBooks.Open(FilePath)
Set MyExcelSheet=MyExcelBook.Sheets("Sheet1")
'获取Excel表中记录的条数
GetExcelSheetRowsCount=MyExcelSheet.UsedRange.Rows.Count
'注意Excel表记录的第一行为1而不是0
'参数文件中第一行为参数名,而非具体的参数值,故从第二行开始
Dim userName
Dim password
For i=2 to GetExcelSheetRowsCount
systemutil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","",""
userName=MyExcelSheet.cells(i,1)
password=MyExcelSheet.cells(i,2)
'输入用户名
Dialog("Login").WinEdit("Agent Name:").Set userName
'输入密码
Dialog("Login").WinEdit("Password:").SetSecure password
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
wait(2)
Next
ExcelBook.Quit
Set ExcelBook=Nothing
错误信息提示:The "Login" object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (20): "Dialog("Login").WinEdit("Agent Name:").Set userName". |
|