Forum Discussion

narender_1's avatar
narender_1
Contributor
13 years ago

Problem while executing the recorded script

Hi,

 I am facing problem to execute the following code:

  Set CIMDocPanel =  javaw.Device_Name.RootPane.null_layeredPane.CIMDocPanel

The "Device_Name" is the name of the device which will be created in earlier step. The above statement is a recorded by testComplete.



 When it is executing the above statement it is showing the following error:

Unable to find the object Device_Name.



Can I use a variable in place of "Device_Name" whose value will be taken from the configuration file?



Thanks,

Narender

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You can use a variable, but you need to make sure that you use it in a way that recognizes it as a variable.  Most likely, the variable is a string so you would have to use a WaitChild method or Eval method to utilize that string to return an object.
  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello,

    Yes, you can read the device name from a variable and then obtain the corresponding object through the WaitChild or Eval method.

    Robert is absolutely correct. As always :)

    The code would look like this:



    ...

    Set Device_Name_Object =   javaw.WaitChild(Project.Variables.DeviceNameStr , 0)

    If Not Device_Name_Object .Exists Then

      Log.Error("Device object not found.")

    End If

    ...



    Happy automation.