Forum Discussion

rushikesh's avatar
rushikesh
Contributor
8 years ago

Problem when checking drop down options of a Combo-box

In tested application there is combo-box option.Inside this combo-box there are 21 drop down options. I want to check if number of options present are 21.
Below is code I am using.

 

var list = ToolSelectFilter.ComboBox_ToolType;
Log.Message("No of tools are " +list.wItemCount);

 

Problem I am facing is that when code is executed Test Complete drop downs the list of combo-box 21 times to check all the options. This happens so fast (almost within 5 seconds) that my tested application crashes.
Is there another way to do this ?
Or
Is there a way to slow down execution of this code ?

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    rushikesh wrote:

    In tested application there is combo-box option.Inside this combo-box there are 21 drop down options. I want to check if number of options present are 21.
    Below is code I am using.

     

    var list = ToolSelectFilter.ComboBox_ToolType;
    Log.Message("No of tools are " +list.wItemCount);

     

    Problem I am facing is that when code is executed Test Complete drop downs the list of combo-box 21 times to check all the options. This happens so fast (almost within 5 seconds) that my tested application crashes.
    Is there another way to do this ?
    Or
    Is there a way to slow down execution of this code ?


    wItemCount is a property that TestComplete puts as a wrapper around the combobox control.  It gets this information from native properties on the object.  I don't know for certain, but it is possible that TestComplete's interaction with your particular control is firing off some sort of event that your developers have put on the control so that, if that property is accessed, the drop down activates.

    Investigate the properties of the component and see if the same value is in a different property that is not going through TestComplete's wrapper and see if the same problem occurs.

    Also, if you have access to your development team, find out if there are any events that are triggered for code that enumerates the number of items in a drop down list.

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      tristaanogre has a point.

       

      There could be custom event triggers in there. It may be a modified version of the base control. All sorts. Only the development team can tell you if it's modified in some way.

       

      But, as tristaanogre says you can attempt to use other properties. You may/should find an array or list of all the options on there. Many/most drop down box type controls have this (but not all - I have one SQL driven one that loads on demand). It may be in an underlying recordset object or something. If you can get the list, you can check the length of it (array length, split a comma separated list, whatever). Which may be an option if  getting such a property doesn't trigger the dropdown.

       

      The only other way you can be activating it 21 times is if you're in some sort of loop that we don't know about. Otherwise, TC activating an event trigger somehow sounds like the only real possibility ...

  • var count =0;

    var res= new Array("One","Two",Three")

    var list = ToolSelectFilter.ComboBox_ToolType;

    var TC = list.wItemCount;

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

    {

    var dropname = list.wItems(i)

     

    for (var j =0;j <res.length;j++)

    {

     

    if (dropname  == res[j])

    {

    Count +=1;

    }

     

    }

    }

    if (Count == TC -1)

    {

    pass// all values present

    }

    else

    {

    fail //all values not present

    }

     

     

    Regards,

    Karthick Raj P

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      How you get the full item count depends entirely what type of dropdown/combo box it is. They are not all the same, and you don't interpret them all the same.

       

      What language is the application, and what is the class of the combo/dropdown in question?

       

      Also, I don't get why it drops 21 times going by that two line code snippet. All you are doing in that is assigning the control to an object variable, and then posting one of it's properties to the log. Right?

       

      Nothing there looks it should actually be triggering the control. Is that code inside a loop or something? Looks like something else is happening, but impossible to say without seeing the rest of the code those two lines reside in.

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        The code from karthick7 is not really what you're after.

         

        It doesn't explain the constant re-activation of the control. It does what you currently do (assign it and extract a property) but then uses that to go through an array and try and match the array content against the dropdown content. It doesn't account for duplicate entries on either side very well (which may or may not be allowed). It also assumes that the basic dropdown methods and properties will all work on all controls similar to this, which they won't. Some dropdowns can't be handled this way.