cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Drag action

SOLVED
Highlighted
Contributor

Problem with Drag action

I have scripts that perform a copy within my tested app. The script uses the Drag method with the ctrl key pressed to drag the item being copied to the location in the tree where the copy should be created when the ctrl+click+drag action completes.

 

I have 3 identical Windows 7 virtual machines on which the automated tests are run.

VM1 & 2 are running TestComplete 14.10

VM3 is running TestComplete 14.20

My desktop is running 14.20.

 

This action works as expected on all machines except for VM3. I've used breakpoints to watch the action happen, and it appears to perform the drag with the ctrl key pressed, but the new (copied) item that should exist after the drag action completes does not exist. I've slowed down the drag action to watch it more closely, checked the coordinates, and everything looks like it's working as expected but the item does not copy as expected.

 

Here is the code for the drag action:

 

/**

* Src - Object, the tree

* srcField - String, path to the item that is dragged

* Dest - Object, the same tree as Src in this case

* destField - String, path where the item is dragged to

**/

function treeItemToTreeItemCopy(Src, srcField, Dest, destField) {
  // Get the x,y of the source
  Src.ClickItem(srcField);
  var bounds = Src.getPathBounds(Src.getSelectionPath());
  var sx = bounds.getCenterX();
  var sy = bounds.getCenterY();
  var sp = Src.WindowToScreen(sx, sy);

  // Get the x,y of the destination
  Dest.ClickItem(destField);
  bounds = Dest.getPathBounds(Dest.getSelectionPath());
  var dx = bounds.getCenterX();
  var dy = bounds.getCenterY();
  var dp = Dest.WindowToScreen(dx, dy);

  // Convert the x,y's into a drag
  Src.Drag(sx, sy, dp.x - sp.x, dp.y - sp.y, skCtrl);
  Delay(1000);
}

 

This code is used a number of times in this project. It consistently fails on VM3 and consistently passes on all other machines.

 

Any thoughts on what could be causing this? I don't have full admin priveleges on the VMs to try upgrading/downgrading TC, or I would try to recreate the issue on the other machines. The tested app is the same code base on all machines.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: Problem with Drag action

Thanks, I submitted a ticket. But in the mean time, I thought that the problem might be with the timing of releasing the ctrl button, so I used low-level procedures to ensure that ctrl is released after the drag is complete, and now it works!

 

For anyone who may encounter this or a similar timing issue, I used this line before the drag to simulate clicking ctrl:

LLPlayer.KeyDown(VK_CONTROL, 250);

 

And this line after the drag to release the control button:

LLPlayer.KeyUp(VK_CONTROL, 250);

View solution in original post

2 REPLIES 2
Highlighted
Community Hero

Re: Problem with Drag action

I suggest that you contact Support directly with your question.  Here's the link:

https://support.smartbear.com/message/?prod=TestComplete

Highlighted
Contributor

Re: Problem with Drag action

Thanks, I submitted a ticket. But in the mean time, I thought that the problem might be with the timing of releasing the ctrl button, so I used low-level procedures to ensure that ctrl is released after the drag is complete, and now it works!

 

For anyone who may encounter this or a similar timing issue, I used this line before the drag to simulate clicking ctrl:

LLPlayer.KeyDown(VK_CONTROL, 250);

 

And this line after the drag to release the control button:

LLPlayer.KeyUp(VK_CONTROL, 250);

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors