sonya_m
5 years agoSmartBear Alumni (Retired)
[TechCorner Challenge #2] Dragging One Element to Another
Hi Community! Here's one more interesting challenge for you to complete!
Drag and drop is quite a simple task that is performed in TestComplete by using the Drag action. However, it might be th...
- 5 years ago
Task: Create a function that takes two objects as parameters and drags the first object to the center of the second one.
This is a solution created for [TechCorner Challenge #2]
In Javascript:
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); }