Added options to selenium session methods to better handle ajax operations. For example: clicks_link('Foo', :wait => :ajax). I'd love to figure out
how to infer whether a click results in ajax vs. dom manipulation vs. page load, but we'll start with this.
This commit is contained in:
parent
7a5fbeef7f
commit
7d94c16ac8
@ -18,15 +18,43 @@ module Webrat
|
||||
@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 = {})
|
||||
|
Loading…
Reference in New Issue
Block a user