Forum Discussion

bmartens's avatar
bmartens
New Contributor
15 years ago

SWTObject support

Hello,



I'm trying to test an SWT Open application.  The tab control, which I am trying to use, has the following full name:



Sys.Process("Process").SWTObject("Shell", "Application").SWTObject("Composite", "", 5).SWTObject("Composite", "").SWTObject("CTabFolder", "", 6)



Inside this control are 4 tabs, which can be in any order.  There are several methods which are available, but I cannot find a method where I can specify the tab name or index, in order to click the tab.  Is there a way to do this for an SWTObject? (The WndClass is SWT_Window0.)



Thanks!



Brett

3 Replies

  • bmartens's avatar
    bmartens
    New Contributor
    Does anyone have any suggestions?  I'm using TestComplete 7.5.



    Thanks!



    Brett
  • Hello Brett,




    You can use native Java properties and methods of the CTabFolder control to accomplish your task. Here is an example demonstrating how to click a tab by its name:




    [JScript]




    function Test()

    {   

      var obj = Sys.Process("Process").SWTObject("Shell", "Application").SWTObject("Composite", "", 5).SWTObject("Composite", "").SWTObject("CTabFolder", "", 6);

      

      ClickTab(obj, "Tab 2");                   

    }




    function ClickTab(objCTabFolder, strTabName)

    {         

      count = objCTabFolder.getItemCount(); 




      for (var i = 0; i < count; i++)

      {

          TabItem = objCTabFolder.getItem(i);

          

          if (TabItem.text == strTabName)

          {         

            objCTabFolder.Click(TabItem.x, TabItem.y);

          }

      }     

    }