I'm currently trying to automate a test case using the White UI-Automation framework.
In doing this I'm having some trouble with drag and drop. I'm trying to drag from a button to a point on the screen, which I calculate based on the location of two other points.
What happens is the button is clicked and the mouse moves to the correct location and then the application hangs until the mouse is manually moved or clicked then the drop occurs and the test continues. If the mouse doesn't receive any manual interaction then the application continues to hang.
The code looks like this:
var criteria = SearchCriteria.ByText(xText);
var yLocation = window.Get(crite);
var yPoint = yLocation.ClickablePoint;
criteria = SearchCriteria.ByText(yText);
var xPoint = window.Get(crite).ClickablePoint;
var dropPoint = new Point(xPoint.X, yPoint.Y);
criteria = SearchCriteria.ByText(buttonName);
var button = (Button) window.Get(criteria);
Mouse.Instance.DragAndDrop(button, button.ClickablePoint,yLocation,dropPoint);
Any code after this last line is not executed.
Thanks in advance for any help.
Check here: http://white.codeplex.com/discussions/271672
This page shows a work around:
//Point the mouse for drag
Mouse.Instance.Location = draggedItem.ClickablePoint;
Mouse.LeftDown();
//Move the mouse a little down
Mouse.Instance.Location = new Point(draggedItem.ClickablePoint.X, draggedItem.ClickablePoint.Y + 1);
//Move to the new window
targetWindow.Focus();
//Set the point to drop
Mouse.Instance.Location = targetWindow.ClickablePoint;
//Drop
Mouse.LeftUp();