I've hit a snag. I am trying to use WatiN to upload a file. I can load the upload box, but it quickly disappears. The last line of my code at the moment is:
ie.FileUpload(Find.ById("profile_file")).Click();
It loads the dialog to select a picture but disappears. Is it possible to set the path of the box automatically example, load "C:/Desktop/image.jpg"?
Also, is it possible to wait for the upload to complete before continuing?
Help is much appreciated.
Thanks.
While this won't answer your question directly, I suspect there is a DialogWatcher automatically canceling the dialog.
As a security measure, browsers don't allow scripts to set the value of a file input. Imagine if they did, I could put a hidden file input on my page where I have a contact form, and set its value to c:\topsecretinfo.txt without the user's permission. then when the user submits the form, voilà, I'd have their top secret information.
As luck has it, I ran into this issue today and this is what I did to get around it:
This is 6 years late, but if anyone else (like me) is still having trouble with this, here's a solution.
To fill out the file dialogue, try this:
This will automatically pull up the file dialogue. You'll then see text being automatically typed into the file selection textfield.
No need for any sendkeys.
why do you need to select from the Dialog.. Try to just sent the Text: