代码如下:
'获取参数文件路径
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".作者: lifreshman0626 时间: 2012-5-5 19:04
Login这个Dialog控件还没有添加到对象库作者: stone1121 时间: 2012-5-7 14:04 回复 2#lifreshman0626
谢谢你,我知道错误的原因了 现在弄好了作者: yubing4828 时间: 2012-5-7 14:51
在QTP对象库中添加Login框框控件,以及上面的编辑框,按钮;
或者不加对象,描述下,比如Dialog("micClass:=Login").…… 当然不一定是micClass,可以用spy查看下login对话框属性