sanlengjingvv 发表于 2014-1-23 16:07:29

QTP入门,以11.5为例

本帖最后由 sanlengjingvv 于 2014-3-25 20:35 编辑

注:6楼更新检查点、参数换相关内容。外链图被缩小了,在新标签中可查看大图。
准备工作:QTP11.5安装教程:http://www.iquicktest.com/qtp-uft-11-5-download.html注: QuickTest Pro(QTP)11.5后更名为UnifiedFunctional Testing(UFT)1、安装后打开QTP,勾选Web add-in,进入QTP后File-New-Test。http://img.blog.csdn.net/20140120140456359?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2、选择File菜单下New-Test。http://img.blog.csdn.net/20140221090513312?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

选择GUI Test,输入Name“第一个脚本”,Create。http://img.blog.csdn.net/20140221090539046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

3、打开IE,进入百度首页www.baidu.com。4、使用Tools菜单下的ObjectSpy。http://img.blog.csdn.net/20140120140645375?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

5、点击手型按钮,点击后鼠标变为手型,再点击浏览器上的“百度一下”按钮。http://img.blog.csdn.net/20140120140724093?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140120140742875?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

6、正常识别结果如图:http://img.blog.csdn.net/20140120140822375?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

未能识别结果如图:http://img.blog.csdn.net/20140120140853140?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
如果未能识别对象:1、检查QTP版本、浏览器版本、操作系统版本,QTP安装目录“\help”下的QTP_PAM.pdf或UFT_PAM.pdf文件提供了支持的操作系统、插件版本、web-addin支持的浏览器及版本、支持的其他HP工具及版本等信息。1.1、例如测试WEB时,可以从这个PDF文档里得出支持的组合如XPsp3+QTP11+IE8,Win7+UFT11.5+IE9,UFT11.53+Chrome30,不支持组合如QTP11+FireFox27。1.2、QTP11官方提供了IE9补丁,安装后可以识别IE9对象。1.3、64位系统下的IE也分32位和64位,例如QTP11测试64位IE,还需要64位补丁。
QTP11补丁:http://blog.csdn.net/zzxxbb112/article/details/6968418QTP11.5补丁:http://www.iquicktest.com/uft-qtp11-5-patches.html
2、检查浏览器插件,IE是否加载了BHOmanagerClass。IE设置-Internet选项-程序-管理加载项-所有加载项。如果BHOmanager Class是未启用状态,改为启用。http://img.blog.csdn.net/20140120141048500?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

如果所有加载项中没有BHOmanager Class,打开开始菜单-HP Software-HP Unified Functional Testing-Tools-AdditionalInstallation Requirements,勾选“配置Internet Explorer 设置”,运行。http://img.blog.csdn.net/20140120141116750?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2.1、FireFox和Chrome同样需要检查插件是否安装并启用。FireFox附加组件-扩展中应有UnifiedFunctional Testing Extension。Chrome工具-扩展程序中应有UnifiedFunctional Testing Agent。3、以管理员身份运行QTP。4、如果仍不能识别,尝试关闭其他程序、关闭杀毒软件,先打开QTP后打开IE再识别。
第一个脚本:1、打开QTP,加载Web add-in。2、打开IE,进入百度首页www.baidu.com3、打开QTP本地对象库,打开Resources菜单下的ObjectRepositoryhttp://img.blog.csdn.net/20140120141334937?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

4、添加对象到本地对象库。Object菜单下的Add Object to Local
http://img.blog.csdn.net/20140120141413031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

点击百度输入文本框。http://img.blog.csdn.net/20140120141434031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

点击OK后,就出现在对象库了。http://img.blog.csdn.net/20140120141502031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140120141522921?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

选中wd对象,使用View菜单下的Highlightin Application,如果浏览器中的输入框闪烁说明QTP能正确定位对象。http://img.blog.csdn.net/20140120141605781?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

以相同步骤添加“百度一下”按钮
5、刷新Toolbox以显示新添加的对象。http://img.blog.csdn.net/20140120141647890?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

刷新后界面http://img.blog.csdn.net/20140120141710812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

6、拖拽wd对象到右侧编辑区(或双击wd对象):http://img.blog.csdn.net/20140123153913031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast在Set后输入参数:http://img.blog.csdn.net/20140120141853046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

7、拖拽“百度一下”对象到编辑区(或双击对象)http://img.blog.csdn.net/20140123154058062?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
8、运行脚本。Run菜单下的Run。http://img.blog.csdn.net/20140120141947250?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

点击Runhttp://img.blog.csdn.net/20140120142017734?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

运行后结果:http://img.blog.csdn.net/20140120142116875?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

代码结构:父对象Class(“父对象Name”).子对象Class(“子对象Name”).方法 [参数]http://img.blog.csdn.net/20140120142155828?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

sanlengjingvv 发表于 2014-1-23 16:19:52

