English 中文(简体)
QTP - Descriptive Programming
  • 时间:2024-03-22 11:38:05

QTP - Descriptive Programming


Previous Page Next Page  

只有在物体位于保留地时,方言书方可执行。 物体的描述是用描述性节目制作的。

    当测试者希望对目标存放处没有的物体进行操作时

    申请中物体在性质上非常活跃时。

    当目标保存机构大增时,由于目标保存机构的规模增加,结果表现不佳。

    当框架建立时,决定根本不使用保留地。

    当测试者想要在不了解物体的独特特性的情况下在运行时间就申请采取行动时。

Syntax

采用描述性方案编制技术进行描述有两种方法。 他们:

    Description Objects

    Description Strings

Description Objects

标本是依据所用特性及其相应价值开发的。 然后,这些描述被用来打造文字。

 Creating a description object
Set btncalc = Description.Create()

 Add descriptions and properties
btncalc("type").value = "Button"
btncalc("name").value = "calculate"
btncalc("html tag").value = "INPUT"

  Use the same to script it
Browser("Math Calc").Page("Num Calculator").WebButton(btncalc).Cpck

Description Strings

对这些物体的描述是以下文所示特性和价值为示例的。

Browser("Math Calc").Page("Num Calculator").WebButton("html 
tag:=INPUT","type:=Button","name:=calculate").Cpck

Child Objects

QTP提供了“儿童目标”方法,使我们能够建立一套物品。 母体物体在“儿童目标”之前。

Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

 Find all the Links
Set obj = Browser("Math Calc").Page("Math Calc").ChildObjects(oDesc)

Dim i
 obj.Count value has the number of pnks in the page

For i = 0 to obj.Count - 1	 
    get the name of all the pnks in the page			
   x = obj(i).GetROProperty("innerhtml") 
   print x 
Next

Ordinal Identifiers

描述性方案用于根据矿石识别特征撰写描述,使QTP能够在两个或两个以上物体具有相同特性时对这些物体采取行动。

  Using Location
Dim Obj
Set Obj = Browser("title:=.*google.*").Page("micclass:=Page")
Obj.WebEdit("name:=Test","location:=0").Set "ABC"
Obj.WebEdit("name:=Test","location:=1").Set "123"
 
  Index
Obj.WebEdit("name:=Test","index:=0").Set "1123"
Obj.WebEdit("name:=Test","index:=1").Set "2222"
 
  Creation Time
Browser("creationtime:=0").Sync
Browser("creationtime:=1").Sync
Browser("creationtime:=2").Sync
Advertisements