-1

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

  • What in the `FlaUInspect` image corresponds to `databaseWindow`? – Ann L. Jan 20 '23 at 01:42
  • Is the result of the call to `databaseWindow.FindFirstDescendant()` non-null? Is it _finding_ that list box? – Ann L. Jan 20 '23 at 01:44
  • The databaseWindow corresponds to the Window "Debug View". – Joseph Gabello Jan 23 '23 at 15:24
  • The databaseWindow.FindFirstDescendant() call does come with the properties of the sequenceScrollViewer. The problem is there is no Length or Count associated with it to loop through as once was with TestStack. So now I am trying to find a way to locate an item with sequenceScrollViewer to find the right entry. This was done using a string. – Joseph Gabello Jan 23 '23 at 15:28
  • I was finally able to get all the checkBoxes with the following code: ```var elements = databaseWindow.FindAllByXPath("//CheckBox");``` but the checkBoxes don't have name asiigned to them. These are the lines in the xaml file: Any ideas? – Joseph Gabello Jan 24 '23 at 21:02
  • I am not a XML or WPF expert, at all, but -- assuming this XAML is what you're using to generate the checkboxes -- you aren't actually assigning a `name` value to them! (Unless that's what you were asking about just now!) So it isn't surprising that, when retrieved, their name property would be null, or missing, or whatever. – Ann L. Jan 24 '23 at 21:25
  • Is this WPF? In that case, maybe you should add the WPF tag in order to increase its visibility to potential answerers. – Ann L. Jan 25 '23 at 16:31

1 Answers1

-1

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