Consecutive Drag and Drops doesn't work

Class library usage, coding and language questions.
bohanl
Posts: 3
Joined: Tue Jul 12, 2011 3:51 pm

Consecutive Drag and Drops doesn't work

Post by bohanl » Tue Jul 12, 2011 4:04 pm

Ranorex version: 3.0.2.12718
.NET version: 4.0
Platform: windows 7
Language: C#

I wrote code to do multiple drag and drops by using:

MoveTo();
ButtonDown();
Delay.Duration(...);
MoveTo();
ButtonUp();

However, this sequence only works once - it does not work if I call it in a loop in the following scenario:
Drag from cell1 and drop to cell2, from cell2 to cell3, from cell3 to cell4...

I tried using Ranorex global recording to do the same thing the code that Ranorex generates looks like the following:

This sequence worked. However, it does not work if I get rid of the "repo.cellInfo" in Report.Log() function.

Any idea how this repository as a param[] IReportMetaData affects consecutive drag and drops?


[Ranorex Code]:
public void Mouse_Up_Cell3()
        {
            // Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Up item 'Cell3' at 16;5.", repo.Cell3Info, new RecordItemIndex(-1));
            repo.Cell2.MoveTo("16;5");
            Mouse.ButtonUp(MouseButtons.Left);
        }

        public void Mouse_Down_Cell2()
        {
            // Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Down item 'Cell2' at 15;7.", repo.Cell2Info, new RecordItemIndex(-1));
            repo.Cell2.MoveTo("15;7");
            Mouse.ButtonDown(MouseButtons.Left);
        }

        public void Mouse_Up_Cell1()
        {
            // Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel..Info, "Mouse", "Mouse Left Up item 'Cell1' at 17;10.", repo.Cell1Info, new RecordItemIndex(-1));
            repo.Cell1.MoveTo("17;10");
            Mouse.ButtonUp(MouseButtons.Left);
        }

        public void Mouse_Down_Cell1()
        {
            // Your code goes here. Code inside this method will not be changed by the code generator.
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Down item 'Cell1' at 17;10.", repo.Cell1Info, new RecordItemIndex(-1));
            repo.Cell1.MoveTo("17;10");
            Mouse.ButtonDown(MouseButtons.Left);
        }

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Post by Support Team » Wed Jul 13, 2011 6:22 pm

bohanl wrote:This sequence worked. However, it does not work if I get rid of the "repo.cellInfo" in Report.Log() function.
This should indeed make no difference. The only cause I can think of is a timing issue. Did you try commenting out the report statement completely?

Could you post the Ranorex log file corresponding to that issue? Thanks!
BTW the code for your Mouse_Up_Cell3 method uses Cell2 and not Cell3...

Regards,
Alex
Ranorex Team
.
Image

bohanl
Posts: 3
Joined: Tue Jul 12, 2011 3:51 pm

Re: Consecutive Drag and Drops doesn't work

Post by bohanl » Wed Jul 13, 2011 6:26 pm

Thanks for your reply. Yes. I did try commenting out the report statement and it didnt work. It did not work even I got rid of repo.callInfo parameter from the function.

As stated, I put a delay between buttonDown and MoveTo. It worked when you do drag and drop once but not "consecutive" ones:

By consecutive, I mean "from Cell1 to Cell2, from Cell2 to Cell3"

However, it does work if you do "from Cell1 to Cell2", from Cell3 to Cell4".

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Post by Support Team » Wed Jul 13, 2011 6:34 pm

And what is the error you get? Do you get an exception? Or does the click (down/up) go to the wrong location? Or does the cell go in edit mode?

Please, give us some more information, since we cannot reproduce that problem on our side. As I wrote before, a Ranorex report of the problem would be good and a Ranorex snapshot of the grid would also help.

Regards,
Alex
Ranorex Team
.
Image

bohanl
Posts: 3
Joined: Tue Jul 12, 2011 3:51 pm

Re: Consecutive Drag and Drops doesn't work

Post by bohanl » Wed Jul 13, 2011 7:02 pm

I'm sorry that I cannot provide the snapshot.

For the following sequence:

1. MoveTo()
2. ButtonDown()
3. Delay.Duration()
4. MoveTo()
5. ButtonUp()

If I do from Cell1 to Cell2, then from Cell2 to Cell3:

1. The code will go through for the first time (drag from Cell1 to Cell2 successfully).
2. It got stuck on Delay.Duration when it is trying to drag and drop from Cell2 to Cell3. But during this time, if I manually move the mouse a little bit..it will keep going.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Post by Support Team » Thu Jul 14, 2011 2:18 pm

