我正在尝试使用 watir-webdriver 通过基于 Web 的表单将文件作为电子邮件附件上传。我遇到的问题是与 fileInput 片段相关的实际 HTML 代码隐藏在页面上,因此无法使用以下方法进行交互:
@browser.file_field(:id => "fileInput").set "#{filepath}"
页面 HTML 代码:
<!--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>
现在,说了这么多,我可以单击打开“文件上传”窗口的页面上的“选择文件”按钮。因此,如果我根本无法与隐藏的 HTML 元素进行交互,我如何使用 Ruby 来指定要使用该弹出窗口上传的文件?Win32ole?