title: File Upload using Selenium Webdriver and ruby with < button type="button">
body: <p>I am using Selenium WebDriver and Ruby and I need to automate the file upload feature. 
  I tried with </p>
  
  <p><code>WAIT.until { driver.find_element(:css,'div.ui-dialog-buttonset').displayed? }</code>  </p>
  
  <p>by using this it gives time out error</p>
  
  <pre><code>  elem = driver.find_element(:css,'div.ui-dialog-buttonset')
    puts "Hi"
    js = &lt;&lt;-end
  var buttons = document.querySelectorAll('button');
      buttons[0].setAttribute('aria-disabled', true);
  end
    elem = driver.execute_script(js, elem)
    puts elem
    elem.send_keys("C:\\Users\\seema\\Desktop\\1413.jpg")
  </code></pre>
  
  <p>Above code is not working and script fails by following error </p>
  
  <p>here is HTML code</p>
  
  <pre><code>&lt;div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"&gt;
     &lt;div class="ui-dialog-buttonset"&gt;
        &lt;button class="otherButtonClass ui-state-hover ui-state-focus" type="button" role="button" aria-disabled="false"&gt;
        &lt;button class="otherButtonClass" type="button" role="button" aria-disabled="false" style="display: none;"&gt;
        &lt;button class="cancelButtonClass" type="button" role="button" aria-disabled="false"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>here is error stack </p>
  
  <pre><code>,"message":"error - undefined me
      thod `send_keys' for nil:NilClass \n [\"tests/upload_branding.rb:38:in `create_publish_pla
      yer'\", \"tests/upload_branding.rb:80:in `PublishPlayerTest'\", \"org/jruby/RubyBasicObjec
      t.java:1703:in `__send__'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-4.7.4/lib
      /minitest/unit.rb:1258:in `run'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-rep
      orters-0.14.20/lib/minitest/reporters.rb:62:in `run_with_hooks'\", \"c:/jruby-1.7.4/lib/ru
      by/gems/shared/gems/scope-0.2.4/lib/scope.rb:105:in `run'\", \"org/jruby/RubyProc.java:255
      :in `call'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/scope-0.2.4/lib/scope.rb:153:in `
      recursively_run_setup_and_teardown'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/scope-0.
      2.4/lib/scope.rb:155:in `recursively_run_setup_and_teardown'\", \"c:/jruby-1.7.4/lib/ruby/
      gems/shared/gems/scope-0.2.4/lib/scope.rb:139:in `run_setup_and_teardown'\", \"c:/jruby-1.
      7.4/lib/ruby/gems/shared/gems/scope-0.2.4/lib/scope.rb:105:in `run'\", \"c:/jruby-1.7.4/li
      b/ruby/gems/shared/gems/minitest-4.7.4/lib/minitest/unit.rb:933:in `_run_suite'\", \"org/j
      ruby/RubyArray.java:2417:in `map'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-4
      .7.4/lib/minitest/unit.rb:926:in `_run_suite'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gem
      s/minitest-reporters-0.14.20/lib/minitest/reporter_runner.rb:45:in `_run_suite'\", \"c:/jr
      uby-1.7.4/lib/ruby/gems/shared/gems/minitest-4.7.4/lib/minitest/parallel_each.rb:71:in `_r
      un_suites'\", \"org/jruby/RubyArray.java:2417:in `map'\", \"c:/jruby-1.7.4/lib/ruby/gems/s
      hared/gems/minitest-4.7.4/lib/minitest/parallel_each.rb:70:in `_run_suites'\", \"c:/jruby-
      1.7.4/lib/ruby/gems/shared/gems/minitest-reporters-0.14.20/lib/minitest/reporter_runner.rb
      :37:in `_run_suites'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-4.7.4/lib/mini
      test/unit.rb:877:in `_run_anything'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest
      -4.7.4/lib/minitest/unit.rb:1085:in `run_tests'\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/g
      ems/minitest-reporters-0.14.20/lib/minitest/reporter_runner.rb:30:in `run_tests'\", \"org/
      jruby/RubyBasicObject.java:1703:in `__send__'\", \"org/jruby/RubyKernel.java:2209:in `send
      '\", \"c:/jruby-1.7.4/lib/ruby/gems/shared/gems/minitest-4.7.4/lib/minitest/unit.rb:1072:i
      n `_run'\", \"org/jruby/RubyArray.java:1617:in `each'\", \"c:/jruby-1.7.4/lib/ruby/gems/sh
      ared/gems/minitest-4.7.4/lib/minitest/unit.rb:1071:in `_run'\", \"c:/jruby-1.7.4/lib/ruby/
      gems/shared/gems/minitest-4.7.4/lib/minitest/unit.rb:1059:in `run'\", \"tests/upload_brand
      ing.rb:87:in `(root)'\"]","result":false}
  </code></pre>
  
  <p>In IRB i found following errors</p>
  
  <pre><code>irb(main):038:0&gt; Wait.until { $driver.find_element(:css,'div.ui-dialog-buttonse&gt;button')[1].displayed? }
  Selenium::WebDriver::Error::TimeOutError: timed out after 80 seconds (Unable to locate element: {"method":"css selector","selector":"div.ui-dialog-buttonse&gt;button"})}
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/wait.rb:57:in `until'
      from (irb):38:in `evaluate'
      from org/jruby/RubyKernel.java:1093:in `eval'
      from org/jruby/RubyKernel.java:1489:in `loop'
      from org/jruby/RubyKernel.java:1254:in `catch'
      from org/jruby/RubyKernel.java:1254:in `catch'
      from C:\jruby-1.7.4\/bin/jirb_swing:53:in `(root)'
  </code></pre>
  
  <p>also for second command</p>
  
  <pre><code>irb(main):043:0&gt; elem = $driver.find_element(:css,'div.ui-dialog-buttonse&gt;button')[1]
  Selenium::WebDriver::Error::NoSuchElementError: Unable to locate element: {"method":"css selector","selector":"div.ui-dialog-buttonse&gt;button"}
      from [remote server] file:///C:/Users/seema/AppData/Local/Temp/webdriver-profile20130704-2984-1wifg7r/extensions/fxdriver@googlecode.com/components/driver_component.js:8444:in `FirefoxDriver.prototype.findElementInternal_'
      from [remote server] file:///C:/Users/seema/AppData/Local/Temp/webdriver-profile20130704-2984-1wifg7r/extensions/fxdriver@googlecode.com/components/driver_component.js:8453:in `FirefoxDriver.prototype.findElement'
      from [remote server] file:///C:/Users/seema/AppData/Local/Temp/webdriver-profile20130704-2984-1wifg7r/extensions/fxdriver@googlecode.com/components/command_processor.js:10456:in `DelayedCommand.prototype.executeInternal_/h'
      from [remote server] file:///C:/Users/seema/AppData/Local/Temp/webdriver-profile20130704-2984-1wifg7r/extensions/fxdriver@googlecode.com/components/command_processor.js:10461:in `DelayedCommand.prototype.executeInternal_'
      from [remote server] file:///C:/Users/seema/AppData/Local/Temp/webdriver-profile20130704-2984-1wifg7r/extensions/fxdriver@googlecode.com/components/command_processor.js:10401:in `DelayedCommand.prototype.execute/&lt;'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:607:in `execute'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:575:in `find_element_by'
      from C:/jruby-1.7.4/lib/ruby/gems/shared/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/search_context.rb:42:in `find_element'
      from (irb):43:in `evaluate'
      from C:\jruby-1.7.4\/bin/jirb_swing:53:in `(root)'
  </code></pre>
  
  <p>Kindly help</p>