QTP资料整理

发表于:2008-9-16 14:32

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:wonew1228    来源:51Testing软件测试博客

  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

22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号