I am trying to automate the creation of a listing on my website and I am having a lot of difficulty uploading an image for the listing. I am using Cloud9 and Watir, and using a headless chrome browser and the code is written in Ruby. For some reason the photo refuses to upload.
Click to see picture of upload area
photo = File.open("00909_8qYJaR8wTix_600x450.jpg", "a")
path = File.expand_path(File.dirname(photo))
browser.file_field(:type,"file").set(path)
Output on terminal:
[8] pry(main)> browser.file_field(:type,"file").value
=> ""
[9] pry(main)> path
=> "/home/ubuntu/workspace/scraper"
[10] pry(main)> File.exist? (path)
=> true
HTML input class="fileupload" multiple="multiple" type="file" style="display: inline-block;"