两种DP描述方法的比较

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--> 使用 DPDescriptive 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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值