Drag a file outside of the browser/DOM and drop it inside of the browser/DOM?

Hey everyone, is there any way to open the file explorer and drag and drop from the file explore into the web application? I am guessing there currently is not. Thanks!

So im guessing you have tried WebUI.dragAndDropToObject(findTestObject('), findTestObject(')) and that did not work for you ?

For my case, the object that is dropped is outside of the DOM/browser. The method, “WebUI.dragAndDropToObject(findTestObject(’), findTestObject(’))”, only works when the object that is dropped is inside the DOM/browser. Ideally, I would like a way to open the file explorer and show the mouse dragging a file and dropping it to the drop location. Any advice?

Ok so ive never used this before but WebUI.dragAndDropByOffset(findTestObject(null), 0, 0) sounds like it would work for what you want to do as its dragging the object to a place on the screen so im assuming it can switch from your file explorer to your web page.

Have a read and a play about and let us know if you get any luck :slight_smile:

https://docs.katalon.com/katalon-studio/docs/webui-drag-and-drop-by-offset.html#example

I just read it. I believe that would work if the object that is dropped is within the browser/DOM and the drop location is outside of the browser/DOM. In my case, the object that is dropped is outside the browser/DOM and the drop location is inside the browser/DOM.

If you have tried it and cant get it to work, im all out of awnsers. Is there a reason you need it to be dragged and dropped from the file explorer ? is there a workaround you can use ?

The reason is to test a drag and drop upload UI/UX widget. There is a workaround but the goal is to test the UI. If there is a way, that would be great. If not, we can probably move this test into the low risk test items list.

You are correct, the WebUI APIs cannot be used for this. You should be able to accomplish this using the Java Robot class. I’d suggest you go on a web search for something similar to your problem to get you started.

https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

Thanks Russ! This solution worked for me :+1:t5:

1 Like