Page 1 of 1

Drag and Drop element from Windows desktop to an open folder

Posted: Wed Oct 07, 2015 7:40 am
by Kinheart
Good day, everyone!

I have this problem, when I try to Drag and Drop some Word Document from desktop to an open folder, it does not drag the Word file. For some reason, Ranorex loses the Drag focus on the file, when it moves the cursor to an opened Folder. I think the problem is, that when Ranorex moves to this Doc file on the Desktop, he minimizes all the windows. And when Ranorex presses the Left Mouse button and tries to move this Doc file to a folder, he opens this folder, makes a focus on this folder and loses the focus on file. So he only drags an empty mouse to an open folder.

I use Visual Studio 2012 for automation and Ranorex-5.2.1.

This is the Method that I use for Drag and Drop -

protected void DragAndDropElement(Unknown dragElement, Unknown destinationElement)
{
dragElement.MoveTo();
Mouse.ButtonDown(MouseButtons.Left);
destinationElement.MoveTo();
Mouse.ButtonUp(MouseButtons.Left);
}

Maybe I am doing something wrong? I would appreciate any feedback =)

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Thu Oct 08, 2015 7:57 am
by odklizec
Hi,

Try to increase Mouse Move Time, as described here:
http://www.ranorex.com/forum/recording- ... tml#p33118

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Thu Oct 08, 2015 8:50 am
by Kinheart
Hi, odklizec

But I don't use the Recording from Ranorex. I write auto-tests in Visual Studio, using Ranorex dlls. But still I've tried this Mouse Move Time, changed the value to 1000 and 1500, still does not work =(

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Thu Oct 08, 2015 9:05 am
by odklizec
You can of course specify the mouse move time also from code. I think you missed the command Mouse.DevaultMoveTime mentioned in the suggested post?

Also, it may be helpful to make sure the element you want to move and the one to which you want to drop something is visible (using EnsureVisible method). So the code should look like this...
protected void DragAndDropElement(Unknown dragElement, Unknown destinationElement)
{
dragElement.EnsureVisible();
dragElement.MoveTo(dragElement);
Mouse.ButtonDown(MouseButtons.Left);
destinationElement.EnsureVisible();
destinationElement.MoveTo();
Mouse.ButtonUp(MouseButtons.Left);
}
Unfortunately, it's hard to suggest something more reliable without seeing your test and exact testing environment. If setting DevaultMoveTime does not help, I would suggest to ask Ricoh folks for a live session so they can watch your test in action and suggest some changes. Drag&Drop actions are always tricky to automate.

BTW, you should really try to update your Ranorex with the most recent version. The one you are using is too old and no longer supported. A lot of bug fixes and new things were added between 5.2.1 and 5.4.2 ;)

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Thu Oct 08, 2015 9:58 am
by Kinheart
Nope, still nothing =(

Well, this is a simple test. This Auto-test opens a folder, sets a specific path(ex. "D:\Autotest folder") then creates a Word document on a Desktop, after that tries to Drag and Drop this newly created Document to this folder.

I have another tests which Drag and Drops folders to Favorites section(left navigation menu in Explorer) from Parent folder(in 'Autotest folder' I create three more folders and then drag and drop them on Favorites section). In this test everything is working perfectly, with the same Method that I've shown you. But in this new case, when I try to drag and drop from Desktop, for some reason it does not work =(. I assume, it somehow loses focus of the file when Ranorex expands the minimized folder.

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Fri Oct 09, 2015 1:11 pm
by Kinheart
Nobody did Drag and Drop, a file from Desktop to an open Folder? Using Visual Studio+Ranorex?

If this could work, it would help me so much. Or maybe it is just a bug of Ranorex? He loses focus, when he expands the Folder? What should I do?

Best Regards

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Fri Oct 09, 2015 3:07 pm
by odklizec
Hi,

Try this code...

Code: Select all

dragElement.MoveTo();
destinationElement.Self.EnsureVisible();
Mouse.ButtonDown(MouseButtons.Left);
destinationElement.MoveTo();
Mouse.ButtonUp(MouseButtons.Left);
Works for me with Ranorex 5.4.2. Notice the EnsureVisible method is done BEFORE left-clicking mouse.

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Mon Oct 12, 2015 1:26 pm
by Kinheart
Thank you very much =). I've updated Ranorex and it works great!

Re: Drag and Drop element from Windows desktop to an open folder

Posted: Mon Oct 12, 2015 1:27 pm
by odklizec
You are welcome ;)