Fixed select method in Selenium driver (web-driver raises exception when element was not found)

This commit is contained in:
Pavel Gabriel 2010-02-18 23:00:40 +02:00
parent 9a91b98f8d
commit c6c0e401bd
2 changed files with 7 additions and 8 deletions

View File

@ -28,12 +28,11 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
end
def select(option)
if option_node = node.find_element(:xpath, ".//option[text()='#{option}']") || node.find_element(:xpath, ".//option[contains(.,'#{option}')]")
option_node.select
else
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
option_node = node.find_element(:xpath, ".//option[text()='#{option}']") || node.find_element(:xpath, ".//option[contains(.,'#{option}')]")
option_node.select
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
def click

View File

@ -18,8 +18,8 @@ describe Capybara::Session do
end
end
# it_should_behave_like "session"
it_should_behave_like "session"
it_should_behave_like "session with javascript support"
# it_should_behave_like "session without headers support"
it_should_behave_like "session without headers support"
end
end