UIAutomation学习入门
2015-11-24 23:38
489 查看
一.界面的自动化操作
.Ui自动化测试
.软件外挂
二.Win32基础知识
a.Win32中一切元素皆窗口,窗口之间有父子关系。整个桌面是一个“根窗口”。
b.进程:
根据进程id拿到进程对象Process process = Process.GetProcessById(processId);
启动一个进程:Process process = Process.Start(exe路径);
杀死一个进程process.Kill()
三.UIAutonation基础
1、需要添加对UIAutomationClient、 UIAutomationProvider、 UIAutomationTypes的引用
2、AutomationElement.RootElement是窗口根元素
AutomationElement.FromHandle(IntPtr hwnd)从窗口句柄拿到AutomationElement对象。
3、遍历:
mainElement.FindAll(TreeScope.Descendants,
new PropertyCondition(AutomationElement.ClassNameProperty, "TLabeledEdit"));
TreeScope.Descendants代表递归从所有子孙元素中递归查找;如果是从直接子节点查找,则使用TreeScope.Children。
Condition是过滤条件,可以根据类名等查找,如果是不指定查询条件则使用Condition.True Condition。
FindFirst是查到第一个。
4、点击按钮、设置文本、读取文本使用Pattern来实现。不是所有Pattern都支持
1)设置控件的值
ValuePattern
valuePattern = (ValuePattern)element.GetCurrentPattern(ValuePattern.Pattern);
valuePattern.SetValue("rupeng.com");
2)得到文本控件的值
TextPattern
valuePattern = (TextPattern)element.GetCurrentPattern(TextPattern.Pattern);
string v= valuePattern.DocumentRange.GetText(-1);
3)调用控件,比如点击按钮
var clickPattern = (InvokePattern)element.GetCurrentPattern(InvokePattern.Pattern);
clickPattern.Invoke();
.Ui自动化测试
.软件外挂
二.Win32基础知识
a.Win32中一切元素皆窗口,窗口之间有父子关系。整个桌面是一个“根窗口”。
b.进程:
根据进程id拿到进程对象Process process = Process.GetProcessById(processId);
启动一个进程:Process process = Process.Start(exe路径);
杀死一个进程process.Kill()
三.UIAutonation基础
1、需要添加对UIAutomationClient、 UIAutomationProvider、 UIAutomationTypes的引用
2、AutomationElement.RootElement是窗口根元素
AutomationElement.FromHandle(IntPtr hwnd)从窗口句柄拿到AutomationElement对象。
3、遍历:
mainElement.FindAll(TreeScope.Descendants,
new PropertyCondition(AutomationElement.ClassNameProperty, "TLabeledEdit"));
TreeScope.Descendants代表递归从所有子孙元素中递归查找;如果是从直接子节点查找,则使用TreeScope.Children。
Condition是过滤条件,可以根据类名等查找,如果是不指定查询条件则使用Condition.True Condition。
FindFirst是查到第一个。
4、点击按钮、设置文本、读取文本使用Pattern来实现。不是所有Pattern都支持
1)设置控件的值
ValuePattern
valuePattern = (ValuePattern)element.GetCurrentPattern(ValuePattern.Pattern);
valuePattern.SetValue("rupeng.com");
2)得到文本控件的值
TextPattern
valuePattern = (TextPattern)element.GetCurrentPattern(TextPattern.Pattern);
string v= valuePattern.DocumentRange.GetText(-1);
3)调用控件,比如点击按钮
var clickPattern = (InvokePattern)element.GetCurrentPattern(InvokePattern.Pattern);
clickPattern.Invoke();
相关文章推荐
- 在android studio中新建android gradle project的时候connect refused:connect或者卡在building project...或Refreshing
- UITableView、UITableViewCell、Xib
- IOS UIDatePicker
- Elasticsearch [2.0] ☞ Java Client API ☞ Query DSL
- 爬爬爬之路:UI(十一) UITableView(三) 自定义Cell 多Cell混合 自适应高度 及cell的状态控制
- 我的iOS学习历程 - UITableView的高级使用
- HDU 1047 Integer Inquiry
- UI基础-UITableView 高级
- 随意细解:UI -- 自定义TableViewCell
- UITableView 高级
- UI基础-UITableView 编辑
- 我的iOS学习历程 - UITableView的编辑
- UIImage 切割
- Java Topology Suite (JTS)与空间数据模型
- [TwistedFate]UITableViewCell自定义-02
- 随意细解:UI --UITableView编辑
- 使用requirejs加载多个插件
- Java循环跳转语句之 continue和多重循环
- UIViewController的生命周期及iOS程序执行顺序
- 31.UILable⾃适应⾼度