现在的位置: 首页 > 综合 > 正文

两种DP描述方法的比较

2013年08月25日 ⁄ 综合 ⁄ 共 1032字 ⁄ 字号 评论关闭


使用
DP

Descriptive Programming
)时,可以使用两种方法,一种是直接描述的办法,另外一种是使用
Description
对象来存储描述:

 

Method
1 – Using String Description

Browser("Browser").Page("Google").WebButton("type:=Submit",
_

       

"name:=Google Search", "html tag:=INPUT").Click

 

Method
2 – Using Object Description

Set oGoogleSearch = Descrition.Create

oGoogleSearch("type").Value =
"Submit"

oGoogleSearch("name").Value =
"Google Search"

oGoogleSearch("html tag").Value =
"INPUT"

Browser("Browser").Page("Google").WebButton(oGoogleSearch).Click

 

 

 

这里做了个对比:

String Description

Object Description

Uses less memory as strings are
used

(因为使用字符串描述,内存用得少些)

Requires more memory as objects
are created. Object creation is as such a overhead

(由于使用了对象,需占用较多内存)

Increases statement length in
case more than one property is to be used

(如果要描述多个属性,则语句长度会增加)

Increase lines of code due to
object creation overhead and property assignment

(增加的不是语句长度,而是代码行数)

 

Preferred when property value
have regular expression characters which needs to be treated literally

(如果属性描述中包含正则表达式,则采用这种方法更好)

 

参考:

http://knowledgeinbox.com/articles/qtp/descriptive-programming/dp-part-2-converting-or-based-scripts-to-dp/

 

抱歉!评论已关闭.