Add drag API (subject to change), fix bug in has_content?

This commit is contained in:
Rob Holland 2009-12-09 09:34:42 +00:00
parent 4a55c1a7cb
commit b93e1cd5b5
2 changed files with 10 additions and 2 deletions

View File

@ -47,7 +47,7 @@ module Capybara
end
SESSION_METHODS = [
:visit, :body, :click_link, :click_button, :fill_in, :choose, :has_xpath?, :has_css?,
:visit, :body, :click_link, :click_button, :drag, :fill_in, :choose, :has_xpath?, :has_css?,
:check, :uncheck, :attach_file, :select, :has_content?, :within, :within_fieldset,
:within_table, :save_and_open_page, :find_field, :find_link, :find_button,
:field_labeled

View File

@ -44,6 +44,14 @@ module Capybara
find_button(locator).click
end
def drag(source_locator, target_locator)
source = find(source_locator).first
raise Capybara::ElementNotFound, "drag source '#{source_locator}' not found on page" unless source
target = find(target_locator).first
raise Capybara::ElementNotFound, "drag target '#{target_locator}' not found on page" unless target
source.drag_to(target)
end
def fill_in(locator, options={})
find_field(locator, :text_field, :text_area, :password_field).set(options[:with])
end
@ -73,7 +81,7 @@ module Capybara
end
def has_content?(content)
has_xpath?("//*[contains(.,#{sanitized_xpath_string(content)})]")
has_xpath?("[contains(.,#{sanitized_xpath_string(content)})] | //*[contains(.,#{sanitized_xpath_string(content)})]")
end
def has_xpath?(path, options={})