Improved the support of the file picker

Send a DOM event directly instead of using sendEvent, since the input
can be outside the window.

And sleep until the filepicker has been really called