Forum Discussion

amithsm's avatar
amithsm
Occasional Contributor
14 years ago

Unable to assign java object using Set

Hi,

I am unable to assign a java object using Set. Testcomplete errors out when the line is executed. Below is the code snippet.

The line "Set tab = guiObject.getItem(ii)" fails however the statement "sTabName = guiObject.getItem(ii).getToolTipText" works fine.

The java object is of type CToolbar




For ii=0 To nTabs-1


ii=0 nTabs-1

Set tab = guiObject.getItem(ii)


Next


For ii=0 To nTabs-1


If ((sTabName = guiObject.getItem(ii).getToolTipText)) Then....



5 Replies

  • Hello Amith,


    Which error do you get in TestComplete? What is the exact value of the toolbar control's JavaFullClassName property?

  • amithsm's avatar
    amithsm
    Occasional Contributor
    Hi Jay,



    The error in TC is "This child element is not available" However this is not true 'cos the statement "sTabName = guiObject.getItem(ii).getToolTipText" works fine. If I execute the just the  statment "guiObject.getItem(ii)" with no LHS assignment then TC proceeds with no errors.

    For the second question the object is an indigo UI toolbar widget enhanced for our internal needs.


  • Hello Amith,


    The Set statement works fine for me with the SWT ToolBar widget. Try running the following code (with or without Set) and paste here its output:



    For ii=0 To nTabs-1

     

      Set tab = guiObject.getItem(ii)

      Log.Message tab.JavaFullClassName

      Log.Message tab.getToolTipText 

         

    Next

  • amithsm's avatar
    amithsm
    Occasional Contributor
    The code snippet you suggested worked fine on application which used SWT widget toolbar but not for application which is using indigo UI widget which is customized.

    This control extends org.eclipse.swt.widgets.Canvas and I am not able to get this control assinged to my local variable in test complete
  • Hello Amith,


    Do you mean that the getItem method was implemented by your developers? If so, you should refer to its declaration to check what type of value it returns. The SWT ToolBar widget's getItem method returns a ToolItem object that can be operated fine in a test script.