如何将Excel数据导入到QTP中得DataTable
本帖最后由 ll7140042511 于 2011-9-1 14:43 编辑以下是具体脚本:
SystemUtil.Run PathFinder.Locate("C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"),"",PathFinder.Locate("C:\Program Files\HP\QuickTest Professional\samples\flight\app"),"open"
DataTable.ImportSheet PathFinder.Locate("C:\Program Files\HP\QuickTest Professional\Tests\调用Action1\Login.xlsx"),"Login_Sheet","Action1"
Dim i,RowCount
i=0
RowCount=DataTable.GetSheet("Action1").GetRowCount
Reporter.ReportEvent micDone,"RowCount="&RowCount,RowCount
Do While(i<RowCount)
i=i+1
DataTable.SetCurrentRow(i)
Dialog("Login").WinEdit("Agent Name:").Set DataTable("username",dtLocalSheet)
Dialog("Login").WinEdit("Password:").Set DataTable("password",dtLocalSheet)
Dialog("Login").WinButton("OK").Click
If Dialog("Login").Dialog("Flight Reservations").Exist Then
Dim err_message
err_message=Dialog("Login").Dialog("Flight Reservations").Static("Please enter agent name").GetROProperty("text")
Reporter.ReportEvent micFail,"登陆失败","错误信息是:"&err_message
Dialog("Login").Dialog("Flight Reservations").WinButton("确定").Click
Dialog("Login").WinButton("Cancel")
SystemUtil.Run PathFinder.Locate("C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"),"",PathFinder.Locate("C:\Program Files\HP\QuickTest Professional\samples\flight\app"),"open"
else
Reporter.ReportEvent micPass,"登陆成功","登陆成功"
End If
Loop
结果失败,得到的RowCount=0中间的循环语句没有运行.
这是怎么回事,哪个大虾可以帮帮我??? 我外部建的是07版本的Excel文件,改成97-03版本就行了。
QTP不支持07版本Excel。 ;P
页:
[1]