本帖最后由 sanlengjingvv 于 2014-2-21 09:56 编辑

实例:对象库如何工作:1、添加“百度一下”按钮到对象库(参考“第一个脚本”1-4步),使用Highlight可以定位对象。如图,“百度一下”对象的name属性是“百度一下”。http://img.blog.csdn.net/20140120142226546?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

2、修改“百度一下”对象的name属性为“百度一下修改”,并将“Enable Smart Identification”的Value改为False。再使用Highlight,QTP提示错误“不能在应用中找到选择的对象”。http://img.blog.csdn.net/20140120142253000?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
http://img.blog.csdn.net/20140120142316609?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

3、打开IE的开发者人员工具(F12),如图,使用鼠标形按钮选择“百度一下”按钮。选择后HTML代码定位到相应元素。修改“百度一下”按钮元素的value值为“百度一下修改”。http://img.blog.csdn.net/20140120142342593?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

修改前代码:<inputclass="bg s_btn" id="su"onmouseout="this.className='bg s_btn'"onmousedown="this.className='bg s_btn s_btn_h'"type="submit"value="百度一下"/>修改后代码:<inputclass="bg s_btn" id="su"onmouseout="this.className='bg s_btn'"onmousedown="this.className='bg s_btn s_btn_h'"type="submit"value="百度一下修改"/>修改后页面:http://img.blog.csdn.net/20140120142411984?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

修改后在对象库中选择“百度一下”对象使用Highlight,QTP又能正确定位了。
4、修改“百度一下”按钮位置,如图:http://img.blog.csdn.net/20140120142434171?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

修改后在对象库中选择“百度一下”对象使用Highlight,能正确定位。
5、复制“百度一下”按钮代码,在页面上再添加一个按钮,修改后如图http://img.blog.csdn.net/20140120142459468?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

修改后在对象库中选择“百度一下”对象使用Highlight,能正确定位。QTP提示错误:有多个符合描述的对象。http://img.blog.csdn.net/20140120142521781?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

添加界面上两个“百度一下”按钮到对象库,现在对象库里有三个“百度一下”按钮对象,对比属性,只有ordinal identifier部分不一样。界面只有一个按钮时添加的对象Type,Value值是Nonehttp://img.blog.csdn.net/20140120142544546?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

界面有两个个按钮时添加的对象Type,Value值分别是”index,1”和”index,2”http://img.blog.csdn.net/20140120142610953?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140120142617343?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

对象库工作模型:1、添加对象时:http://img.blog.csdn.net/20140123154422453?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
1.1、QTP Spy被测软件被选中的对象,获取对象的属性集合和对象类型。1.2、按照Object Identification中相应对象类型的设置,筛选属性集合后存入对象库。1.3、打开Tools菜单下Object Identification,如图,以WebButton为例。http://img.blog.csdn.net/20140123154531109?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140123154658125?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2、运行时:http://img.blog.csdn.net/20140123154840812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2.1、如运行到第二行。http://img.blog.csdn.net/20140120142847593?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

QTP读取对象库中Class是WebButton,name是“百度一下”的对象,获取属性集合(TO)。2.2、获取被测软件上的对象集合。2.3、获取第一个对象的属性集合(RO)。对比RO和TO。2.4、如果属性值不一致,获取第二个WebButton对象的属性集合后对比。如果属性值一致,则触发WebButton对象的方法。
关于录制:使用录制后可以看出录制自动完成了添加对象到对象库和在编辑区输入脚本(对象、方法和参数)的过程。但录制经常有步骤缺失的问题,比如实际点击某个页面对象A但录制结束后对象库中没有对象A,编辑区也没有相关代码。不补全脚本就Run就会报错了。
使用QTP帮助文档:在编辑区选中Browser("").Page("").WebEdit("")下的Set 按F1,帮助文档会自动定位到Web> WebEdit Object > Methods > Set Method,帮助文档提供了语法、参数说明、返回类型和例子,查看Example可以看到代码示例。http://img.blog.csdn.net/20140123155022171?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140120143102031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
点击WebEdit Object,可以看到WebEdit对象的说明、方法和属性,http://img.blog.csdn.net/20140120143133156?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEasthttp://img.blog.csdn.net/20140120143146265?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
http://img.blog.csdn.net/20140120143152203?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

Alvin-x 发表于 2014-2-7 13:58:02

伟大的雷锋精神,赞一个!

赵佳乐SMILE 发表于 2014-2-7 15:26:42

赞 图太小

黑羽祭 发表于 2014-2-12 09:19:54

教学贴~赞一个

sanlengjingvv 发表于 2014-2-21 09:18:10

本帖最后由 sanlengjingvv 于 2014-3-27 11:55 编辑

