Forum Discussion

lbyrne's avatar
lbyrne
Contributor
10 years ago

button bars

The following code was recorded using Test Complete.

 

Set toolkitButtonBar = splitContainer.WinFormsObject("SplitterPanel", "", 1).bbarBroker
Call toolkitButtonBar.Click(36, 50)

 

A button called Financials is clicked on the toolkitButtonBar.

 

Instead of giving the (x,y), I would like to reference the button either by name or index and do the click operation in vbscript.

 

Thanks for your help

 

 

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor

    Hi

     

    You should be able to obtain the index for the button you need to click from the properties.  Once you have this, you should be able to call either a Click() or a ClickButton() method without specifying coordinates.

     

    Regards

    Stephen.

  • I see the property Index is available for the toolkitButtonBar but I dont know how to use it

     

    Set toolkitButtonBar = splitContainer.WinFormsObject("SplitterPanel", "", 1).bbarBroker

     

    When I tried the following codeit returns the label on the button -- Properties

    Set text = toolkitButtonBar.Items.Item_2(0).get_Text

     

    When the following code executes it returns the label on the second button -- Financials

    Set text = toolkitButtonBar.Items.Item_2(1).get_Text

     

    But I cannot seem to find the Click method.

     

     

    • Marsha_R's avatar
      Marsha_R
      Icon for Champion Level 3 rankChampion Level 3

      What happens if you try

       

      Call toolkitButtonBar.Items.Item_2(0).Click

      • lbyrne's avatar
        lbyrne
        Contributor

        <script>// function writeContent(){ document.getElementById("container").innerText = document.getElementById("dataIsland").innerHTML; }window.onload = writeContent; // </script>

        I get the following error

        Object doesn't support this property or method: 'toolkitButtonBar.Items.Item_2(...).Click' Error location: Unit: "HSPAdminTK\Codes Management\Script\Tasks" Line: 202 Column: 1.

        Object doesn't support this property or method: 'toolkitButtonBar.Items.Item_2(...).Click'
         
        I cannot figure out how to identify that button 
         
        As soon as I correctly identify the button, the Click method should be available