The code below illustrates one way of enumerating the application objects while performing an operation on each object.
Function EnumerateApp(ParentObj, Desc, OperationMethod, PostOperationMethod, RestoreMethod)
' Retrieve a collection of all the objects of the given description
Set ObjCol = ParentObj.ChildObjects(Desc)
set CurrentObj = ObjCol.item(idx)
' Perform the desired operation on the object
eval("CurrentObj." & OperationMethod)
' Perform the post operations (after the object operation)
eval(PostOperationMethod & "(ParentObj, CurrentObj)")
' Return the application to the original state
eval(RestoreMethod & "(ParentObj, CurrentObj)")
' Retrieve the collection of objects
' (Since the application might have changed)
Set ObjCol = ParentObj.ChildObjects(Desc)
' ********************************** An Example of usage **********************
' Report all the pages referred to by the current page
' ***********************************************************************************
Function ReportPage(ParentObj, CurrentObj)
PageTitle = ParentObj.GetROProperty("title")
Reporter.ReportEvent 0, "Page Information", "page title " & PageTitle
Function BrowserBack(ParentObj, CurrentObj)
Reporter.Filter = 2 ' Enables Errors Only
' Create the description of the Link object
Set Desc = Description.Create()
Set BrowserObj = Browser("creationtime:=0")
Set PageObj = BrowserObj.Page("index:=0")
call EnumerateApp(PageObj, Desc, "Click", "ReportPage", "BrowserBack")
Reporter.Filter = OldFilter ' Returns the original filter
No comments:
Post a Comment