D+QTP实用操作手册.ppt_第1页
D+QTP实用操作手册.ppt_第2页
D+QTP实用操作手册.ppt_第3页
D+QTP实用操作手册.ppt_第4页
D+QTP实用操作手册.ppt_第5页
已阅读5页,还剩56页未读 继续免费阅读

下载本文档

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

文档简介

TD+QTP使用操作手册 银行付款实例讲解 * iSoftStone Information Service Corporation 目录 测试设计 测试实现 测试执行 2 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计设计测试用例 现在要针对银行付款业务设计一个测试用例,进行功能的覆盖 1 划分业务功能、画出业务流程图 1 新增 2复核 3 取消复核 4 修改 5 删除 3 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计设计测试用例 2 根据流程图,写出测试方案 银行付款有一个起始点,两个结束点,按照功能覆盖的思想,选择两 条路径即可。如果要考量到动作之间的关联性,路径就比较多了。 基于以往的经验,取消复核、二次复核比较容易出现问题,因此两条 路径分别为: 路径一:新增-复核-取消复核-修改-复核 路径二:新增-复核-取消复核-删除 3 确定业务功能 在流程图中,可以得出,本业务可以划分成以下业务功能: 新增、复核、取消复核、修改、删除 4 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计设计测试用例 4 确定业务数据 由于只要进行流程的覆盖,所以暂时可以把业务数据作的简单一点。 5 在TD中录入测试用例 访问TD服务器,如:http:/stc-hrye/tdbin/start_a.htm 5 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 在“Test Plan”新建一个文件夹,用来存放测试脚本 6 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 新建一个测试脚本,这个脚本是用来存放银行付款的标准业务功能的 。下阶段的测试实现,主要就是实现这个脚本的内容。 7 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 添加对脚本的描述说明文字。说明脚本实现的内容、目的 8 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 录入所有的步骤。如果是业务功能的基础脚本,每一个step,就对应 一个业务功能。如果该脚本是用来描述一个测试用例的,则一个step 就是一个操作。 9 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 Step录入完成后,自动生成QTP的测试脚本。如果不能生成,请检查 是否安装了TDPlus 10 2005 iSoftStone Information Service Corporation. All rights reserved. 测试设计在TD中录入测试用例 生成的脚本中,只包含说明信息。 11 2005 iSoftStone Information Service Corporation. All rights reserved. 目录 测试设计 测试实现 测试执行 12 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现 测试实现,需要实现两部分的内容 1 测试用例的实现 (testCase Action的实现) 2 基础业务功能的实现(reusable Action的实现) 其中,testCase Action只调用reusable Action,每个业务功能如何实 现,都放在了resuable Action中。 13 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 1 使用QTP连接TD 14 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 2 输入TD服务器的信息,并连接。 3 打开要编辑的基础业务功能的脚本。 15 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 16 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 4 按照脚本的说明信息,将基础的业务功能脚本分割成多个resuable 的Action。注意:分割了的Action,不能再合并。 17 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 18 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 依次的,将所有的Action分割完成。 19 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 5 修改基础业务功能Action的属性,使其可重用。 20 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 6 修改Action的传入、传出参数。 传入传出参数的数据类型建议只使用String型,且各只有1个。 传入的参数,是将数组转成字符串传入的,需要经过解析后才能使用 。 21 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 7 基础的业务功能的Action暂时就完成了。现在开始编写testCase的 Action。打开测试用例的脚本payment01 22 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 8 切换到Expert View,调用“银行付款-新增”的Action 23 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 24 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 25 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现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直接或间接调用。 26 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 9 确定要调用的新增的Action的传入参数 根据页面的信息,新增银行付款业务时,需要输入以下数据: 付款方客户编号 付款方账户号 开户行编号 收款方账户编号 收款方名称 汇入行所在省 汇入行所在市 汇入行名称 金额 支票号 报单号 摘要 27 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 10 将传入参数和数据写入到一个Excel表格中,并保存 同时,填写设计参数说明,将Action的名称和传入参数的字段记 录存档。 28 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 11 将测试数据导入到脚本payment01的Action1中 29 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 12 将业务数据作为参数传入到“新增”的Action中 从DataTable中读取所需要的数据,组成一个字符串。 假设这个功能,我们把它写成一个方法,命名为getLocalDTData, 我们在testCase Action中可以这样使用它: dataList=getLocalDTData(3,12) RunAction “新增 payment“, oneIteration,dataList 由于这个功能经常要使用,所以我们把它添加到库函数中去 30 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 另存到TD服务器上 31 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 点击 File Setting,打开设置页面,将脚本与库函数关联起来 32 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现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-1 If isEmpty(dataTable.Value(i+1,dtLocalSheet) Then Exit for End If Dim temp_value temp_value=dataTable.Value(i+1,dtLocalSheet) ReDim preserve rowData(i) If instr(temp_value,“)0 Then rowData(i)=replace(temp_value,“ “,“) elseif temp_value=“ Then rowData(i)=“ else rowData(i)=temp_value End If Next getLocalDTData=join(rowData) End Function 33 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 13 继续调用“复核”的Action,方法与之前的类似。不过复核时,需要 把交易号传出来,有一个传出参数的问题。形成的脚本如下: dataList=getLocalDTData(3,12) RunAction “新增 payment“, oneIteration,dataList RunAction “复核 payment“, oneIteration,dataList,transNO 这样一个简单的“制单-复核”的流程就完成了。 当然,在这之前要调用“登陆”、“选择模块”、“选择币种”、“选择菜单” 、“退出系统”的Action。 完成后的脚本如下图: 34 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 35 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现testCase Action 传入参数与传出参数的使用: 如果所调用的操作已定义了输入和/ 或输出参数,您还可以提供输入参数的值以 及输出参数的存储位置,作为 RunAction 语句的参数。输入参数列在输出参数 之前。 对于输入参数,可以指定一个固定值,也可以指定另一个已定义的参数(数据表 参数、环境参数或调用操作的操作输入参数)的名称,输入参数将采用该已定义 参数的值。 对于输出参数,可以指定一个用于存储值的变量,或者是一个已定义参数(数据 表参数、环境参数或调用操作的操作输出参数)的名称。 带有参数的操作调用使用以下语法: RunAction ActionName,=IterationQuantity,=Parameters 例如,假设从 Action1 调用 Action2,并且 Action2 有一个已定义的输入参数和 一个已定义的输出参数。 RunAction “Action2“, oneIteration, “MyValue” , MyVariable 为输入参数提供 MyValue 的字符串值,并将输出参数生成的值存储在名为 MyVariable 的变量中。 摘自QTP用户手册第308页 36 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现 测试实现,需要实现两部分的内容 1 测试用例的实现 (testCase Action的实现) 2 基础业务功能的实现(reusable Action的实现) 其中,testCase Action只调用reusable Action,每个业务功能如何实 现,都放在了resuable Action中。 37 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现基础业务功能的脚本 现在,开始实现“银行付款-新增”的功能。 打开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 Then myString(i)=replace(temp_value,“,“ “) elseif temp_value=“ Then myString(i)=“ else myString(i)=temp_value End If Next stringToArray=myString End Function 38 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现基础业务功能的脚本 解析传入参数 bizData=stringToArray(dataList) 那么bizData就是一个数组,为了查看方便,在注释中写明每个参数 的含义: 39 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现基础业务功能的脚本 识别第一个放大镜客户编号的放大镜。 对于放大镜,为了统一识别,采用以下两步操作来完成: 1 点击放大镜的图标 2 在弹出框中选择编号的链接 第一步,识别放大镜的图标 先用object Spy查看一下图标的属性。 对于静态Web对象的识别,在自动化测试的实践-应用QTP测试框 架的PPT中有一个常用属性的列表,可以参考。这里使用name属 性来识别图片。 页面上有4个放大镜的图标,所以仅仅靠name属性是不能唯一识别的 ,这里需要使用index属性来辅助识别。 完成后的脚本就是这样的: Browser(“creationTime:=1”).Page(“index:=0”).Image(“name:=button”,”in dex:=0”).Click 40 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现基础业务功能的脚本 41 2005 iSoftStone Information Service Corporation. All rights reserved. 测试实现实现基础业务功能的脚本 第二步,在弹出窗口中点击客户编号的超链接 脚本如下: Browser(“creationTime:=2“).Page(“index:=0“).Link(“text:=“&bizData(0).Click 这句话的意思是:在第3个被打开的IE窗口中,点击一个超链接,超链接的内 容是bizData(0)。bizData(0)就是解析出来的数组,

温馨提示

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

评论

0/150

提交评论