UI Automation-InvokePattern
来源:互联网 发布:淘宝怎么申请游戏专营 编辑:程序博客网 时间:2024/06/05 17:33
InvokePattern用于可被调用的控件,如按钮。Used to support controls that do not maintain state when activated but rather initiate or perform a single, unambiguous action, such as a button.
封装如下代码:
public static InvokePattern GetInvokePattern(AutomationElement element)
{
object currentPattern = null;
if (!element.TryGetCurrentPattern(InvokePattern.Pattern, out currentPattern))
{
Log.Error(string.Format("Element with AutomationId '{0}' and Name '{1}' does not support the InvokePattern.",
element.Current.AutomationId, element.Current.Name));
throw new Exception(string.Format("Element with AutomationId '{0}' and Name '{1}' does not support the InvokePattern.",
element.Current.AutomationId, element.Current.Name));
}
return currentPattern as InvokePattern;
}
//Get the button element
AutomationElement button = AutomationElementSearch.FindElementById(window, "button1");
Assert.IsNotNull(button);
Thread.Sleep(1000);
//Click the button
InvokePattern invokepattern = Invokepattern.GetInvokePattern(button);
Assert.IsNotNull(invokepattern);
invokepattern.Invoke();
Thread.Sleep(1000);
- UI Automation-InvokePattern
- UI Automation-InvokePattern
- 使用UI Automation实现自动化测试 (InvokePattern)
- UI Automation-ValuePattern
- UI Automation-TogglePattern
- UI Automation-WindowPattern
- UI Automation-GridPattern
- UI Automation-TablePattern
- UI Automation-RangeValuePattern
- UI Automation-TransformPattern
- UI Automation-RangeValuePattern
- UI Automation-TablePattern
- UI Automation-TransformPattern
- UI Automation-GridPattern
- UI Automation-WindowPattern
- UI Automation-TogglePattern
- UI Automation-ValuePattern
- UI Automation-XML(二)
- ajax学习笔记1
- Qt编程技巧 Q_OBJECT宏的作用
- 线程经验
- frame & frameset
- define和typedef的区别
- UI Automation-InvokePattern
- 解决wdk 中不同编译环境兼容性问题解决
- 接收到来自58.18.164.129的消息!
- 利用Web Application Stress Tool(WAS)做性能测试
- VB中的command
- jQuery 1.4正式发布:一起来看有哪些新变化(上篇)
- 微软安全通报 979352 及威胁形势透析
- Linux创始人Linus步入不惑之年
- db2中自增id违反唯一性约束解决方法(SQLCODE=-803, SQLSTATE=23505)