From 7bfd695483da88a72ea71ff93d2cb66061eb4918 Mon Sep 17 00:00:00 2001 From: Sarah Mei <sarahmei@gmail.com> Date: Thu, 14 Jul 2011 17:55:03 -0700 Subject: [PATCH] Patch Capybara to get rid of cucumber deprecation warnings --- features/support/env.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/features/support/env.rb b/features/support/env.rb index 226bfb4ef7..d793c64fc0 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -74,3 +74,21 @@ end After('@localserver') do CapybaraSettings.instance.restore end + +class Capybara::Driver::Selenium < Capybara::Driver::Base + class Node < Capybara::Node + def [](name) + node.attribute(name.to_s) + rescue Selenium::WebDriver::Error::WebDriverError + nil + end + + def select(option) + option_node = node.find_element(:xpath, ".//option[normalize-space(text())=#{Capybara::XPath.escape(option)}]") || node.find_element(:xpath, ".//option[contains(.,#{Capybara::XPath.escape(option)})]") + option_node.click + rescue + options = node.find_elements(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ') + raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}" + end + end +end \ No newline at end of file -- GitLab