rubyfile-uploadwatir

Can WATIR upload files from Mac directories?


Part of my test involves uploading a file held in my local Documents directory on my Mac which is running OSMonterey.

The 'Choose Files' element in the browser can't be interacted with other than clicking the button to bring up the mac file browser. So I guess my question is - can WATIR select a file from a local Mac directory? If not, is there any way to force in a file?

Here's the HTML of the Choose File dialog in the browser:

Choose File HTML

Here's the upload dialog:

Upload Dialog


Solution

  • Looks like the site has created a custom control that is used to populate an underlying file input field. Watir won't be able to use that custom control to select a file.

    However, you should be able set the underlying file input directly:

    browser.file_field(class: 'proFileUploader_browser').set('path/to/file')