I'm having trouble using C# UIAutomation to find UI elements of Firefox.
In Inspect.exe, everything looks fine:
However, when using the method below on the window as root, only the elements highlighted yellow are found. I need to get to the blue element but have not been able to get it. The solution below is based on this post:
UIAutomation won't retrieve children of an element
public static void WalkControlElements(AutomationElement rootElement)
{
if (rootElement == null) return;
var children = new List<AutomationElement>();
var currentChild = TreeWalker.RawViewWalker.GetFirstChild(rootElement);
while (currentChild != null)
{
children.Add(currentChild);
currentChild = TreeWalker.RawViewWalker.GetNextSibling(currentChild);
}
foreach (var child in children)
{
Console.WriteLine(child.ToString());
WalkControlElements(child);
}
}