I am trying to automate the process of selecting a local file from an html page using watir-webdriver
I have the following html
<body>
<form method="post" action="upload" enctype="multipart/form-data">
test file to upload: <input type="file" name="file" size="60" id="test"/>
<input type="submit" value="Upload" name="upload" id="upload" />
</form>
</body>
I am trying to click input using idfrom testand set the path to the local file that I want to download using watir-webdriver.
I can use the following to click a button to open a selection window using
@browser.goto 'http://www.test.com'
@browser.button(:id => 'test').click
however, I am trying to use the following (from research, this seems correct, but does not work)
@browser.file_field(:name => 'file').set("C:\\path\\to\\test\\file\\validTest.xml")
leading to the following error
Watir::Exception::UnknownObjectException: unable to locate element, using {:name=>"file", :tag_name=>"input", :type=>"file"}
attempt
@browser.button(:id => 'test').set("C:\\path\\to\\test\\file\\validTest.xml")
leads to the following error
NoMethodError: undefined method `set' for #<Watir::Button:0x3859920>
Can anyone help? I am trying to understand why the parameter is file_fieldnot working.