Skip to content

Commit

Permalink
Fix options with quotes under selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Apr 26, 2010
1 parent cbb42a1 commit 8a7ecba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/capybara/driver/selenium_driver.rb
Expand Up @@ -36,7 +36,7 @@ def set(value)
end

def select(option)
option_node = node.find_element(:xpath, ".//option[text()='#{option}']") || node.find_element(:xpath, ".//option[contains(.,'#{option}')]")
option_node = node.find_element(:xpath, ".//option[text()=#{Capybara::XPath.escape(option)}]") || node.find_element(:xpath, ".//option[contains(.,#{Capybara::XPath.escape(option)})]")
option_node.select
rescue
options = node.find_elements(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
Expand All @@ -49,7 +49,7 @@ def unselect(option)
end

begin
option_node = node.find_element(:xpath, ".//option[text()='#{option}']") || node.find_element(:xpath, ".//option[contains(.,'#{option}')]")
option_node = node.find_element(:xpath, ".//option[text()=#{Capybara::XPath.escape(option)}]") || node.find_element(:xpath, ".//option[contains(.,#{Capybara::XPath.escape(option)})]")
option_node.clear
rescue
options = node.find_elements(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
Expand Down

0 comments on commit 8a7ecba

Please sign in to comment.