Forum Discussion

jarnold615's avatar
jarnold615
Occasional Contributor
13 years ago

Need to use wildcard in VCLObject for object identification

Hello - I'm using VBScrip to try to set the object identification for a window which has a variable full name like this:




Sys.Process("tcs").VCLObject("frmSKEDWorksheet")


.Process("tcs").VCLObject("frmSKEDWorksheet")

Sys.Process("tcs").VCLObject("frmSKEDWorksheet_1")


.Process("tcs").VCLObject("frmSKEDWorksheet_1")

Sys.Process("tcs").VCLObject("frmSKEDWorksheet_2")



I tried using the following code with a wildcard character inserted so that it could identify all the object names listed above:



Set OSWWin = Sys.Process("tcs").VCLObject("frmSKEDWorksheet*")



It doesn't seem to work though.  There's no error, but the window isn't recognized.  Do you have any suggestions?



John


.Process("tcs").VCLObject("frmSKEDWorksheet_2") I tried using the following code with a wildcard character inserted so that it could identify all the object names listed above:Set OSWWin = Sys.Process("tcs").VCLObject("frmSKEDWorksheet*") It doesn't seem to work though.  There's no error, but the window isn't recognized.  Do you have any suggestions?John

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    If there's no error, what indications are you getting that it's not being recognized?  Could you clarify what's going on?
  • jarnold615's avatar
    jarnold615
    Occasional Contributor
    Normally, it's able to populate fields in the window with parameters that I've provided, such as setting a date field, etc.  However, that's not happening in this case.  The window appears but no changes are made to the controls in the window.  TestComplete will pause because it's not able to locate the controls in the window.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What code are you using to do the data population?  Are you certain that code is still valid (properties still available, etc)? I find it hard to believe that, upon attempting to interact with the control, that there's nothing in your log file that indicates a problem.  
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    John,


    You are using the * wildcard to replace the variable part of the name. The name becomes a kind of a search pattern that TestComplete uses to find the appropriate object. I suspect that in your case, the tested application contains several objects, whose names match the pattern you are using. In this case, TestComplete uses the first found object. If it differs from the needed object, you have an impression that the object is not found.


    If so, I'd suggest that you identify the needed object by its properties, for instance, by title, coordinates, id, the number of child objects, and so on.


    You can call the FindChild method of your test process to find the object by its property values.


    Alternatively, you can map the object's name to an alias and address the object in tests by the alias (see Name Mapping). The mapping criteria may include object properties or properties of its child objects.

  • jarnold615's avatar
    jarnold615
    Occasional Contributor
    Thanks!  That suggestion about using the Find method to look for object properties instead did solve my problem.



    John