using System;
using System.Windows.Automation;
using System.Windows.Forms;
using UIAutomationClientsideProviders;
using System.Threading;
namespace autoTest
{
public class WalkEnabledElements
{
public WalkEnabledElements (AutomationElement rootElement, TreeNode treeNode)
{
Condition condition1 = new PropertyCondition(AutomationElement.IsControlElementProperty, true);
Condition condition2 = new PropertyCondition(AutomationElement.IsEnabledProperty, true);
TreeWalker walker = new TreeWalker(new AndCondition(condition1, condition2));
AutomationElement elementNode = walker.GetFirstChild(rootElement);
while (elementNode != null)
{
System.Console.WriteLine("-----> ", elementNode.ToString());
TreeNode childTreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType);
new WalkEnabledElements(elementNode, childTreeNode);
elementNode = walker.GetNextSibling(elementNode);
}
}
}
}
UI Walk
Page 1 of 11 Replies - 240 Views - Last Post: 27 September 2012 - 10:20 AM
#1
UI Walk
Posted 27 September 2012 - 09:26 AM
I am trying to walk a given UI and retrieve the string of the name of each element (textbox, etc). I have the code below, but it prints out a bunch of lines with " ----> " -- that leads me to believe it's walking the UI correctly, but nothing else prints. Any ideas?
Replies To: UI Walk
#2
Re: UI Walk
Posted 27 September 2012 - 10:20 AM
If you want the name, you'll have to crack open the Current property. ToString() doesn't cut it.
http://msdn.microsof...nt.current.aspx
http://msdn.microsof...nt.current.aspx
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|