Forum Discussion

Aurelien's avatar
Aurelien
Contributor
15 years ago

WaitWinFormsObject: doesn't find object

Hi,



I think I am doing something wrong in my VBScript code because TC can't find object:



NameMapping.Sys.Metrino.PlatformSettings.WaitWinFormsObject "PlatformSettings", 60000



The Name property is "WinFormsObject("PlatformSettings")" but this syntax doesn't work too (so the other 20 ones I tried too).



I believe it's a problem of syntax, so could somebody help me with this please ?



Thank you!



Aurélien

6 Replies

  • Hi,



    WaitWinForms object accepts the native name of your object (the value from the name in the object tree - WinFormsObject("native name is here")). So, let's assume that you need to obtain an object named 'Sys.Process("app").WinFormsObject("form")'. In this case, your code will look like this:

    ...

    Set obj = Sys.Process("app").WaitWinFormsObject("form", 10000)



    If obj.Exists Then

    ' object was found

    End If

    ...




    In your case, it looks like you actually need to obtain the 'NameMapping.Sys.Metrino_Kernos_ControlPanels_PlatformSettings.PlatformSettings' object (the name you pass to WaitWinFormsObject coincides with this name in Name Mapping).



    You need to use the WaitNamedChild method to do this:

    ...

    Set obj = NameMapping.Sys.Metrino_Kernos_ControlPanels_PlatformSettings.WaitNamedChild("PlatformSettings", 10000)



    If obj.Exists Then

    ' object was found

    End If

    ...




    See the "Waiting for a Process or Window Activation" help topic to understand how Wait methods work.
  • Hi,



    What happens when "TC can't find object"? Do you see any errors in the log? If you do, what text does their 'Additional information' section contains? By using this information, you can check what object caused problems and troubleshoot them.



    Also, can you post here the exact code which obtains the target object, not just the WaitWinFormsObject call?
  • Hi Jared,



    I am newbie so I will try to answer the best:



    There was no error in my TC (the code just wait then continue). I am using WaitWinFormsObject to wait until the object existed before to continue the code. I know the object exist since I can see it but my syntax must be wrong since TC doesn't see it.



    I am sorry if I don't answer all your questions correctly but I am not sure to understand what you need (target object?): 



    "Also, can you post here the exact code which obtains the target object, not just the WaitWinFormsObject call?"





    My code that I reduced to simple expression:





    Option Explicit







    Function TB_Click_PlatformSettings_In_Tools












    Dim ListViewTools, ItemCount, x, intImageIndex, WinPlatformSettings, toto







           log.message NameMapping.Sys.Metrino_Kernos_ControlPanels_PlatformSettings.PlatformSettings.WaitWinFormsObject("PlatformSettings", 1000).exists


     


      


    End Function







    The result value is "False".



    Since the exact name is  "WinFormsObject("PlatformSettings")" I believe I should write:



    log.message NameMapping.Sys.Metrino_Kernos_ControlPanels_PlatformSettings.PlatformSettings.WaitWinFormsObject("WinFormsObject("PlatformSettings")", 1000).exists



    But then I got an error syntax and I am not able to run unit.



    I tried wildcard like this WaitWinFormsObject("*(PlatformSettings)*", 1000).exists

    But doesn't work too.



    Thanks you for your support.
  • Ok, I figured out that WaitWinFormsObject("*(PlatformSettings)*", 1000).exists cannot work.



    I tried log.message NameMapping.Sys.Metrino_Kernos_ControlPanels_PlatformSettings.PlatformSettings.WaitWinFormsObject("*", 1000).exists



    And it works. But I suppose this is not the correct way to use it?



    Thanks.
  • Thanks Jared,



    I understand where was my mistake now.



    Regards.
  • DurgaPrasad's avatar
    DurgaPrasad
    Occasional Contributor
    Hi Jared,

     The solution given by you doesn't worked for me.as  i am facing same problem.so please provide another solution.Thanks in advance.





    Thank you

    Durga.