Implement and Object-To-Object Mouse Drag capability for both script and keyword tests.
Currently, the mouse "Drag" method drags from a starting co-ordinate a set X distance and Y distance from that starting co-ordinate. For most "normal" drag functionalities, this is sufficient. I even wrote some code with help from folks up here that, given a starting object and a destitination object, will drag from one to the other.
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 problem is this... We have a situation where we need to drag an object that is present below a table in our application to a particular cell in the table. In that process, when we cross the lower border of the table, the table may auto-scroll down to reveal other rows. Because the above function just drags to a calculated set of co-ordinates, the end result is that we end up dropping the object on the wrong row in the table.
Proposed Solution: A drag functionality for TestComplete where, instead of dragging based upon a co-ordinate distance, actually drag from one object to another... something like
onscreenObject1.DragTo(onscreenObject2)
where the two objects are identified onscreen objects. This would resolve the auto-scroll because it would actually drag to the particular cell we want and not to just a set of on-screen co-ordinates.
Low priority change to make... and I'm open to other code that would make this work better for us. But I think this would be "cool" as it would mean that my custom code above wouldn't be necessary any more and we could have "smart" drag-and-drop functionality.