Forum Discussion

MarekFric's avatar
MarekFric
Occasional Contributor
9 years ago

Click on ListView item based on its name

Hi all. I need to click on ListView item based on its name not based on its position/index. I was not succesful with  method FindChild because item is not visible on screen. It is necessary to scroll down to see it. In wItemCount is real number of ListView items not only visible ones. If I click on ListView item base on its position then it works, but I need to click on it based on its name. Do you have any idea how to solve this ?

7 Replies

    • MarekFric's avatar
      MarekFric
      Occasional Contributor

      Hi Alex,

       

      I'm testing Android application. Object structure is following:

       

      Mobile -> Device -> Process->RootLayout->Layout("NO_ID")->Layout("NO_ID")->Layout("headers")->ListView("list") - "android.widget.ListView" -> listview items, e.g. Layout("NO_ID", 10) -> Layout("NO_ID") with 2 objects->

      -ListView("summary")

      -ListView("title") with property ControlText = "Send by email"

       

      I want to click on ListView("title").

      ListView("list")  is its 3rd parent object.

       

      I have tried Aliases.SignatusMobile.SettingsAndPreferences.Content.Menu.ClickItem("Send by email")

      Total number of items: 14. Items: '', '', '', '', '', '', '', '', '', '', '', ... Tested object: Aliases.SignatusMobile.SettingsAndPreferences.Content.Menu (Mobile.Device("SM-T365").Process("com.anasoft.signatus.app").RootLayout("").Layout("NO_ID").Layout("NO_ID").Layout("headers").ListView("list"))

       

      I know that I'm missing something, but I don't know what.

       

      Thanks,

      Marek

       

  • nepol77's avatar
    nepol77
    New Contributor

    You can use code below but i made this function more general where you pass the name of the item you want to click on as parameter.

     

    function SelectListItems()

    {

      //Jscript

      var avColumns = tasksView.Reports.CandidateFeedbackReport.AvailableColumns; // list items object

      for(i=0; i<avColumns.wItemCount; i++)
      {
          var a = avColumns.Items.get_Item(i).Title;
          if (a == "ItemName")
         {
           avColumns.ClickItem(i);
           Log.Message(a + " had been selected");
         }


      }
    }

     

    I hope this helps.