<!-- [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]--> 使用 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 (如果属性描述中包含正则表达式,则采用这种方法更好) |