I'm trying to browse to a file after i click the download button. But I though of writing a recursive function that finds controls in any window using AutomationElement library so hopefully i can find the nested controls in the open dialog window. This function is not working now. Please let me know where is the issue here or let me know if you have any suggestions.
The problem is that It never gets to the else statement and never ends. So i don't think it finds the element at all.
Here is the element highlighted that i'm trying to get using:
Thanks
private AutomationElement GetElement(AutomationElement element, Condition conditions, string className)
{
AutomationElement boo = null;
foreach (AutomationElement c in element.FindAll(TreeScope.Subtree, Automation.ControlViewCondition))
{
var child = c;
if (c.Current.ClassName.Contains(className) == false)
{
GetElement(child, conditions, className);
}
else
{
boo = child.FindFirst(TreeScope.Descendants, conditions);
}
}
return boo;
}