Started moving selenium on rails tests over to RSpec stories. See the updated README_DEVELOPERS for info on running the new tests.

This commit is contained in:
Luke Melia 2008-06-19 00:14:04 -04:00
parent 85dc6f4898
commit d47e863dfc
12 changed files with 257 additions and 74 deletions

View file

@ -11,24 +11,52 @@ module Webrat
end
def fills_in(label_text, options)
@selenium.type("webrat=#{Regexp.escape(label_text)}", "#{options[:with]}")
@selenium.type("webrat=#{label_text}", "#{options[:with]}")
end
def response_body
@selenium.get_html_source
end
def clicks_button(button_text = nil)
def clicks_button(button_text = nil, options = {})
button_text, options = nil, button_text if button_text.is_a?(Hash) && options == {}
button_text ||= '*'
@selenium.click("button=#{button_text}")
@selenium.wait_for_page_to_load()
wait_for_result(options[:wait])
end
def clicks_link(link_text)
@selenium.click("webratlink=#{Regexp.escape(link_text)}")
@selenium.wait_for_page_to_load()
def clicks_link(link_text, options = {})
@selenium.click("webratlink=#{link_text}")
wait_for_result(options[:wait])
end
def wait_for_result(wait_type)
if wait_type == :ajax
wait_for_ajax
elsif wait_type == :effects
wait_for_effects
else
wait_for_page_to_load
end
end
def wait_for_page_to_load(timeout = 15000)
@selenium.wait_for_page_to_load(timeout)
end
def wait_for_ajax(timeout = 15000)
@selenium.wait_for_condition "window.Ajax.activeRequestCount == 0", timeout
end
def wait_for_effects(timeout = 15000)
@selenium.wait_for_condition "window.Effect.Queue.size() == 0", timeout
end
def wait_for_ajax_and_effects
wait_for_ajax
wait_for_effects
end
def selects(option_text, options = {})
id_or_name_or_label = options[:from]