Question

I'm attempting to upload a file as an email attachment through a web-based form using watir-webdriver. The issue that I am running into is that the actual HTML code tied to the fileInput piece is hidden on the page and therefore cannot be interacted with using:

@browser.file_field(:id => "fileInput").set "#{filepath}"

Page HTML Code:

<!--Real Input field, but hidden-->
<input id="fileInput" type="file" value="" name="attachment"></input>
<input id="fileButton" type="button" name="attachment" value="Choose Files"
onclick="document.getElementById('fileInput').click();"></input>

Now, all that being said, I am able to click the 'Choose Files' button on the page which opens the File Upload window. So if I am not able to interact at all with the hidden HTML element, how can I use Ruby to specify what file I want to upload using that popup window? Win32ole?

Was it helpful?

Solution

Two potential solutions come to mind

one, use an OS level automation tool like AutoIt, or RAutomationto interact with the system level file selection control

two, confer with developers of the page and execute javascript to set the appropriate values as if the file selection tool had been used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top