How to upload a file with watir and IE?
- by karlthorwald
I am writing a watir script to test an upload form.
But the script does not automatically choose the file that is to be uploaded from my harddrive.
Instead IE stops with the file chooser dialog open. As soon as I manually select the to be uploaded file in the dialog and click ok, watir continues as desired. I wonder why it stops.
This is from my watir script:
ie.file_field(:name, 'upload').set("s:\\localwatir\\Test_Pdf.pdf")
ie.button(:name, 'submit').click
I got the code from this page: http://wiki.openqa.org/display/WTR/File+Uploads
This is the form:
<form name="form1" enctype="multipart/form-data" method="post" action="uploadlegacy.php">
<input type="file" name="upload" size="30">
<input type="submit" name="submit" value="upload">
</form>
I have found this manual http://svn.openqa.org/svn/watir/trunk/watir/unittests/filefield_test.rb also, but as I do not know what $htmlRoot stands for, I cannot really follow it. Does that mean, I have to put some "file///" into the parameter for set()? If so, how exactly? I am using IE 6 for the testing.