Forum Discussion

SSI's avatar
SSI
Occasional Contributor
13 years ago

Passing an On Screen Object to a Script or Keyword test routine

Hello

   We have several windows that have a combo on them and they are loaded the same way.  i would like to create a routine  that i send in the window, and the combo box , and how to get to the window and do checkpoints on them.  but when calling this routine  TC waits for the window name  because it is in the parameter list.  



is there anyway to get around this?



Thanks

2 Replies

  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Like many (all?) other languages, VBScript has a way of passing objects by reference, ByRef.



    Sub Main

        DoSomethingWithObject GetObject("SomeName")

    End Sub



    Function GetObject(ByRef objParent, strObjectName)

        Set GetObject = objParent.WaitVBObject(strObjectName)

    End Function



    Sub DoSomethingWithObject(ByRef objReference)

        ' Do whatever you like with the object here...

    End Sub
  • You can only use object variables with much reliability when the object you are trying to assign exists onscreen.



    For a parameterized routine like you are considering, it is helpful to think of the problem as not how to pass in the object, but how to pass in how to find the object.



    For the simple case of using Aliases, if you pass the alias in as a String, when the combo box is on screen you can then:

    a) use a series of WaitAliasChild calls to get the object

    b) use "Eval" to blindly execute the alias to get the object

    c) use a Find with the alias name and the MappedName property (this is slow)