i trying automate creation of listing on website , having lot of difficulty uploading image listing. using cloud9 , watir, , using headless chrome browser , code written in ruby. reason photo refuses upload.
click 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;"
shouldn't path
variable contain path actual file? example looks it's pointing parent directory. ditch file.dirname(photo)
turning this:
photo = file.open("00909_8qyjar8wtix_600x450.jpg", "a") path = file.expand_path(photo) browser.file_field(:type,"file").set(path)
and should fine, in opinion.
Comments
Post a Comment