# File lib/capybara/rack_test/node.rb, line 14
  def set(value)
    if tag_name == 'input' and type == 'radio'
      other_radios_xpath = XPath.generate { |x| x.anywhere(:input)[x.attr(:name).equals(self[:name])] }.to_s
      driver.dom.xpath(other_radios_xpath).each { |node| node.remove_attribute("checked") }
      native['checked'] = 'checked'
    elsif tag_name == 'input' and type == 'checkbox'
      if value && !native['checked']
        native['checked'] = 'checked'
      elsif !value && native['checked']
        native.remove_attribute('checked')
      end
    elsif tag_name == 'input'
      if (type == 'text' || type == 'password') && self[:maxlength] &&
        !self[:maxlength].empty?
        # Browser behavior for maxlength="0" is inconsistent, so we stick with
        # Firefox, allowing no input
        value = value[0...self[:maxlength].to_i]
      end
      native['value'] = value.to_s
    elsif tag_name == "textarea"
      native.content = value.to_s
    end
  end