检查点
1、新建一个脚本,在百度知道(http://zhidao.baidu.com/)页添加关键字输入框和搜索答案对象,添加后如图:http://img.blog.csdn.net/20140327104531515?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

输入以下脚本:http://img.blog.csdn.net/20140327104605859?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2、执行后打开对象库,选择”word”对象使用Highlightin Application,在搜索后的百度页面仍能定位。3、使用Object Spy查看搜索后页面的文本框,查看value属性,值为“QTP”。删除文本框内容后使用Object Spy,查看value属性,值为空,如图。所以这里可以用对象“word”的value属性值判断功能是否正确。http://img.blog.csdn.net/20140327104702453?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

4、修改脚本如下,修改后Run。http://img.blog.csdn.net/20140327104726859?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

5、运行后打开View菜单下的Last RunResults。http://img.blog.csdn.net/20140327104754093?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

如图, Property "value" has the expected value:"QTP".对象“word”的value属性的值是期望的“QTP”,检查点Pass。http://img.blog.csdn.net/20140327104822796?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast


参数化1、在Global表中输入多行数据,并修改脚本如下。http://img.blog.csdn.net/20140327104847265?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
2、打开File菜单下的Settings,设置Run如下。
http://img.blog.csdn.net/20140220171528828?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

3、Run脚本,可以看到执行过程中依次搜索了Global表中的数据,打开Last Run Results,可以每次迭代的结果,如图,每次迭代检查点都有记录。http://img.blog.csdn.net/20140327104926000?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

4、选中Global表中有数据的行,在右键菜单中选择Delete删除行。http://img.blog.csdn.net/20140220171645375?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

注意,如果删除了表格中的内容——比如用键盘的退格和删除,而有黑线的行仍是三行(如图),还是会迭代三次。http://img.blog.csdn.net/20140220171719640?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

5、在Action1表中输入多行数据,并修改脚本如下,注意脚本和使用Global表时不同。http://img.blog.csdn.net/20140327105018281?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

6、打开View菜单下的TestFlow。http://img.blog.csdn.net/20140220171808531?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

右键Action1,在菜单中选择Action Call Properties。http://img.blog.csdn.net/20140220172548421?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

设置如下。http://img.blog.csdn.net/20140220172613500?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

7、Run脚本,可以看到执行过程中依次搜索了Action1表中的数据,打开Last Run Results可以查看结果。
参数化迭代流程图A:一个脚本可以有多个Action。B:File-Settings-Run下的设置控制脚本的迭代。C:Action CallProperties-Run下的设置控制Action的迭代。http://img.blog.csdn.net/20140220172806203?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

一个迭代实例1、新建GUI Test,选择Design菜单下的Call toNew Actionhttp://img.blog.csdn.net/20140220172641078?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

点击“OK”后添加了一个action。http://img.blog.csdn.net/20140220172915781?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

2、在Global表添加两行数据“Global第1行”和“Global第2行”;Action1表下添加两行数据“Action1第1行”,“Action1第2行”;Action2表下添加两行数据“Action2第1行”,“Action2第2行”。3、修改File-Settings-Run设置为Run on allrows。修改Action1和Action2的Call Properties-Run设置为Run on all rows。4、在Action1和Action2的编辑区输入下图脚本。http://img.blog.csdn.net/20140220172940109?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2FubGVuZ2ppbmd2dg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

5、Run脚本,可以看到弹窗出现16次,依次如下:Global第1行Action1第1行Global第1行Action1第2行Global第1行Action2第1行Global第1行Action2第2行Global第2行Action1第1行Global第2行Action1第2行Global第2行Action2第1行Global第2行Action2第2行

xuguilin2010 发表于 2014-2-21 19:56:05

赞一个,感谢分享

janexujing 发表于 2014-3-12 10:19:06

大爱,谢谢分享,很好的东西:)

fengchu_007 发表于 2014-3-12 16:54:00

感谢楼主分享

天下有雪 发表于 2014-3-14 11:36:36

伟大的雷锋精神!!!!!

CrazyPolaris 发表于 2014-3-16 16:40:45

谢谢分享!!!

让测试飞起来 发表于 2014-3-17 10:36:45

真是太强大了!
太谢谢了

ycw 发表于 2014-3-17 12:42:40

很好,非常感谢楼主的分享

413601429 发表于 2014-3-17 13:51:52

:lol好人一生平安。。

lianghuimei 发表于 2014-3-19 10:43:54

检查点
1、打开编写的“第一个脚本”,Run。
2、执行后打开对象库,选择”wd”对象使用Highlightin Application,在搜索后的百度页面仍能定位。

请问一下,在实践检查点时,在执行后的搜索页面,Highlightin定位不到“wd”对象了是为什么?(QTP10+win764+IE9)

sanlengjingvv 发表于 2014-3-21 22:09:09

本帖最后由 sanlengjingvv 于 2014-3-26 16:44 编辑

回复 15# lianghuimei

这里有问题,搜索前和搜索后的页面被认为是两个Page对象,我找个其他网站做例子。
谢谢指出

页: [1]
查看完整版本: QTP入门,以11.5为例