Forum Discussion

Janis's avatar
Janis
Occasional Contributor
8 years ago
Solved

iOS dropdown menu

hi all!

 

There is a dropdown menu in our application. It contains 27 menu items, but only 5 are visible on the screen simultaneously. Is it possible to have all items to select any of them without swiping on the screen?

 

thanks!

  • Janis you can use ScrollToItem method instead of swiping. E.g. you have a menu item "Item_10" which is in the TableViewCell(0, 10). Use:

     

    TableView.ScrollToItem(0, 10)

    You can make a function to scroll through all items while searching for required element. Something like this:

     

    function selectFromDropdown(item) {
    
        index = 0;
        while (! item.Visible) {
    
            TableView.ScrollToItem(0, index);
            index ++;
            }
        item.Touch();
        }

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    When a human user interacts with UI element, some code-behind of this element is executed in the response to the user's action.

    So, in order to trigger some action of the UI element without direct interaction with this UI element, two conditions must be met:

    1) The UI element must exist; and

    2) Your test code must have programmatic access to the code of this UI element which (code) is executed when the given action is performed by human.

     

    So, what you need should be possible to do in general, but you should check that both mentioned conditions are met. You can do this by either investigating the given UI element in the TestComplete Object Browser or talk to developers to know what method you need to call and, again, check in the Object Browser (Methods pane) that this method is accessible to TestComplete.

     

    P.S. TestComplete provides the Swipe method, so you may consider it as well.

  • baxatob's avatar
    baxatob
    Community Hero

    Can you explain how your menu looks in the TC Object Browser?

    • Janis's avatar
      Janis
      Occasional Contributor

      baxatob

       

      Mobile.Device("Ipad2").Process("app13632").Window(0).TableView(4).ScrollView(0).TableViewCell(0, 0).Label("Item1")

       

      Each menu item is wrapped in TableViewCell. All TableViewCell elements have different indexies.

       

       

      • baxatob's avatar
        baxatob
        Community Hero

        Janis you can use ScrollToItem method instead of swiping. E.g. you have a menu item "Item_10" which is in the TableViewCell(0, 10). Use:

         

        TableView.ScrollToItem(0, 10)

        You can make a function to scroll through all items while searching for required element. Something like this:

         

        function selectFromDropdown(item) {
        
            index = 0;
            while (! item.Visible) {
        
                TableView.ScrollToItem(0, index);
                index ++;
                }
            item.Touch();
            }