windows之UIAutomation简介
来源:互联网 发布:淘宝旺旺权重值查询 编辑:程序博客网 时间:2024/06/06 09:04
1、简介
UIAutomation微软提供的UI自动化库,主要用AutomationElement类来表示UI 自动化目录树中的一个UI自动化元素,.NET Windows的窗体应用程序和WPF应用程序
2、体系
- 在服务端由UIAutomationProvider.dll和UIAutomationTypes.dll提供
- 在客户端由UIAutomationClient.dll和UIAutomationTypes.dll提供
- UIAutomationCore.dll为UI自动化的核心部分,负责Server端和Client端的交互
- UIAUtomationClientSideProvides.dll为客户端程序提供自动化支持
3、UI自动化流程
项目中一定要添加引用:
使用UISpy查看控件属性值
Process p = Process.Start(@"C:\Windows\system32\calc.exe");//启动应用程序Thread.Sleep(2000);AutomationElement desktop = AutomationElement.RootElement;//获取RootElementAutomationElement calcframe = desktop.FindFirst(TreeScope.Descendants | TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "计算器"));//获取应用程序AutomationElement sevenbtn = calcframe.FindFirst(TreeScope.Descendants | TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "7"));//获取控件InvokePattern ivkp = (InvokePattern)sevenbtn.GetCurrentPattern(InvokePattern.Pattern);ivkp.Invoke(); //触发控件事件
执行效果:
注:PropertyCondition类是用来对相关属性进行条件匹配,在控件树中查找控件时,可以通过最佳匹配来找到相应的控件
4、UIAutomation重要属性
AutomationIdProperty:通过AutomationId来查找AutomationElement
NameProperty:通过控件的Name属性来查找AutomationElement
ControlType:通过控件的类型来查找AutomationElement
AutomationId: 唯一地标识自动化元素,将其与同级相区分
Name: WPF 按钮的Content 属性、Win32 按钮的Caption 属性以及 HTML 图像的ALT 属性都映射到 UI 自动化视图中的同一个属性Name
5、TreeScope
Element:指定搜索包括元素本身。
Children:指定搜索包括元素的直接子级。
Descendants:指定搜索包括元素的子代(包括子级)。
Parent:指定搜索包括元素的父级。不支持。
Ancestors:指定搜索包括元素的上级
Subtree:指定搜索包括搜索的根和全部子代。
阅读全文
0 0
- windows之UIAutomation简介
- windows之UIAutomation压测
- windows之UIAutomation查找元素
- windows之UIAutomation鼠标操作
- windows之UIAutomation识别UI元素
- windows之UIAutomation的UI元素操作
- uiautomation之AccessibilityNodeInfo
- iOS自动化测试之UIAutomation
- wondows之UIAutomation的优缺点
- UiAutomation系列——Android4.3引入的UiAutomation新框架官方简介(001)
- IOS自动化测试之UIAutomation学习
- IOS自动化测试之UIAutomation学习
- Android4.3引入的UiAutomation新框架官方简介
- Android4.3引入的UiAutomation新框架官方简介
- Android4.3引入的UiAutomation新框架官方简介
- windows程序设计之菜单简介
- windows程序设计之GDI简介
- Windows程序设计[之]Unicode 简介
- ubuntu使用SSH通过Termux登录Android设备
- listview 加载点击事件 弹出不同的内容
- SpringBoot+MyBatis+Oracle+多数据源
- Python tornado数据库与模板页面应用
- 蓝牙底层框架
- windows之UIAutomation简介
- imagemagick 图像纠偏和矫正
- 20171025
- CF#877 E. Danil and a Part-time Job(DFS序+线段树)
- cookie,sessionstorage与localstorage
- linuk下安装jdk与tocmat步骤
- Angular学习第二天
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer
- Junit 测试不支持多线程踩记及解决方案