QTP在excel中写入内容
<
/p>
filename="D:\xyb\xueyb\xueyb.xls" ' create the Excel object Set ExcelObj = CreateObject("Excel.Application") ExcelObj.Workbooks.Add Set NewSheet = ExcelObj.Sheets.Item(1) NewSheet.Name = "Page Information" row = 1 NewSheet.Cells(1,1) = "name" NewSheet.Cells(1,2) = "xueyb" NewSheet.Columns("A:A").ColumnWidth = 20 NewSheet.Columns("A:A").Font.Bold = True NewSheet.Columns("B:B").ColumnWidth = 60 NewSheet.Columns("B:B").HorizontalAlignment = -4108 ' xlCenter ' save the Excel file ExcelObj.ActiveWorkbook.SaveAs filename ExcelObj.Quit Set ExcelObj = Nothing |
QTP等待某个对象出现方法
Window("Flight Reservation").Static("Static").WaitProperty("visible",true,10000) |
例:
SystemUtil.Run "E:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","E:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").Click 177,47 Dialog("Login").WinEdit("Agent Name:").Set "mercury\" Dialog("Login").WinEdit("Password:").SetSecure "4886c0abed388164f4f9c00404eef82ad60997ea" Dialog("Login").WinButton("OK").Click If Window("Flight Reservation").Static("Static").WaitProperty("visible",true,10000) ==true Then msgbox("flight4A登录成功!") else msgbox("flight4A登录失败!") End If |
QTP childobject的应用
childobject可以返回界面上满足条件 的对象集合,而且与对象库里是否有这些对象无关,这就可以简化对象库;
返回的对象集合的count方法可以返 回对象个数,这就可以通过下标对单个对象进行操作;在出现index标识对象时可以进行运用
如:
< /table>QTP Action之间的参数传递
例如:在Action1中,有如下代
码:
Set
m_WinCheck=Descrīption.Create() m_WinCheck("nativeclass").Value="Button" set All_WinCheck=Window("").Dialog("").Childobject(m_WinCheck) n=All_WinCheck.Count() for i=0 to n-1 All_WinCheck(i).Set "ON" next |
out_str="This is out_string" RunAction "Action2",oneIteration,out_str |
在Acton2中,在其step->Action Properties中的,input参数栏,加入out_str后,msgbox(parameter("out_str")),就能正确显示参数 了
QTP 自动截图
1. 选择菜单栏Tools->Option项,再选择Run选项卡,在Run窗体中选中“Save still image captures to results,且它右边的下拉框中选择“For errors”
2.
用CaptureBitmap("D:\1.bmp")
Browser("XX").Page("XX").CaptureBitmap("D:\1.bmp") |
本文出自51Testing软件测试博客,转载请注明出处:
http://www.51testing.com/?57326/action_viewspace_itemid_92852.html