0

I tried this piece of code to click on Cortana search option on Windows 10 using Coded UI:

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);

Can someone suggest me the right way for this approach? While running this test it shows "Unable to identify hidden control".

Mika Sundland
  • 18,120
  • 16
  • 38
  • 50
  • Just an an FYI, variables in c# are generally named with camel casing: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions – Rescis Dec 29 '17 at 20:17

1 Answers1

0

Try

Mouse.Click(Desktop.ToPoint())

where ToPoint() is

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;
}
Rescis
  • 547
  • 5
  • 19