Skip to content

Commit

Permalink
Patch Capybara to get rid of cucumber deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmei committed Jul 15, 2011
1 parent 395bb56 commit 7bfd695
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions features/support/env.rb
Expand Up @@ -74,3 +74,21 @@ def enqueue(klass, *args)
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

0 comments on commit 7bfd695

Please sign in to comment.