Forum Discussion

ZXQA's avatar
ZXQA
Occasional Contributor
10 months ago
Solved

Object Required error, please help!

Hello,

   I am trying to use a value that is stored in a Project level variable but I am getting am Object Required error. The error in TC showy the value but it is showing the value as incomplete. When I log the variable it logs out complete. The Project level variable is being set by another procedure which also logs the value as correct to the log.

 

I am identifying the current form displayed on the screen using FindChild and sending it to a Project variable. From another script I am setting a local variable to the value of the Project variable and then attempting to use it. When I do I get an error "Object Required:'[string: "Aliases.Signon.frmPS"]'. 

When I log the values for "Project.Variables.whereAmI" and "cFrm" they write to the log as expected: Aliases.Signon.frmPSInvoices. 

 

I don't know where I am going wrong!

 

My code: (error is coming from bold line)


Sub Suspend_Transaction_AnyUser()
Dim transType, cFrm
transType = "" ' initialize Transaction Type
cFrm = "" ' initialize Current Form visible on-screen

Call whereAmI 'Update value for Project.Variables.whereAmI
Log.Message(Project.Variables.whereAmI)
' Set current form value and log for troubleshooting
Set cFrm = Project.Variables.whereAmI
Log.Message(cFrm)

Call cFrm.StripMainMenu.Click("File|Suspend")
Call aqObject.CheckProperty(Aliases.Signon.frmSuspend, "WndCaption", cmpEqual, "Suspend Transaction")
' transType = Aliases.Signon.frmSuspend.txtFriendlyName.wText
Call Aliases.Signon.frmSuspend.radioSuspendToGlobal.ClickButton
Call aqObject.CheckProperty(Aliases.Signon.frmSuspend.radioSuspendToGlobal, "Checked", cmpEqual, True)
Call Aliases.Signon.frmSuspend.txtDescription.Keys("Suspended Automated test: " + KeywordTests.Suspend_Transaction.Variables.transactionType)
Call aqObject.CheckProperty(Aliases.Signon.frmSuspend.butProcess, "Enabled", cmpEqual, True)
End Sub

'-------------------------------------------------------------
'-------------------------------------------------------------

Sub whereAmI
' Use to identify current form displayed 
'---------------------------------------------------
' Define property array: pArray,Values array: vArray
' p: process, w: window
Dim pArray, vArray, p, w

pArray = Array("MappedName", "VisibleOnScreen")
vArray = Array("Aliases.Signon.frm*", True)

Set p = Sys.Process("Signon")
Set w = p.FindChild(pArray, vArray, 1)


If w.Exists Then
Log.Message w.FullName
Project.Variables.whereAmI = w.MappedName
Log.message(Project.Variables.whereAmI)
Else
Log.Error "The object was not found."
End If
End Sub

 

 

  • In case anyone sees this... I have this working now and I don't know why I didn't see it sooner.

    I forgot to set the Project variable to Object and then Eval() the w.MappedName so it was not a string.  You can only stare at code for so long before your brain turns to mush 🙂 I also fixed my logging.

     

    If anyone sees any other suggestions please let me have it!!

     

    Thank you and I hope this might help someone in the future.

1 Reply

  • ZXQA's avatar
    ZXQA
    Occasional Contributor

    In case anyone sees this... I have this working now and I don't know why I didn't see it sooner.

    I forgot to set the Project variable to Object and then Eval() the w.MappedName so it was not a string.  You can only stare at code for so long before your brain turns to mush 🙂 I also fixed my logging.

     

    If anyone sees any other suggestions please let me have it!!

     

    Thank you and I hope this might help someone in the future.