qtp文档

上一篇 / 下一篇  2015-05-07 09:29:48 / 个人分类:qtp


测试模型概念:QTP测试对象模型的两个概念:TO和RO 不管是RO还是TO都使用相同的类方法:如Broswser page webbuton 等等等
   对应的几个函数:
   TO:GetTOProperty()  GetROProperty() GetTOPropertys() SetTOPropertys()
   A、TestObject的用法:
      主要针对对象库的测试对象。
      Browser("页面1").Page("子页面1").Image("密码提交按钮").Click 其中的页面1、子页面1、密码提交按钮为自己定义的对象库的对象
      Dim TestResult2
      TestResult2=Browser("页面1").Page("子页面1").Image("密码提交按钮").GetTOProperty ("image type")
      Msgbox(TestResult2)

      Run-Time object的用法:
      Dim TestResult2
      TestResult2=Browser("name:=常用地址").Page("title:=常用地址").Image("file name:=index_91.gif").GetROProperty ("image type")
      Msgbox(TestResult2)

1、参数化:全局变量、环境变量、局部变量
   H2流程的例子
   全局变量设置路径:Test->TestSetting
   局部变量设置路径:ACTION->Parameters   登陆的例子
   全局变量就是整个工程都用的一样的属性参数,局部就是只单ACTION用其他ACTION函数不用

2、检查点实例类型:
   A、系统自带的检查点插入功能:
      Browser("常用地址").Page("常用地址").Image("index_91").Check CheckPoint("index_91")
      Browser("常用地址").Page("常用地址").Check CheckPoint("用户名")
   B、判断对话框提示、页面是否存在
      Dim TestRc
      If Browser("name:=常用地址").Dialog("text:=Microsoft Internet Explorer").WinButton("attached text:=请输入用户名!").Exist Then
      TestRc = 1
      else
      TestRc =0
      End If
      Msgbox(TestRc)
   C、判断是否一致
      Dim TestResult2,TestResult3
      TestResult2=Browser("页面1").Page("子页面1").Image("密码提交按钮").GetTOProperty ("image type")
      Msgbox(TestResult2)
      TestResult3="Plain Image"
      Msgbox(TestResult3)
      If   instr(TestResult2,TestResult3) Then                                                        
      Reporter.ReportEvent testr, "流程节点:问题单信息检查","测试成功"
      else
      Reporter.ReportEvent micPass1, "流程节点:问题单信息检查","测试失败"
      End If 
3、Action的使用
      A、拆分原则,重复利用,如何设置属性
      B、call to copy call to existing函数的使用  RunAction name "参数"

    
4、Recovery scenario(效率和适用性)
      A、录制脚本  注明使用范围 用函数封装起来便于维护      
      B、函数直接写 
      方法:
       '-----------------------------------------------------------------------------------------------------------------
       '函数ProblemCheck定义如下:
       '-----------------------------------------------------------------------------------------------------------------
         Function ProblemCheck()
         Dim TestResult2
         .......................
         ProblemCheck = TestResult2  
         End Function
5、虚拟对象:
       录制脚本常见的问题:1、下拉列表框盲点 2、默写特殊的图片按钮对象回放无效
       原因:1、对象类其实只需要操作一次  2、对象探测器识别不明确,JSP页面层太多
       解决办法:1、删除多余操作 2、使用虚拟对象
       语法:
             Browser("常用地址").Page("常用地址").VirtualButton("button").Click


6、Descriptive programming描述性编程
        如何自己判断对象有那些特征和方法(obj spy的使用)
   6.1  直接使用描述性语言操作:
       语法格式:Testobject("","")
       A、常用描述性编程的方法及对应的特征属性(即不通过对象库进行对象查找的方法操作对性)
          方法:Browser  常用特征:name
             page               title
             Image              file name
             Link               name
             Button             text
             Dialog             text
             WebElement         innertext等
             Table              name
      B、多特征综合查询模式尽量找到唯一控件如: 
         Browser("name:=外购件进厂审批流程").Page("title:=外购件进厂审批流程").WebElement("innertext:=30","html tag:=FONT","ID:=Eixt1").Click
      C、如果实在找不到:使用索引定位方法:
         location:=0
         Browser("name:=质量反馈信息录入").Page("title:=质量反馈信息录入").Link("name:=审批","location:=0").Click

  6.2 使用describe对象
      Set MyDescription = Description.Create()
      Set MyDescription =Description.Create()
      Set MyDescription2 =Description.Create()
      Set MyDescription3 =Description.Create()
      MyDescription("text").value= "确定"
      MyDescription2("text").value= "Microsoft Internet Explorer"
      MyDescription3("name").value= "常用地址"
      Browser( MyDescription3).Dialog(MyDescription2).WinButton(MyDescription).Click

7、自动化测试框架技术:共享对象库和共享函数库
  (将使测试脚本和测试用例的管理更加灵活,健壮,并且可实现高度重用)
   实现:
   A、脚本和对象库分离
   B、函数和用例脚本分离
   讲解目前QM的H2流程的实例
   
 


TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-11  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 2530
  • 日志数: 8
  • 建立时间: 2008-01-30
  • 更新时间: 2015-11-27

RSS订阅

Open Toolbar