Drop file

Hi,
There is a web portal with this behavior: In order to upload a file you need to drop it on “Drop file here” element, or, as a second option - to initiate standard file location dialog by clicking on the same element.
Since I need both Windows and Linux compatibility for the automation script - I can’t really use the “dialog” option but Drop file only option.
I tried to use Drag And Drop function, but it expects an object as a droppable item and not a file path.
The data I have is:
1. An object to drop into, it has events related to click, drop and others
2. A file path which I would like to transfer to the object without use of File dialog

Could you suggest a way to implement it?
Thanks

1 Like

take this as an crazy idea:
1. open window with url file:///Users/me/path/to/file/ (or inject iframe with folder to page)
(this is part i’m not sure about)
2. start drag action in window with file (pointer on target, mouse down)
3. switch to target window
4. drop file (pointer on target, mouse up)
as i said, not tested, probably (definitely) there are some obstacles

1 Like

Andrej Podhajský said:

take this as an crazy idea:
1. open window with url file:///Users/me/path/to/file/ (or inject iframe with folder to page)
(this is part i’m not sure about)
2. start drag action in window with file (pointer on target, mouse down)
3. switch to target window
4. drop file (pointer on target, mouse up)
as i said, not tested, probably (definitely) there are some obstacles

I’ll try that, thanks )

could you please paste script :slight_smile:
would be easier than for rookies like me

1 Like

hello, Tried but unfortunately it is impossible to perform drag and drop action, files are invisible once trying to put them on web.

1 Like

Found the solution, it appears that for that fancy drag and drop element - there is old good html input form inside. Just check your html source - in the very end there should be hidden input element. The only thing left - change its hidden attribute to be visible with javascript. From that point you can upload a file using WebUI.uploadFile command

1 Like