Forum Discussion
1 Reply
- tristaanogreEsteemed Contributor
Drag and drop us done by using the "Drag" method associated with most on screen objects (see https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/onscreen/drag-action-onscreen-object.html).
The only problem I have with that is that it is very co-ordinate specific. You drag from some point on the source object and then you drag a differential x and y distance. So, you can't just say, "Drag this object to that object" using Drag alone...
To that end... with a little help from our friends here... I use the following:
function dragCalculatedDistance(startObject, destinationObject) { var startPoint, targetPoint, dragX, dragY; // Drag from the center of object A to the center of object B startPoint = startObject.WindowToScreen(startObject.Width/2, startObject.Height/2); targetPoint = destinationObject.WindowToScreen(destinationObject.Width/2, destinationObject.Height/2); dragX = targetPoint.X - startPoint.X; dragY = targetPoint.Y - startPoint.Y; startObject.Drag(-1, -1, dragX, dragY); }
The startObject would be the OnScreen object (Alias or some other way of designating the onscreen object) that is the thing you want to drag, the destinationObject is the OnScreen object that is the target destination.