mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Fixed select method in Selenium driver (web-driver raises exception when element was not found)
This commit is contained in:
parent
9a91b98f8d
commit
c6c0e401bd
2 changed files with 7 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue