AscentialTest Support Hub

Helper Function to …

 

Notifications

Clear all

Helper Function to Accompany $ Operator



1

Posts


1

Users


0

Reactions


39 K

Views

(@andreawaldorf)
Active Member

Joined: 12 years ago
Posts: 2

Topic starter
 

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.
// 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



   

Quote

Share:

Can’t Find An Answer in the Forum?

Contact Our Team