Forum Discussion

cam_farineau's avatar
cam_farineau
Contributor
8 years ago

ComboBox: How to know when you can click on the items of a ComboBox after you opened the DropDown

Hi,

 

I am using TestComplete 12 (Desktop Testing).

I want to click on ComboBoxItems inside a DropDown of a ComboBox.

I need to know when I can click on those items.

 

First step is to click on the ComboBox and open the DropDown. Now I want to click on the items inside the DropDown (items of the ComboBox). The easiest solution is to wait for the property "HasItems" of the ComboBox to be true.


But at this time of my program, "HasItems" is already true because I used this ComboBox previously (Items are already loaded). So I can't use this property to know when I can click on the items. 

 

I tried to wait for the property "IsDropDownOpen" to be true before clicking. However it seems this property is true before the DropDown is completely opened.

The result is: TC12 is too fast and doesn't find the item I am looking for because the DropDown is not completely opened.

 

Do you have any solution for this issue ?

I am just trying to wait for a property of the ComboBox to be sure when I can click on the items inside the DropDown (I can't use directly the ComboBoxItem that I am looking for).

 

Thanks for your help.

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Why aren't you using the "ClickItem" method on your combobox control? (https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/combobox/clickitem-action-combobox-control.html)

     

    Seems that this is a much cleaner way of selecting an item from a combobox than first clicking the drop down then clicking the item.  However, different components and different implementations of components may mean you need to use another method, but I'd suggest at least investigating this option as it should take care of both clicking the drop down AND clicking the individual item itself.

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      tristaanogre - "Why aren't you using the "ClickItem" method on your combobox control?"

       

      Might not support it. Not all do. I have some Delphi ones that I have to use other methods. (Data driven, with visible selections populated "as you scroll" from the underlying DB. They're a pain.)

       

      cam_farineau - "But at this time of my program, "HasItems" is already true because I used this ComboBox previously (Items are already loaded). So I can't use this property to know when I can click on the items."

       

      Is the ComboBox a mapped object? You may just need to refresh it before using it again. (Refresh it before you load the page, which should effectively "empty" the cached version.)

       

      https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html

      • cam_farineau's avatar
        cam_farineau
        Contributor

        Thanks for your answer.

         

        I did try the refresh but it was not working.

         

        I finally find a workaround for this problem (hard delay).