如何使用编码的UI单击Cortana搜索

时间:2017-12-08 11:30:43

标签: c# coded-ui-tests testautomationfx

我尝试使用Coded UI在Windows 10上点击Cortana搜索选项这段代码:

WinPane Desktop = new WinPane();
Desktop.TechnologyName = "MSAA";
Desktop.SearchProperties.Add(WinPane.PropertyNames.ClassName, "#32769");
Desktop.SearchProperties.Add(WinPane.PropertyNames.ClassName, "Shell_TrayWnd");            
Desktop.SearchProperties.Add(WinPane.PropertyNames.ClassName, "TrayButton", WinButton.PropertyNames.ControlType, "Button");
Mouse.Click(Desktop);

有人可以建议我采用这种方法的正确方法吗?在运行此测试时,它显示"无法识别隐藏的控件"。

1 个答案:

答案 0 :(得分:0)

尝试

Mouse.Click(Desktop.ToPoint())

其中ToPoint()是

public static Point ToPoint(this UITestControl control)
{
    var point = new Point(control.BoundingRectangle.X + control.BoundingRectangle.Width / 2,
        control.BoundingRectangle.Y + control.BoundingRectangle.Height / 2);
    return point;
}