Merge remote branch 'robholland/master'

Conflicts:
	lib/capybara/session.rb
This commit is contained in:
Jonas Nicklas 2009-12-12 22:09:35 +01:00
commit bb2b98cc30
5 changed files with 18 additions and 6 deletions

View File

@ -17,16 +17,13 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
end
def set(value)
if tag_name == 'input' and %w(text password hidden file).include?(type)
if tag_name == 'textarea' or (tag_name == 'input' and %w(text password hidden file).include?(type))
node.clear
node.send_keys(value.to_s)
elsif tag_name == 'input' and type == 'radio'
node.select
elsif tag_name == 'input' and type == 'checkbox'
node.toggle
elsif tag_name == "textarea"
node.clear
node.send_keys(value.to_s)
end
end

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, :find_field, :find_link, :find_button,
:field_labeled, :all, :wait_for, :evaluate_script

View File

@ -37,6 +37,14 @@ module Capybara
button.click
end
def drag(source_locator, target_locator)
source = find(source_locator)
raise Capybara::ElementNotFound, "drag source '#{source_locator}' not found on page" unless source
target = find(target_locator)
raise Capybara::ElementNotFound, "drag target '#{target_locator}' not found on page" unless target
source.drag_to(target)
end
def fill_in(locator, options={})
field = wait_for(XPath.fillable_field(locator))
raise Capybara::ElementNotFound, "cannot fill in, no text field, text area or password field with id or label '#{locator}' found" unless field

View File

@ -36,7 +36,7 @@ module Capybara
end
def content(locator)
append("//*[contains(.,#{s(locator)})]")
append("/descendant-or-self::*[contains(.,#{s(locator)})]")
end
def table(locator)

View File

@ -362,6 +362,13 @@ shared_examples_for "session" do
@session.should have_content('Redirect')
end
it "should be true if scoped to an element which has the content" do
@session.visit('/with_html')
@session.within("//a[@title='awesome title']") do
@session.should have_content('labore')
end
end
it "should be false if the given content is not on the page" do
@session.visit('/with_html')
@session.should_not have_content('xxxxyzzz')