QTP自动化测试框架:第七章 主要方法介绍(描述性编程引入框架)

最后来看一下,对于CS架构的,只能以字符串方式描述

而对于BS的可以 直接set aa=browswer("ss").....形势,然后直接execute文件,对应的变量即可直接用

下面我们看一下基于CS的对象库。因为是纯字符串,写的时候需要注意,我这里也是加入字典,我觉得处理的不太好,如果有什么好的方法求介绍

'FunctionName: DespritionObject
'Description:  this Function provide a way to description an object if when cann't identify object normally,and this function priority is higher than shared repository object
'FunctionType:Global Function,referenced by [Utility Function file, BuildObject function]	
Dim ObjectDescriptionDictionary
Function DespritionObject(ObjectName)
         DespritiionObject="Not Found"
         DescriptObjectName=right(ObjectName,len(ObjectName)-4)
         
        TextCheckPoint="WpfWindow("+"""XPOS"""+").WpfObject("+"""name:=销售管理"""+","+"""ClassName:=System.Windows.Controls.Label"""+")"
                      ' wpfwindow("XPOS").WpfObject("name:=销售管理","Class Name:=WpfObject")
          
'         Object Description
'	     Set MyObjectA=Description.Create()
'	     MyObjectA("text").value="Login"  'set right property for the object value and return.
'	     MyObjectA("title").value="Test"
'	     '...
'	     ObjectA=Window(MyObjectA).WinButton(MyObjectA)
'	     ObjectB=Window(MyObjectB).WinButton(MyObjectB)
'	     '...
'	     
	     Set ObjectDescriptionDictionary=CreateObject("Scripting.Dictionary")
	         ObjectDescriptionDictionary.Add TextCheckPoint,ObjectA
              ObjectDescriptionDictionary.Add "销售管理",TextCheckPoint
              '...
        If ObjectDescriptionDictionary.Item(DescriptObjectName) <> "" Then
           DespritionObject=ObjectDescriptionDictionary.Item(DescriptObjectName)
        End If
        Set MyObjectA=nothing
        Set MyObjectB=nothing
        Set ObjectDescriptionDictionary=nothing
End Function

猜你喜欢

转载自543827357.iteye.com/blog/2043320