def select(option)
if node['multiple'] != 'multiple'
node.xpath(".//option[@selected]").each { |node| node.remove_attribute("selected") }
end
if option_node = node.xpath(".//option[text()=#{Capybara::XPath.escape(option)}]").first ||
node.xpath(".//option[contains(.,#{Capybara::XPath.escape(option)})]").first
option_node["selected"] = 'selected'
else
options = node.xpath(".//option").map { |o| "'#{o.text}'" }.join(', ')
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
end