title: Testing upload watir and rspec
body: <p>I am trying to test upload pictures/document on web pages using watir/watir-webdriver, but everything I tried does not work.</p>
  
  <p>For example, uploading pictures on Imgur:</p>
  
  <pre><code>require 'watir'
  require 'watir-webdriver'
  require 'rspec'
  
  describe "Upload test" do
  
    before(:all) do 
        @browser = Watir::Browser.new :firefox
        @browser.goto("https://imgur.com/")
    end
  
    context "Upload test" do
      it "can upload picture" do
        @browser.link(:text, "upload images").click
        @browser.file_field(:name, "img_path").set("img_path")
        @browser.button(:value,"Save").click
      end
    end
  
    after(:all) do
      @browser.close unless debugging?
    end
  
  end
  </code></pre>
  
  <p>There is an error.</p>
  
  <pre><code>Failures:
  
    1) Upload test Upload test can upload picture
       Failure/Error: @browser.link(:text, "upload images").click
  
       Watir::Exception::UnknownObjectException:
         unable to locate element, using {:text=&gt;"upload images", :tag_name=&gt;"a"}
       # /var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:536:in `assert_element_found'
       # /var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:508:in `assert_exists'
       # /var/lib/gems/1.9.1/gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:114:in `click'
       # ./PROBA.rb:14:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 11.47 seconds (files took 0.19261 seconds to load)
  1 example, 1 failure
  
  Failed examples:
  
  rspec ./PROBA.rb:13 # Upload test Upload test can upload picture
  </code></pre>
  
  <p>I have tried to upload it on other sites, but I could not. Can anybody show me a correct way to upload document using watir? I think there is some trick using "flash" buttons, but I am not sure?</p>