As I said before, we are not able to reproduce that issue on our side, sorry. Could you provide us a sample application and the Ranorex code that we can reproduce the problem with?
bohanl wrote:1. The code will go through for the first time (drag from Cell1 to Cell2 successfully).
Could it be that the mouse down action on Cell 2 from the second loop happens too quickly? Have you tried adding a delay after step 5 (ButtonUp)?
bohanl wrote:2. It got stuck on Delay.Duration when it is trying to drag and drop from Cell2 to Cell3. But during this time, if I manually move the mouse a little bit..it will keep going.
It is stuck on Delay.Duration? That method does nothing but wait for the specified time, no idea how that could get stuck :? Please, try to move to screen position (0,0) in between the two drag&drop operations:
// drag & drop operation from Cell1 to Cell2
Ranorex.Mouse.MoveTo(0, 0);
// drag & drop operation from Cell2 to Cell1
Regards,
Alex
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Consecutive Drag and Drops doesn't work

Post by Aracknid » Thu Jul 21, 2011 3:41 pm

I just thought that I would add this in case it helps...

I was having drag and drops issues. What I did to resolve it was to add a "wiggle mouse" step, which resolved the problem. In my case I was trying to drag items in List A to List B. When I clicked on item in List A and moved to List B, it would not always drop it in List B when I did the mouse up EVEn with a delay of more than enough time. So before the mouse up, I would move the mouse a bit around where I was and then mouse up. This resolved my issue.

Aracknid.

JSH_QA
Posts: 56
Joined: Thu Apr 05, 2012 9:03 am

Re: Consecutive Drag and Drops doesn't work

Post by JSH_QA » Mon Oct 06, 2014 4:33 pm

Three years later, but I can confirm that we have just encountered this same problem.
In our scenario, using a Windows desktop application (WPF), we drag one treeitem after another from one tree to a second tree. The first three drags work, but the fourth failed every time. The moment we implemented a "wiggle" the problem does not recur.

The sequence we end up with is:

1. Move to first tree item
2. Left button down
3. Move mouse up 2 pixels
4. Move mouse down 4 pixels
5. Move mouse up 2 pixels
6. Move mouse to the destination tree
7. Left button up

If (4) and (5) are removed it still does not work, so it needs more than just a single move, it really does need wiggle.

Regards,

John H.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Post by Support Team » Tue Oct 07, 2014 1:48 pm

Hi John,

May I ask you to change the Mouse Move Time of your Mouse Up action to for instance 3000ms for test purposes?
You find the setting in the properties window of the specific action:
MouseMove_Property.png
MouseMove_Property.png (12.27 KiB) Viewed 1685 times
Does it work with a single Mouse Down and Up when you use a higher value for the Move Time?

Regards,
Markus
.
Image

JSH_QA
Posts: 56
Joined: Thu Apr 05, 2012 9:03 am

Re: Consecutive Drag and Drops doesn't work

Post by JSH_QA » Tue Oct 07, 2014 4:49 pm

Hi Markus,

No, increasing the Move Time does not make any difference. We have it set to 300ms already, as we had seen other issues if the value was 0. However, changing it from 300ms to 3000ms has no effect (other than making it slower :-) ).

In our test, we perform multiple drag & drop operations. The first three always work, the fourth only works if we introduce the "wiggle". With the wiggle, we can then continue and do many, many more drag and drops successfully.

Strangely, when I was manually testing another piece of software last year that also used tree controls, I encountered the same sort of issue. That was during manual testing, rather than automated. With the software that we are testing now, we only see this with automation, but it does make me wonder whether it is an issue with the tree control, or with Windows 7, rather than Ranorex...

Regards,

John H.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Post by Support Team » Thu Oct 09, 2014 1:58 pm

Hi John,

I also saw an issue once where Ranorex was not able to drag'n'drop an item to another position unless you increased the Mouse Move time. I therefore was curious if this would also solve the issue on your site.

I would rather think this is somehow related to the application since the first three drag'n'drops work without any issues. You could try debugging the application under test to see if there happens something unexpectedly when you drag'n'drop such elements the fourth time.

Regards,
Markus
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Consecutive Drag and Drops doesn't work

Post by Aracknid » Thu Oct 09, 2014 2:19 pm

Figure I'd jump in since I originally mentioned the wiggle workaround years ago.

I believe the problem I was experiencing was due to the fact that Mouse down on the source item and then mouse up on the target location was happening with no movement in the middle. The cursor would just go from source to target instantly. The target control was not always registering the mouse over event and thus when you did the mouse up, it wouldn't really do the drop. The Wiggle workaround was actually forcing the movement over the target control, so that upon mouse up the drop would work.

Another way to resolve this was to simply mouse down on the source, mouse move over a certain amount of time, such as 1 or 2 seconds to the target, and then mouse up on the target spot you moved to. This also seemed to always work, and looks like a more real drag and drop.

As an aside and separate, I also had a very odd control that was a div control with div items in it. It looked like a select list, but wasn't. With this control, as you dragged the div items they would get snapped out of the source Div container control and when you moved over the target div container they would snap into it at the spot the mouse was... but it had some weird bugs in how it worked and created a bunch of different issues. So just wanted to mention it is possible that controls/UI design can be the issue too.

Aracknid