Retrieve Multiple UIItems ByClassName

∥☆過路亽.° 提交于 2019-12-12 02:55:32

问题


I have a Custom type, under which I have multiple TextBox controls. the problem is all the TextBox's doesn't have either an Automation Id or the Name. So, I wanted to retrieve all the textboxes in a list, so that, I can operate upon them. I know it's not a good practice to do so but I don't have any other option. The problem is how do I retrieve all the these TextBox's which are under a particular custom type in a List?

If anyone knows a better way around then please suggest.


回答1:


Condition condition = new PropertyCondition(AutomationElement.ClassNameProperty, "customclassname");
AutomationElementCollection TextBoxs = ListThatContainsTextBoxsAutomationElement.FindAll(TreeScope.Children, condition);
 Foreach(AutomationElement TextBox in TextBoxs) 
 {
    //Do something with the TextBoxs
 }


来源:https://stackoverflow.com/questions/21130961/retrieve-multiple-uiitems-byclassname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!