3_td_qtp实用操作手册—银行付款实例讲解_第1页
3_td_qtp实用操作手册—银行付款实例讲解_第2页
3_td_qtp实用操作手册—银行付款实例讲解_第3页
3_td_qtp实用操作手册—银行付款实例讲解_第4页
3_td_qtp实用操作手册—银行付款实例讲解_第5页
已阅读5页,还剩56页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

2018/1/5,iSoftStone Information Service Corporation,TD+QTP使用操作手册,银行付款实例讲解,2005 iSoftStone Information Service Corporation. All rights reserved.,2,目录,测试设计测试实现测试执行,2005 iSoftStone Information Service Corporation. All rights reserved.,3,测试设计设计测试用例,现在要针对银行付款业务设计一个测试用例,进行功能的覆盖1 划分业务功能、画出业务流程图,1 新增,2复核,3 取消复核,4 修改,5 删除,2005 iSoftStone Information Service Corporation. All rights reserved.,4,测试设计设计测试用例,2 根据流程图,写出测试方案银行付款有一个起始点,两个结束点,按照功能覆盖的思想,选择两条路径即可。如果要考量到动作之间的关联性,路径就比较多了。基于以往的经验,取消复核、二次复核比较容易出现问题,因此两条路径分别为:路径一:新增-复核-取消复核-修改-复核路径二:新增-复核-取消复核-删除3 确定业务功能在流程图中,可以得出,本业务可以划分成以下业务功能:新增、复核、取消复核、修改、删除,2005 iSoftStone Information Service Corporation. All rights reserved.,5,测试设计设计测试用例,4 确定业务数据由于只要进行流程的覆盖,所以暂时可以把业务数据作的简单一点。5 在TD中录入测试用例访问TD服务器,如:http:/stc-hrye/tdbin/start_a.htm,2005 iSoftStone Information Service Corporation. All rights reserved.,6,测试设计在TD中录入测试用例,在“Test Plan”新建一个文件夹,用来存放测试脚本,2005 iSoftStone Information Service Corporation. All rights reserved.,7,测试设计在TD中录入测试用例,新建一个测试脚本,这个脚本是用来存放银行付款的标准业务功能的。下阶段的测试实现,主要就是实现这个脚本的内容。,2005 iSoftStone Information Service Corporation. All rights reserved.,8,测试设计在TD中录入测试用例,添加对脚本的描述说明文字。说明脚本实现的内容、目的,2005 iSoftStone Information Service Corporation. All rights reserved.,9,测试设计在TD中录入测试用例,录入所有的步骤。如果是业务功能的基础脚本,每一个step,就对应一个业务功能。如果该脚本是用来描述一个测试用例的,则一个step就是一个操作。,2005 iSoftStone Information Service Corporation. All rights reserved.,10,测试设计在TD中录入测试用例,Step录入完成后,自动生成QTP的测试脚本。如果不能生成,请检查是否安装了TDPlus,2005 iSoftStone Information Service Corporation. All rights reserved.,11,测试设计在TD中录入测试用例,生成的脚本中,只包含说明信息。,2005 iSoftStone Information Service Corporation. All rights reserved.,12,目录,测试设计测试实现测试执行,2005 iSoftStone Information Service Corporation. All rights reserved.,13,测试实现,测试实现,需要实现两部分的内容1 测试用例的实现 (testCase Action的实现)2 基础业务功能的实现(reusable Action的实现)其中,testCase Action只调用reusable Action,每个业务功能如何实现,都放在了resuable Action中。,2005 iSoftStone Information Service Corporation. All rights reserved.,14,测试实现实现testCase Action,1 使用QTP连接TD,2005 iSoftStone Information Service Corporation. All rights reserved.,15,测试实现实现testCase Action,2 输入TD服务器的信息,并连接。3 打开要编辑的基础业务功能的脚本。,2005 iSoftStone Information Service Corporation. All rights reserved.,16,测试实现实现testCase Action,2,2005 iSoftStone Information Service Corporation. All rights reserved.,17,测试实现实现testCase Action,4 按照脚本的说明信息,将基础的业务功能脚本分割成多个resuable的Action。注意:分割了的Action,不能再合并。,2005 iSoftStone Information Service Corporation. All rights reserved.,18,测试实现实现testCase Action,2005 iSoftStone Information Service Corporation. All rights reserved.,19,测试实现实现testCase Action,依次的,将所有的Action分割完成。,2005 iSoftStone Information Service Corporation. All rights reserved.,20,测试实现实现testCase Action,5 修改基础业务功能Action的属性,使其可重用。,2005 iSoftStone Information Service Corporation. All rights reserved.,21,测试实现实现testCase Action,6 修改Action的传入、传出参数。传入传出参数的数据类型建议只使用String型,且各只有1个。传入的参数,是将数组转成字符串传入的,需要经过解析后才能使用。,2005 iSoftStone Information Service Corporation. All rights reserved.,22,测试实现实现testCase Action,7 基础的业务功能的Action暂时就完成了。现在开始编写testCase的Action。打开测试用例的脚本payment01,2005 iSoftStone Information Service Corporation. All rights reserved.,23,测试实现实现testCase Action,8 切换到Expert View,调用“银行付款-新增”的Action,2005 iSoftStone Information Service Corporation. All rights reserved.,24,测试实现实现testCase Action,2005 iSoftStone Information Service Corporation. All rights reserved.,25,测试实现实现testCase Action,2005 iSoftStone Information Service Corporation. All rights reserved.,26,测试实现实现testCase Action,说明:insert call to copy 与 insert call to Exists假设要在ActionA中调用ActionB call 是获得ActionB的引用,只是引用,如果原本的ActionB的内容发生了变化,那么ActionA中的内容也跟着变化,且不能在ActionA中对ActionB修改。copy 是把ActionB的脚本复制到ActionA中,得到ActionB的一个copy,修改ActionB_copy不对ActionB造成影响,修改ActionB也不对ActionB_copy造成影响。有点像C语言中的传指针和传值的意思。另外,还可以去看编写的脚本,一个没有分割Action的脚本,默认会生成Action0和Action1两个Action,其中Action0中一般只有一句话:RunAction Action1,oneIteration当运行脚本时,实际上,只是运行了Action0,其他的Action都是被Action0调用的。copy过来的Action,如果没有使用RunAction的方法来调用,应该是不会被运行的,因为没有被Action0直接或间接调用。,2005 iSoftStone Information Service Corporation. All rights reserved.,27,测试实现实现testCase Action,9 确定要调用的新增的Action的传入参数根据页面的信息,新增银行付款业务时,需要输入以下数据:付款方客户编号 付款方账户号 开户行编号收款方账户编号收款方名称汇入行所在省汇入行所在市汇入行名称金额支票号报单号摘要,2005 iSoftStone Information Service Corporation. All rights reserved.,28,测试实现实现testCase Action,10 将传入参数和数据写入到一个Excel表格中,并保存同时,填写设计参数说明,将Action的名称和传入参数的字段记录存档。,2005 iSoftStone Information Service Corporation. All rights reserved.,29,测试实现实现testCase Action,11 将测试数据导入到脚本payment01的Action1中,2005 iSoftStone Information Service Corporation. All rights reserved.,30,测试实现实现testCase Action,12 将业务数据作为参数传入到“新增”的Action中从DataTable中读取所需要的数据,组成一个字符串。假设这个功能,我们把它写成一个方法,命名为getLocalDTData,我们在testCase Action中可以这样使用它:dataList=getLocalDTData(3,12)RunAction 新增 payment, oneIteration,dataList由于这个功能经常要使用,所以我们把它添加到库函数中去,2005 iSoftStone Information Service Corporation. All rights reserved.,31,测试实现实现testCase Action,另存到TD服务器上,2005 iSoftStone Information Service Corporation. All rights reserved.,32,测试实现实现testCase Action,点击 File Setting,打开设置页面,将脚本与库函数关联起来,2005 iSoftStone Information Service Corporation. All rights reserved.,33,测试实现实现testCase Action,在库函数文件中,实现getLocalDTData(rowNumber,columnCount)方法。具体的代码如下:Function getLocalDTData(rowNumber,columnCount)取出当前sheet的第rowNumber行的前columnCount列的所有数据,拼成一个字符串返回。如getBizData(1,8),表示取出当前Sheet的第1行的前8列数据。字符串之间使用空格作为分隔符。如果数据本身有使用空格,用两个下划线代替,如果数据本身是空,使用两个特殊符号代替。“”datatable.SetCurrentRow (rowNumber)Dim rowData()For i=0 to columnCount-1If isEmpty(dataTable.Value(i+1,dtLocalSheet) ThenExit forEnd IfDim temp_valuetemp_value=dataTable.Value(i+1,dtLocalSheet)ReDim preserve rowData(i)If instr(temp_value,)0 ThenrowData(i)=replace(temp_value, ,)elseif temp_value= ThenrowData(i)=elserowData(i)=temp_valueEnd IfNextgetLocalDTData=join(rowData)End Function,2005 iSoftStone Information Service Corporation. All rights reserved.,34,测试实现实现testCase Action,13 继续调用“复核”的Action,方法与之前的类似。不过复核时,需要把交易号传出来,有一个传出参数的问题。形成的脚本如下:dataList=getLocalDTData(3,12)RunAction 新增 payment, oneIteration,dataListRunAction “复核 payment, oneIteration,dataList,transNO这样一个简单的“制单-复核”的流程就完成了。当然,在这之前要调用“登陆”、“选择模块”、“选择币种”、“选择菜单”、“退出系统”的Action。完成后的脚本如下图:,2005 iSoftStone Information Service Corporation. All rights reserved.,35,测试实现实现testCase Action,2005 iSoftStone Information Service Corporation. All rights reserved.,36,测试实现实现testCase Action,传入参数与传出参数的使用:如果所调用的操作已定义了输入和/ 或输出参数,您还可以提供输入参数的值以及输出参数的存储位置,作为 RunAction 语句的参数。输入参数列在输出参数之前。对于输入参数,可以指定一个固定值,也可以指定另一个已定义的参数(数据表参数、环境参数或调用操作的操作输入参数)的名称,输入参数将采用该已定义参数的值。对于输出参数,可以指定一个用于存储值的变量,或者是一个已定义参数(数据表参数、环境参数或调用操作的操作输出参数)的名称。带有参数的操作调用使用以下语法:RunAction ActionName,=IterationQuantity,=Parameters例如,假设从 Action1 调用 Action2,并且 Action2 有一个已定义的输入参数和一个已定义的输出参数。 RunAction Action2, oneIteration, “MyValue” , MyVariable为输入参数提供 MyValue 的字符串值,并将输出参数生成的值存储在名为MyVariable 的变量中。 摘自QTP用户手册第308页,2005 iSoftStone Information Service Corporation. All rights reserved.,37,测试实现,测试实现,需要实现两部分的内容1 测试用例的实现 (testCase Action的实现)2 基础业务功能的实现(reusable Action的实现)其中,testCase Action只调用reusable Action,每个业务功能如何实现,都放在了resuable Action中。,2005 iSoftStone Information Service Corporation. All rights reserved.,38,测试实现实现基础业务功能的脚本,现在,开始实现“银行付款-新增”的功能。打开payment脚本,编辑“新增”的Action解析传入参数。因为传入参数是一个字符串,需要将其转换成数组。仍然是在函数库中添加一个方法,具体的脚本如下:Function stringToArray(bizDatas)与getBizData()方法相对,解析字符串成数组返回。myString=split(bizDatas, ,-1,1)For i=LBound(myString) to UBound(myString)temp_value=myString(i)If instr(temp_value,)0 ThenmyString(i)=replace(temp_value, )elseif temp_value= ThenmyString(i)=elsemyString(i)=temp_valueEnd IfNextstringToArray=myStringEnd Function,2005 iSoftStone Information Service Corporation. All rights reserved.,39,测试实现实现基础业务功能的脚本,解析传入参数bizData=stringToArray(dataList)那么bizData就是一个数组,为了查看方便,在注释中写明每个参数的含义:,2005 iSoftStone Information Service Corporation. All rights reserved.,40,测试实现实现基础业务功能的脚本,识别第一个放大镜客户编号的放大镜。对于放大镜,为了统一识别,采用以下两步操作来完成:1 点击放大镜的图标2 在弹出框中选择编号的链接第一步,识别放大镜的图标先用object Spy查看一下图标的属性。对于静态Web对象的识别,在自动化测试的实践-应用QTP测试框架的PPT中有一个常用属性的列表,可以参考。这里使用name属性来识别图片。页面上有4个放大镜的图标,所以仅仅靠name属性是不能唯一识别的,这里需要使用index属性来辅助识别。完成后的脚本就是这样的:Browser(“creationTime:=1”).Page(“index:=0”).Image(“name:=button”,”index:=0”).Click,2005 iSoftStone Information Service Corporation. All rights reserved.,41,测试实现实现基础业务功能的脚本,2005 iSoftStone Information Service Corporation. All rights reserved.,42,测试实现实现基础业务功能的脚本,第二步,在弹出窗口中点击客户编号的超链接脚本如下:Browser(creationTime:=2).Page(index:=0).Link(text:=&bizData(0).Click这句话的意思是:在第3个被打开的IE窗口中,点击一个超链接,超链接的内容是bizData(0)。bizData(0)就是解析出来的数组,第一个数据是客户编号。注意这里的特殊写法,因为bizData(0)是一个变量,连接字符串需要使用“&”。考虑到传入的参数可能为空,所以在这之前加一个判断:如果客户编号的值不为空,那么才点击客户编号的放大镜,否则不点击。脚本如下:If bizData(0) ThenBrowser(creationTime:=1).Page(index:=0).Image(name:=button,index:=0).ClickBrowser(creationTime:=2).Page(index:=0).Link(text:=&bizData(0).ClickEnd If,2005 iSoftStone Information Service Corporation. All rights reserved.,43,测试实现实现基础业务功能的脚本,依次的,写出付款账户编号,及开户行的脚本:,2005 iSoftStone Information Service Corporation. All rights reserved.,44,测试实现实现基础业务功能的脚本,然后是收款方外部账户的信息。采取每次都重新录入的原则,来输入收款方外部账户的信息。由于是输入框,就不需要判断是否为空了。脚本如下:,2005 iSoftStone Information Service Corporation. All rights reserved.,45,测试实现实现基础业务功能的脚本,接着,录入付款金额等信息,并点击“保存”按钮。注意保存按钮的文字的前后均有空格,描述这个button时,也要保留空格。,2005 iSoftStone Information Service Corporation. All rights reserved.,46,测试实现实现基础业务功能的脚本,关闭弹出对话框。注意:弹出对话框中的对象,属于windows对象,不是Web对象,因此其属性的识别也不一样。如弹出框的“确定”按钮,其类别就是WinButton, 而不是WebButton,识别的属性也改成text了。在这里,是假设了银行付款业务通过了所有的页面和后台的校验。如果要检查输入的数据是否能够通过程序校验,需要写一些脚本来实现。,2005 iSoftStone Information Service Corporation. All rights reserved.,47,测试实现实现基础业务功能的脚本,到此,一个简单的银行付款-新增的功能就完成了。最后再加上一句话:Reporter.ReportEvent micPass,银行付款-新增,完成“最终输出的报告就会显示“银行付款-新增”功能成功完成的字样。其中,micPass是表示事件的状态:0或micPass 表示该事件通过1或micFail 表示该事件失败2或micDone 表示该事件完成(注意,完成与通过的区别)3或micWarning 表示生成警告信息,2005 iSoftStone Information Service Corporation. All rights reserved.,48,测试实现实现基础业务功能的脚本,编写“银行付款-复核”的脚本银行付款-复核的页面分两个,一个是匹配复核信息,一个是复核页面。首先还是解析传入参数:现在开始要使用传出参数了。,2005 iSoftStone Information Service Corporation. All rights reserved.,49,测试实现实现基础业务功能的脚本,输入匹配信息,点击“匹配”按钮:,2005 iSoftStone Information Service Corporation. All rights reserved.,50,测试实现实现基础业务功能的脚本,由于匹配时,有时能完全匹配,有时又不能完全匹配。这里就需要增加一个判断。分析事件:如果匹配上的话,那么就直接显示单据信息,如果不能匹配的话,就要弹出提示框显示。而且如果是脚本的话,大多数时候是能匹配上的。因此,判断条件为,如果页面上存在交易编号的输入框,那么就认为匹配上了,如果有弹出框,且弹出框的内容为“无匹配信息”的话,那么就认为没有匹配上。具体的脚本如下:,2005 iSoftStone Information Service Corporation. All rights reserved.,51,测试实现实现基础业务功能的脚本,2005 iSoftStone Information Service Corporation. All rights reserved.,52,测试实现实现基础业务功能的脚本,这段脚本中有如下内容需要解释:If browser(creationTime:=1).Page(index:=0).WebEdit(name:=textfield2352).Exist Then这句话的意思是说,如果存在name属性为textfield2352的输入框(就是交易编号的输入框,开发人员在写jsp页面时,没有把这个输入框的名称改过来)的话,那么Exist: 指示 QuickTest 等待打开窗口或显示对象。Exist 语句返回一个布尔值,指示对象当前是否存在。如果使用.Exist(20),就表示等待20秒,不加入等待时间,取系统默认的等待时间。等待时间的设置在File-Setting菜单中。如下图。如果在无人值守的情况下,还需要使用场景恢复机制。这个需要另外的PPT说明。,2005 iSoftStone Information Service Corporation. All rights reserved.,53,测试实现实现基础业务功能的脚本,2005 iSoftStone Information Service Corporation. All rights reserved.,54,测试实现实现基础业务功能的脚本,parameter(outStr)=Browser(creationTime:=1).Page(index:=0).WebEdit(name:=textfield2352).GetROProperty(value)这句话的意思是说,把交易编号的值赋给本Action的传出参数outStr。.GetROProperty(“value”),取得对象在运行时的value的值,不是静态的。这个方法会经常用到。Para

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论