QTP - evergreen_wang - 51Testing软件测试网 - Power...
来源:百度文库 编辑:神马文学网 时间:2024/05/23 23:59:54
copy Bookmark http://www.51testing.com/?6254
空间管理 您的位置: 51Testing软件测试网 » evergreen_wang » 文件 微笑着面对每天,善待自己……QTP
上一篇 / 下一篇 2009-07-10 16:47:22 / 个人分类:资料
查看( 77 ) / 评论( 0 ) / 评分( 0 / 0 )- 文件版本: V1.0
- 开发商: 本站原创
- 文件来源: 本地
- 界面语言: 简体中文
- 授权方式: 免费
- 运行平台: Win9X/Win2000/WinXP
'例1:运行一个exe文件
Extern.WinExec "d:\1.exe ", 1'例2:Beep
'它让我的机器在办公室里狂响不止!
Extern.Declare micLong, "Beep", "kernel32.dll", "Beep", micLong
Extern.Beep 500
QTP 获取对话框中的信息
如果弹出对话框就获取上面提示信息并与表中的信息对比,不统一证明弹出的提示出错,主要用来验证
if browser("web_name").dialog("dialog_name").exist(1) then'如果不出现=false
error_message=browser("web_name").dialog("diaglog_name").static("用户密码错误!".getRoproperty("text")
if error_message<>(datatable.value("error_info"))then
msgbox(error_message)
end if
browser("web_name").dialog("diaglog_name").close
end if
这里我总结了两点技巧:
一是:对于dialog中,虽然提示信息对象名称是"用户密码错误",但如果信息对象名称是“该用户不存在”,不用更改会自动识别,我想主要是录制第一遍时,“用户密码错误”只是让运行时能找到这个控制,而不管它是什么内容,因为在对象仓库中,text不是决定该对象的属性
二是:如果对于提示信息比较长的,可以用mid(error_message,n,m)取一部份特征提示信息进行验证,这样我想可以节省处理时间,又可以避免长度以及空格等字符的处理
QTP获取对象属性名称用法:
GetRoProperty----从应用程序界面上获取对象属性(即,是脚本运行时,获取的对象动态属性值)
例如:获取对象库中index属性值,似乎只能用GetToProperty,因为应用程序界面上对象没有该属性,只是QTP为识别该对象创立的描述属性;
GetToproperty----从对象库中描述对象的属性,静态值
GetToProperties----获取用于标识对象的属性集;对于这个集合,有count等属性方法
QTP在执行过程中往excel中写入值
DataTable.GlobalSheet.AddParameter "Name", "liuxuedong"取datatable特定行的数据可以这样使用
DataTable.GetSheet("Action1").GetParameter("test\").ValueByRow(1)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
收藏 分享给好友 管理 举报
TAG:
查看全部评论evergreen_wang
测试因仔
用户菜单
- 给我留言
- 加入好友
- 发短消息
- 我的介绍
- 论坛资料
- 空间管理
我的栏目
- 资料
- 工具
标题搜索
日历
« 2010-08-26 日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31我的存档
- 2010年03月
- 2010年02月
- 2010年01月
- 2009年12月
- 2009年11月
- 2009年10月
- 2009年09月
- 2009年08月
- 2009年07月
- 2009年06月
数据统计
- 访问量: 2503
- 日志数: 43
- 文件数: 6
- 建立时间: 2009-06-17
- 更新时间: 2010-03-10
RSS订阅
Powered by X-Space 4.0Final © 2001-2008 Comsenz Inc.
沪ICP备05003035号