Loop through CheckBoxes to find a particular one based upon string

145 views Asked by At

I have an object which is defined as Pane in FlaUInspect with a number of Checkboxes loaded dynamically when the program starts. For a Unit Test I need to loop through all the checkBoxes and find one particular item based upon a string. The code below was first attempt to load the item which does load but it doesn't list all the checkboxes in the Pane.

ListBox seqPanelItems = databaseWindow.FindFirstDescendant(cf => cf.ByAutomationId("sequenceScrollViewer")).AsListBox();

var rdctSeqCheckBox = GetSeqPanelCheckbox(seqPanelItems, "RDCT");

The following code is what loops through the items.

      private CheckBox GetSeqPanelCheckbox(ListBox items, string name)
      {
         for (int i = 0; i < items.Items.Length; i += 1)
         {
            //if (items[i] is not Label)
            //{
            //   continue;
            //}
            if (items.Items[i].Name == name)
            {
               return items.Items[i - 1].AsCheckBox();
            }
         }
         return null;
      }

As the code indicates, it needs to find the particular item and return it as a checkbox item but items.Items.Length returns 0.

Below is what FlaUInspect shows.

enter image description here

1

There are 1 answers

0
Joseph Gabello On

I am considering this problem closed. I moved the CheckBox and Text to a list box.