Helper Function to Accompany $ Operator

Tips and Techniques

Moderators: ZeenyxSupport, blesuer

Post Reply
andreawaldorf
Posts: 2
Joined: Thu Oct 18, 2012 10:35 am

Helper Function to Accompany $ Operator

Post by andreawaldorf »

I found that the '$' operator only works for one level (up to a period). In order to get around this, I have written my own function to evaluate a complex string made up of x levels of objects.
I don’t know if this is something that others can use but I find it very useful when writing reusable automated steps.

I’m sure there are several ways to write it but here is one way that I thought of.

Code: Select all

// takes a string containing a multi-level object, such as "MyPage.MyFrame.SomeButton" and returns an AppObject 
// that refers to the actual object
AppObject GetActualObject(String sObject)
        [ ] List<String> lsObjHierarchy = sObject.Split(".")
        [ ] AppObject aObject
        [ ] AppObject wWindow
        [ ] Integer iIndex = 1
        [ ] String sCurObjPart
        [ ] 
        [ ] sCurObjPart = lsObjHierarchy[1]
        [ ] wWindow = $(sCurObjPart)  // starts with the topmost parent object
        [+] for (Integer iCount = 2 ;iCount <= lsObjHierarchy.Count(); iCount++)
                [ ] sCurObjPart =  lsObjHierarchy[iCount]
                [ ] wWindow = wWindow.$(sCurObjPart)
        [] return wWindow
Post Reply