salley
8 years agoFrequent Contributor
Return a page object using vbscript function and use it from another func
Hi , i'm trying to create a generic function, that will return an object then call that function to do specific task. my script is executing successfully when the object exists, but giving me run tim...
- 8 years ago
Hi,
Observed behavior is correct and expected one.
When object is not found, the value returned by MyObj() is not an object. Thus it obviously does not contain the .SetText() method.
Suggested code modification:
Function PoScreen Set sPage=Aliases.browser.MainPage 'Selects Company strEffDteProp=Array("ObjectIdentifier","ObjectType") strEffDtePropVal=Array("DisplayEffectiveDate","Textbox") Set objEffDte=MyObj (sPage,strEffDteProp,strEffDtePropVal) If (objEffDte.Exists) Then objEffDte.SetText"11/01/2017" Else ... ' process appropriately End If End Function '@@@@@@@@@@@@@@ Function MyObj(sPage,arrProp,arrVal) ' Set obj=sPage.FindChild(arrProp,arrVal,50) ' If (obj.Exists) Then ' Set MyObj=obj ' Else ' Log.Message"Obj Not Found" ' End If Set MyObj=sPage.FindChild(arrProp,arrVal,50) If (Not MyObj.Exists) Then Log.Message"Obj Not Found" End If End Function