UI Automation(一)

试用了UI automation并写了些简单的代码,再次总结一下。

1) Launch Application

Process applicationname=new Process();

applicationname.start();

 

2)Identify window

window=AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty,"   "));

 

3)Identify Control

AutomationElement button=window.FindFirst(TreeScope.Descendants, new PropertyConditon(AutomationElement.AutomationIdProperty, "  "));

 

4)Find first and Find all

 

Find first---obtain the first child or descendant element that matches the specified conditon.

Find all---obtain all AutomationElement objects that satisfy the specified condition.

 

//Find all listitems

AutomationElementCollection listitems=window.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem));

你可能感兴趣的:(UI Automation(一))