Consecutive Drag and Drops doesn't work : Automation API

Consecutive Drag and Drops doesn't work

Class library usage, coding and language questions.

Consecutive Drag and Drops doesn't work

Postby bohanl » Tue Jul 12, 2011 5: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);
        }
bohanl
 
Posts: 3
Joined: Tue Jul 12, 2011 4:51 pm

Re: Consecutive Drag and Drops doesn't work

Postby Support Team » Wed Jul 13, 2011 7: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
User avatar
Support Team
Site Admin
 
Posts: 4838
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Postby bohanl » Wed Jul 13, 2011 7: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".
bohanl
 
Posts: 3
Joined: Tue Jul 12, 2011 4:51 pm

Re: Consecutive Drag and Drops doesn't work

Postby Support Team » Wed Jul 13, 2011 7: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
User avatar
Support Team
Site Admin
 
Posts: 4838
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Postby bohanl » Wed Jul 13, 2011 8: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.
bohanl
 
Posts: 3
Joined: Tue Jul 12, 2011 4:51 pm

Re: Consecutive Drag and Drops doesn't work

Postby Support Team » Thu Jul 14, 2011 3: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
User avatar
Support Team
Site Admin
 
Posts: 4838
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Consecutive Drag and Drops doesn't work

Postby Aracknid » Thu Jul 21, 2011 4: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.
User avatar
Aracknid
 
Posts: 126
Joined: Tue Aug 10, 2010 4:23 pm
Location: Toronto, Ontario, Canada


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests