Patch Capybara to get rid of cucumber deprecation warnings
This commit is contained in:
parent
395bb5679b
commit
7bfd695483
1 changed files with 18 additions and 0 deletions
|
|
@ -74,3 +74,21 @@ end
|
||||||
After('@localserver') do
|
After('@localserver') do
|
||||||
CapybaraSettings.instance.restore
|
CapybaraSettings.instance.restore
|
||||||
end
|
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
|
||||||
Loading…
Reference in a new issue