标签:type att out box current exp ring idp sele
实例1:找到已知名称的窗口
AutomationElement desktop = AutomationElement.RootElement; string wndName="XXX"; Wnd = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty,wndName));
实例2:找到窗口中一个显示为“开始”的文本Label
string ControlName="开始"; var lbStart = Wnd.FindFirst(TreeScope.Descendants, new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text),new PropertyCondition(AutomationElement.NameProperty,ControlName)));
实例3:有一个id为calendar的ComboBox,选择其中的July项
string ComboItemName = "July"; //找到id为calendar的ComboBox AutomationElement calendar = Wnd.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "calendar")); //展开 ExpandCollapsePattern ecPattern = (ExpandCollapsePattern)calendar.GetCurrentPattern(ExpandCollapsePattern.Pattern); ecPattern.Expand(); //找到名称为July的项 var typeCond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem); AutomationElementCollection items = calendar.FindAll(TreeScope.Descendants, typeCond); AutomationElement itemToSelect = items[6]; Object selectPattern = null; if (itemToSelect.TryGetCurrentPattern(SelectionItemPattern.Pattern, out selectPattern)) { ((SelectionItemPattern)selectPattern).Select(); }
标签:type att out box current exp ring idp sele
原文地址:https://www.cnblogs.com/noigel/p/13958186.html