Drag and Drop element from Windows desktop to an open folder

Experiences, small talk, and other automation gossip.
Kinheart
Posts: 10
Joined: Tue Oct 06, 2015 7:10 pm

Drag and Drop element from Windows desktop to an open folder

Post by Kinheart » Wed Oct 07, 2015 7:40 am

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Thu Oct 08, 2015 7:57 am

Hi,

Try to increase Mouse Move Time, as described here:
http://www.ranorex.com/forum/recording- ... tml#p33118
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Kinheart
Posts: 10
Joined: Tue Oct 06, 2015 7:10 pm

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

Post by Kinheart » Thu Oct 08, 2015 8:50 am

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 =(

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Thu Oct 08, 2015 9:05 am

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 ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Kinheart
Posts: 10
Joined: Tue Oct 06, 2015 7:10 pm

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

Post by Kinheart » Thu Oct 08, 2015 9:58 am

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.

Kinheart
Posts: 10
Joined: Tue Oct 06, 2015 7:10 pm

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

Post by Kinheart » Fri Oct 09, 2015 1:11 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Fri Oct 09, 2015 3:07 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Kinheart
Posts: 10
Joined: Tue Oct 06, 2015 7:10 pm

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

Post by Kinheart » Mon Oct 12, 2015 1:26 pm

Thank you very much =). I've updated Ranorex and it works great!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Mon Oct 12, 2015 1:27 pm

You are welcome ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration