I want to get the value from the LegacyIAccessible description property of a list item using either UI Automation or preferably FlaUI. I have the below working but it is not consistent. I am unsure why but it seems to only work if the target window is open before the test starts(using SpecFlow to run tests).
for (int i = 0; i < listbox.Items.Length, i++)
{
itemDesciption = listBox.Items[i].Patterns.LegacyIAccessible.PatternOrDefault.Description;
if (itemDesciption.Contains("value"))
{
targetItem = listBox.Items[i]; )
}