Reputation: 1
I am trying to automate desktop application using CodedUI I am getting below error while I am trying click on buttons. Please suggest to me a resolution.
{"Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details:
TechnologyName: 'MSAA'
ClassName: 'WindowsForms10.BUTTON'
ControlType: 'Window'\r\n"}
Code:
WinWindow SearchButtonWindow = new WinWindow();
SearchButtonWindow.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
SearchButtonWindow.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);
SearchButtonWindow.SearchProperties[WinWindow.PropertyNames.ControlType] = "Window";
SearchButtonWindow.SearchProperties[WinWindow.PropertyNames.ControlName] = "cmdSearch";
//SearchButtonWindow.WindowTitles.Contains("Ascend Retail Management Software");
WinButton SearchButton = new WinButton();
SearchButton.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
SearchButton.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);
SearchButton.SearchProperties[WinWindow.PropertyNames.ControlType] = "Button";
SearchButton.SearchProperties[WinButton.PropertyNames.ControlName]= "cmdSearch";
Mouse.Click(SearchButton);
Upvotes: 0
Views: 3898
Reputation: 1
There is a workaround where you can define the location of the object, then put your mouse over it and click.
var clickTargetPoint = new System.Drawing.Point(*OBJECTNAME*.Left + *OBJECTNAME*.Width / 2, *OBJECTNAME*.Top + *OBJECTNAME*.Height / 2);
Mouse.Hover(clickTargetPoint);
Mouse.Click();
This helped me.
Upvotes: 0
Reputation: 19
I have run into this a few times in the past. Usually when there is a non-clickable transparent or other non-visible object on top of the object you want. You can get to the object by forcing the mouse to the objects location and then calling the click command.
Point? xyPoint = GetCenterPoint(SearchButton);
if (xyPoint != null)
{
Mouse.Click((Point)xyPoint);
}
public Point? GetCenterPoint(UITestControl objTarget)
{
Point? _Point = null;
try
{
if (objTarget != null && objTarget.GetProperty(UITestControl.PropertyNames.BoundingRectangle) != null)
{
double _CenterX = objTarget.BoundingRectangle.X + (objTarget.BoundingRectangle.Width / 2);
int _PointX = Convert.ToInt32(_CenterX);
double _CenterY = objTarget.BoundingRectangle.Y + (objTarget.BoundingRectangle.Height / 2);
int _PointY = Convert.ToInt32(_CenterY);
_Point = new Point(_PointX, _PointY);
}
}
catch (Exception ex)
{
//Exception Logging Here
}
return _Point;
}
Upvotes: 1
Reputation: 21
Try using Drawhighlight() method and find whether test is highlighting the correct control
Upvotes: 1
Reputation: 21
From your code I see that, the SearchButtonWindow is not assigned as parent to the SearchButton. Most of the times hierarchy is also required for identifying a control uniquely.
WinButton SearchButton = new WinButton(SearchButtonWindow);
Also, check the child controls of the SearchButtonWindow through CodedUI Test Builder Tool (Once the Window is highlighted, use arrow keys on top right of the Builder window. Down arrow key takes to the immediate first child of the currently highlighted control, where as right arrow key moves to the siblings)
Upvotes: 1