# File lib/capybara/driver/selenium_driver.rb, line 9 def [](name) if name == :value node.value else node.attribute(name.to_s) end rescue Selenium::WebDriver::Error::WebDriverError nil end
# File lib/capybara/driver/selenium_driver.rb, line 60 def click node.click end
# File lib/capybara/driver/selenium_driver.rb, line 64 def drag_to(element) node.drag_and_drop_on(element.node) end
# File lib/capybara/driver/selenium_driver.rb, line 38 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.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
# File lib/capybara/driver/selenium_driver.rb, line 27 def set(value) if tag_name == 'input' and type == 'radio' node.click elsif tag_name == 'input' and type == 'checkbox' node.click if node.attribute('checked') != value elsif tag_name == 'textarea' or tag_name == 'input' node.clear node.send_keys(value.to_s) end end
# File lib/capybara/driver/selenium_driver.rb, line 68 def tag_name node.tag_name end
# File lib/capybara/driver/selenium_driver.rb, line 5 def text node.text end
# File lib/capybara/driver/selenium_driver.rb, line 46 def unselect(option) if node['multiple'] != 'multiple' raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box." end begin 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.clear 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
Generated with the Darkfish Rdoc Generator 2.