-
寻找解决方案
- QTP --- 又重又贵
- Microsoft’s UI automation framework :使用起来非常麻烦 例子:here.
- Microsoft’s Coded UI Test --- 需要Visual Studio Enterprise: FYI
- Winium+uiautomationverify --- 开源 based on Microsoft’s UI automation framework.
-
代码实现
- 使用uiautomationverif来查看应用的结构树,用Winium 来写代码
- 有两种方式可以找到元素:Find the element by name or by ID
var component= menus.FindElementByName("component").ToMenu(); var component= tblLayOut.FindElementByUid("component");
-
一些关键点
- 可以用Thread.Sleep(),让线程等待每一步的完成。
- 不能最小化应用,也不能所屏。
- 使用如下类调用Win32API可以让Windows永远不锁屏
public class PowerHelper { public static void ForceSystemAwake()