title: How do I fill the value of an input element with Mechanize?
body: <p>How do I change fill the value of an input element with Mechanize?</p>
  
  <p>What I want to do is set a ranger <a href="http://d.pr/i/nMuM" rel="nofollow">http://d.pr/i/nMuM</a> to be between 2010 and the default value of 2014 so the correct trucks show up for parsing. Would that be possible?</p>
  
  <p>I'm following the example <a href="http://mechanize.rubyforge.org/GUIDE_rdoc.html" rel="nofollow">here</a> but it doesn't seem to work.</p>
  
  <p>This is the code:</p>
  
  <pre><code>require "mechanize"
  
  @url = "https://www.kleyntrucks.nl/vrachtwagens/trekker/"
  
  a = Mechanize.new do |agent|
    agent.user_agent_alias = 'Mac Safari'
    agent.follow_meta_refresh = true
  end
  
  a.get(@url) do |page|
  
      bouwjaar_range_field = page.search("#imprp0")
  
      bouwjaar_range_details = bouwjaar_range_field.search(".details")
  
      input = bouwjaar_range_details.search("input")[0]
  
      input.value = "2010"
  
  end
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>/Users/username/Dropbox/Development/Rails/folder/lib/tasks/experiment.rb:20:in `block in &lt;main&gt;': undefined method `value=' for #&lt;Nokogiri::XML::Element:0x007fd4ab0fd9a8&gt; (NoMethodError)
      from /Users/username/.rvm/gems/ruby-2.0.0-p353@global/gems/mechanize-2.7.3/lib/mechanize.rb:442:in `get'
      from /Users/username/Dropbox/Development/Rails/folder/lib/tasks/experiment.rb:10:in `&lt;main&gt;'
  [Finished in 1.9s with exit code 1]
  </code></pre>
  
  <p><code>pp input</code> gives me the following output:</p>
  
  <pre><code>#(Element:0x3fe33c82ab68 {
    name = "input",
    attributes = [
      #(Attr:0x3fe33c869430 { name = "type", value = "hidden" }),
      #(Attr:0x3fe33c8692a0 { name = "name", value = "slider_from" }),
      #(Attr:0x3fe33c869278 { name = "value", value = "1968" })]
    })
  </code></pre>
  
  <p><code>puts input</code> gives me the following output:</p>
  
  <pre><code>&lt;input type="hidden" name="slider_from" value="1968"&gt;
  </code></pre>
  
  <p>Any ideas?</p>