Forum Discussion

fujunxu's avatar
fujunxu
Contributor
11 years ago

How to trigger click on ToolStrip label control ?

I have a .Net application and I try to use testcomplete to simulate the click on a ToolStrip label.  I followed the procedure "Recongnizing Custom Control".  But when I trie to "add from screen" I always get "The select object doesn't match the criteria of the "Microsoft Controls|winForms|Strip ToolBar" group. 

Have I miss something ?



Thanks a lot!

  • Hi Aaron,


     


    TestComplete already contains the System.Windows.Forms.ToolStripLabel control under the Strip Toolbar | ToolStripLabel group. Is this the control that you are testing? If it is, there is no need to add this control one more time to the list of Object Mapping.


     

  • Found the issue.  My process Filter was set to "Use only Tested application" ( I copy it from another projects).  After I add my application to TestedApps. I can see it now. 
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Aaron,


     


    TestComplete already contains the System.Windows.Forms.ToolStripLabel control under the Strip Toolbar | ToolStripLabel group. Is this the control that you are testing? If it is, there is no need to add this control one more time to the list of Object Mapping.


     

  • Hi Tanya,



    Yes. I was trying to use testcomplete to test ToolStripLablel, ToolStrip I did checked "System.Windows.Forms.ToolStripLabel" under Objet mapping.  But under "Object Browser" the WndClass shows as "WindowsForms10.Window.8.app.0.2bf8098_r13_ad1".  And it looks like TC only recognize the whole ToolStrip as one Object(without knowing it is ToolStrip) it can't tell there is a ToolStrip label on the ToolStrip on my application. 



    Thanks,



    Aaron



  • I encountered a similar problem (I think). Test complete (in object spy hunter mode) detects my toolstrip. However it will not find the buttons on the toolstrip by name/ID and add them to the namemapping



    When I use Inspect from microsoft it can detect the buttons on the toolstrip. The field AutomationID shows value "Not supported" as wel as the Poperty "ClassName" (ClrCLassName in TestComplete)



    TestComplete knows there ar items on the tools strip, because the Toolstrip.Items > 0



    The way to select an item on the toolstrip can be done using

    Toolstrip.Items.get_Item(id) (Note that this is . Net's reflection method for the getter) 

    this blog post: http://www.programmershare.com/3701518/ explens hoe to select an item by name.



    In JScript this will be (since I use JScript in TestComplete):




    function ToolStrip_ClickItem (ToolStrip, Name) {


        for(i=0;i<ToolStrip.Items.Count;i++)  {


            var item = ToolStrip.Items.get_Item(i);


            if(ToolStrip.Items.get_Item(i).Text = Name) {


                ToolStrip.Items.get_Item(i).PerformClick();


                break;


            } 


        }


    }