Forum Discussion

ilija_panov's avatar
ilija_panov
Contributor
14 years ago

Script for ClickButton method regardless of the button parent object ?

Hi to All,



I'm pretty new in using TC, but here is my question. I have a usual desktop Visual C++ 10.0 application with MFC classes featuring the main window with a main menu, and a structure  of interlinked nested windows being opened by the main menus and from link buttons on the windows themselfs (there is no limit in number of windows opened at the same time).



All of these windows also provide a button control called BtnClose for closing that window. What I need is a script which will call the ClickButton event on all visible Close buttons regardless of their parrent object. In other words if more windows are opened at the same moment it should call the ClickButton method for all Close buttons belonging to different window objects visible on the screen.



I tried to create this through a KeyWord test pressing a Close button on a randow window and then trying to mask the mapping in order to work with every other window (by removing mapping criteria from the parent and making the mapping  for the Close button to apply for every button on the screen).



This method does not work because the btnClose object must be always related to it's parent in the name mapping. I'm looking forward to your suggestions,  the other option would be to click the close button at the end of the test for involving every window but using a single script for closing windows regardless of their id would be much better. Thanks in advance.



Best Regards,

    Ilija

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I would suggest looking into the "FindAllChildren" method.  Call that method from you application level and have it look for all buttons with particular captions, etc.   You can then use a "for" loop to loop through the resulting array and call "ClickButton" for each item in the array.



    See http://smartbear.com/support/viewarticle/12741/
  • Thanks a lot, I will definitely try the FindAllChild method if writing a script solution for the Close Window issue I described. For now I managed to handle the situation by using TC 'Unexpected Window' feature and it's Press Enter, Press Esc methods with some tweaking in the tests. This allows me to run them without worrying about closing windows from previous tests, but on the long run I might get a lot of windows opened at the same time