Showing results for 
Search instead for 
Did you mean: 

Add DragDrop method to testedobjects

0 Kudos

Add DragDrop method to testedobjects

var obj = someobject;

var destination = someotherobjectl




This would be SO righteously helpful and clean. 


Community Hero
Super Contributor

Yes. Which requires you to calculate the coordinates of the destination. Not a fan. I want someone to calculate it for me. Of course, in the meantime I have to do it anyway. But as I look forward to training my team, I would rater not have to teach them that. So be it. But...

Community Hero

You could create a script extension for them to use so you don't have to train them. 

Super Contributor

Yes, I know. Thanks.

Community Hero

I actually have our drag method added to a script extension.  The code looks like this:


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); 

I wrap that in a script extension and then the method is available for any project.  Give this a try.


Super Contributor

I will, thanks. I think you posted this elsewhere. I still with TestComplete had the ability natively.